<Kena>
I was trying to understand the concept of pointer since it is the mechanic slice's under the hood.
ur5us has quit [Ping timeout: 246 seconds]
frmdstryr has joined #zig
ur5us has joined #zig
a92 has joined #zig
Kingsquee has joined #zig
x2C25 has joined #zig
a92 has quit [Quit: Leaving]
Kena has quit [Remote host closed the connection]
leah2 has quit [Ping timeout: 264 seconds]
cole-h has joined #zig
earnestly has quit [Ping timeout: 258 seconds]
x2C25 has quit [Ping timeout: 258 seconds]
a_chou has joined #zig
a_chou has quit [Remote host closed the connection]
frmdstryr has quit [Ping timeout: 256 seconds]
lucid_0x80 has joined #zig
kristoff_it1 has quit [Ping timeout: 260 seconds]
copy has quit [Quit: copy]
copy has joined #zig
copy has quit [Client Quit]
copy has joined #zig
ur5us has quit [Ping timeout: 272 seconds]
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 260 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
dumenci has quit [Ping timeout: 260 seconds]
frett27_ has joined #zig
frett27_ has quit [Ping timeout: 264 seconds]
x2C25 has joined #zig
osa1 has joined #zig
squeek502 has joined #zig
ifreund has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
cole-h has quit [Ping timeout: 260 seconds]
omglasers2 has joined #zig
xackus_ has joined #zig
xackus_ has quit [Client Quit]
lucid_0x80 has joined #zig
lucid_0x80 has quit [Remote host closed the connection]
leah2 has joined #zig
Heppokoyuki has joined #zig
Heppokoyuki has quit [Client Quit]
skuzzymiglet has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
skuzzymiglet has quit [Quit: WeeChat 2.9]
tane has joined #zig
marnix has quit [Remote host closed the connection]
marnix has joined #zig
earnestly has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
nycex has quit [Ping timeout: 240 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
kristoff_it1 has joined #zig
Kingsquee has quit []
skuzzymiglet has joined #zig
moka has joined #zig
jj__ has joined #zig
sjums has joined #zig
jjsullivan1 has quit [Ping timeout: 260 seconds]
mokafolio has quit [Ping timeout: 260 seconds]
moka is now known as mokafolio
washbear is now known as racoon
ifreund has quit [Read error: Connection reset by peer]
ifreund has joined #zig
x2C25 has quit [Ping timeout: 246 seconds]
<dominikh>
is there a way to branch on whether a value is compile-time known or not? e.g. could one implement a std.fmt.format that worked with both constant format strings and dynamic format strings by emitting different code for the two cases?
<ifreund>
there's a reason the string must be comptime known, I don't think there's a way to implement a version taking a runtime known format string
<dominikh>
how so? the type of the tuple and the number of elements is still comptime known, isn't it? which should allow guarding against an incorrect number of {}
<dominikh>
(and invalid arguments to format specifiers)
<g-w1>
It would be runtime error instead of compile time right?
<dominikh>
that's my idea, yes
<dominikh>
it's very possible I'm missing something obvious here
<daurnimator>
dominikh: yeah you probably could.... might be worth trying
<daurnimator>
dominikh: main problem you'd hit is indexing args. tuple indexes need to be comptime known
<dominikh>
ah…
<ifreund>
yeah, you can only loop over a tuple at comptime since the fields are hetrogenous
<daurnimator>
you'd just have to work around it
<daurnimator>
e.g. `inline for (args) |a,i| if (i==wanted) dothing(a);`
<daurnimator>
which is expensive.... but would work.
<dominikh>
wouldn't that require wanted to be comptime known?
<daurnimator>
no
<ifreund>
yeah, that is quite code-bloaty
<dominikh>
couldn't one create a lookup table of index to bit offset in the tuple?
<ifreund>
structs don't have a well defined memory layout and that assumes tuples I assume
<ifreund>
maybe packed tuples are a thing
<dominikh>
but @bitOffsetOf does exist and operates on structs, right? they don't have a well-defined memory layout, but the compiler does know the layout
<dominikh>
it won't change from one execution to the next
<ifreund>
nice
Xavi92 has joined #zig
<Xavi92>
Just after compiling llvm release/v11.x, I'm surprised now zig complains about llvm version: https://bpa.st/raw/VPPQ
<dutchie>
how did you rebuild zig? you need to update the buildInputs as well as the makeDerivation call
<dutchie>
(that's what tripped me up the first time)
marnix has quit [Ping timeout: 268 seconds]
marnix has joined #zig
<Xavi92>
dutchie: I have removed the whole build folder generated by CMake and started from scratch by running `cmake ..`
frmdstryr has joined #zig
<dutchie>
wait why did i think you were using nix
<Xavi92>
Well, it's not generated by CMake, but files generated by CMake end up there
<Xavi92>
dutchie: I am using Kubuntu 20.04 LTS
<dutchie>
ok ignore me then i don't know what's going on
<Xavi92>
dutchie: thanks for your help anyway :)
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<Xavi92>
dutchie: did a quick workaround by adding the path where my llvm toolchain is located on cmake/Findllvm.cmake, cmake/Findlld.cmake and cmake/Findclang.cmake, as well as removing the version check
<Xavi92>
Now zig compiles, but does not link: https://bpa.st/GSEA . I'll keep on investigating why
Xavi92 has quit [Remote host closed the connection]
knebulae has quit [Read error: Connection reset by peer]
knebulae has joined #zig
waffle_ethics has joined #zig
donniewest has joined #zig
LanceThePants has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
<ifreund>
uh, why did we get rid of std.fmt.trim()?
<ifreund>
std.mem.trim() is not a direct replacement, I don't want to have to pass a list of whitespace characters everywhere
<ifreund>
and there is no std.mem.isWhitespace
<dutchie>
i used std.ascii.isSpace last time i needed it
swills has quit [Ping timeout: 260 seconds]
<ifreund>
I wouldn't expect that to include \n and \t?
<dutchie>
i'm not sure how to parse the tables that it uses
swills has joined #zig
<dutchie>
there is also isBlank which just checks against '0' and '\n'
<dominikh>
I would expect isSpace to roughly match C's isspace. space tends to mean both vertical and horizontal space, so \n and \t and space and what else there is
<dutchie>
anecdotally i think it stripped space and \n
Akuli has joined #zig
<dominikh>
the Space table has 6 entries, which fits. the table is probably just the first 128 characters in ASCII
<ifreund>
cool, isSpace returns true for everything I want
<dominikh>
the trick is returning false for the things you don't want ;)
<ifreund>
but I can't pass that directly to mem.trim() as that wants an array of values to trim
skuzzymiglet has quit [Quit: WeeChat 2.9]
mgxm has quit [Read error: Connection reset by peer]
mgxm has joined #zig
tdeo has quit [Read error: Connection reset by peer]
tdeo has joined #zig
<dutchie>
hmm, am i completely missing the point here, or would it be useful to have a reset method on ArenaAllocator?
<dutchie>
let's say i have a worker function that runs a loop which takes roughly constant space each iteration
<dutchie>
in that function i spawn an arena, reset it each iter, and then deinit it when i return
<dutchie>
at the moment i have to create a completely new arena each loop and i can't reuse the blocks that arena allocates
<dutchie>
FixedBufferAllocator has a reset
swills has quit [Ping timeout: 260 seconds]
skuzzymiglet has joined #zig
swills has joined #zig
swills has quit [Ping timeout: 258 seconds]
hnOsmium0001 has joined #zig
cole-h has joined #zig
swills has joined #zig
lucid_0x80 has joined #zig
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
<ifreund>
having a reset for ArenaAllocator would make the code a lot more complex
<ifreund>
dutchie: you could use a StackFallbackAllocator with an arena as a fallback
<dutchie>
hmm, that's probably overkill for this tbh
<dutchie>
i guess i don't understand the guts of ArenaAllocator, i thought it'd just be a matter of resetting a pointer
<ifreund>
nah, it owns multiple allocations
<ifreund>
reset is definetly possible to implement, but it would complicate things and I don't know if it would be worth it or not
tane has quit [Quit: Leaving]
skuzzymiglet has quit [Ping timeout: 264 seconds]
radgeRayden has joined #zig
jayschwa has joined #zig
Xavi92 has joined #zig
FireFox317 has joined #zig
GrooveStomp has quit [Ping timeout: 240 seconds]
jj__ has quit [Remote host closed the connection]
tane has joined #zig
jjsullivan1 has joined #zig
<FireFox317>
andrewrk, i'm working on clashos, and for clashos we run the emulator in one terminal window with `zig build qemu` and in another window we are suppose to `zig build upload` to upload a new binary. However now with the new cache architecture, the `zig build upload` hangs and a backtrace shows that is blocking on `std.os.flock`. What is the behaviour we want?
<andrewrk>
ah, interesting
<andrewrk>
the first thing I want to check is if it would make sense to make this just work
<FireFox317>
For some reason it is keeping the file locked, but i dont think it has to stay locked?
<andrewrk>
yeah that sounds right. I think for `zig run` we should be able to unlock everything except the executable
<andrewrk>
hmm probably the reasoning for keeping it locked would be for stack traces
<andrewrk>
ifreund, tests pass locally for #6931?
<andrewrk>
(just a native execution of std lib would be fine IMO)
<ifreund>
andrewrk: i ran zig test on std/ascii.zig which passed
<andrewrk>
good enough
<ifreund>
didn't touch anything else :)
<andrewrk>
ready for merge?
<andrewrk>
FireFox317, I think it would be worthwhile to explore releasing all locks for zig run
GrooveStomp has joined #zig
<FireFox317>
andrewrk, yeah that makes sense. However in this case i run `zig build qemu` which runs qemu as a system command and i wouldn't expect that that holds some locks, but apparantly it does?
<FireFox317>
I will make a GH issue, this is not something that has to be solved before 0.7.0 anyway
<g-w1>
what build_runner.zig it gets generated sometimes when I do zig build? is it supposed to be a temporary file to run the build?
<andrewrk>
g-w1, build_runner.zig is main() that calls your build()
<g-w1>
thanks. is it supposed to be removed, or should I add to gitignore?
<alexnask[m]>
Are you using zls by any chance?
<alexnask[m]>
If yes then its prpbably its fault :P
<alexnask[m]>
I should try making this better with the new cli, i had to copy paste it to run it with the old caching system because of a bug
<g-w1>
ok yeah. im using zls
<andrewrk>
FireFox317, I always appreciate your QA before the release :D
<FireFox317>
andrewrk, you are welcome :)
<GrooveStomp>
Hello! I'm getting a compile error trying to import openssl/ssl.h: 'pub const SSL_Library_init = @compileError("unable to translate C expr: expected identifier");'
<GrooveStomp>
No doubt I have completely missed something.
<FireFox317>
GrooveStomp, you should try with master too. The translate-c code has been improved a lot in this release.
<Xavi92>
Hi, I'm compiling latest zig with llvm release/v11.x and a couple of patches and I am getting the following link-time errors: https://bpa.st/GUHA
<GrooveStomp>
I did "snap refresh --classic zig --edge" and my version is now "0.6.0+909aae815"; that should be good, right? That seems to correlate with the last commit yesterday. I get the same compilation error, though.
<alexnask[m]>
Ssl library init looks like a pretty trivial macro, but its a function like macro with no args, maybe this is the bug (cant try it atm)
<andrewrk>
Xavi92, liblld is not getting linked, could the patches have to do with that?
xackus has joined #zig
<GrooveStomp>
alexnask you are correct. If I call c.OPENSSL_init_ssl(0, null); then it succeeds.
<FireFox317>
andrewrk, it looks like g-w1 just made a similar issue on GH (#6939)
<g-w1>
oh, I thought this was related, but then realized it was zig run instead. Are the generated files lock not being removed?
<FireFox317>
g-w1, i get the same problem (as described above) when i do `zig build run` in one terminal and then `zig build another` (which also does a run) in another window.
<FireFox317>
It looks like the locks are indeed not removed.
<andrewrk>
Xavi92, looks fine. next thing I would do is check the linker line and make sure the 3 lld libs are there
<Xavi92>
andrewrk: I have compiled clang and friends into $HOME/llvm-11-zig, and CMake would not configure zig unless I modified Findllvm.cmake, Findclang.cmake and Findlld.cmake. Apparently, those scripts only look in /usr and /usr/local
<Xavi92>
andrewrk: is `cmake ..` enough to configure zig?
<andrewrk>
generally, yes. some systems have "weird" things that you have to work around
<Xavi92>
andrewrk: I had already tried setting -DCMAKE_PREFIX_PATH, but it returns the following error: https://bpa.st/raw/O5LA
<Xavi92>
andrewrk: which is kinda funny since 11.X should allow 11.0.1, right?
osa1 has quit [Quit: osa1]
ur5us has joined #zig
radgeRayden has quit [Remote host closed the connection]
nullheroes has joined #zig
mmohammadi9812 has joined #zig
<andrewrk>
Xavi92, I just fixed that an hour ago in b30a765b95cf666409c1e53
<andrewrk>
it was a typo when updating from 10 to 11
frett27 has joined #zig
<Xavi92>
andrewrk: thanks!!
<andrewrk>
sorry for the trouble
frett27_ has quit [Ping timeout: 240 seconds]
<Xavi92>
np
Kingsquee has joined #zig
<Xavi92>
Now it compiles and links successfully :)
<Xavi92>
Has --c-source been deprecated?
<FireFox317>
Xavi92, yeah you are just suppose to pass c files to zig now and it will figure out if they are c files or not (by looking at the extension)
V is now known as ^
<Xavi92>
FireFox317: I see, thanks!
<Xavi92>
FireFox317: what about --linker-script, BTW? Just removing it returns "error: unrecognized file extension of parameter"
<Xavi92>
Otherwise, it returns "error: unrecognized parameter: '--linker-script'"
<FireFox317>
Xavi92, apparantly changed to: `-T[script], --script [script] Use a custom linker script`
<andrewrk>
we now match clang's option for linker scripts
<Xavi92>
FireFox317, andrewrk: makes sense, thanks again
^ is now known as V
<Xavi92>
`zig --help` did not show that option, so forgive me for asking so mcuh
<g-w1>
I think you need zig build-exe --help
omglasers2 has quit [Ping timeout: 264 seconds]
<Xavi92>
g-w1: thanks!
cole-h has quit [Quit: Goodbye]
<g-w1>
np
cole-h has joined #zig
allan0 has quit [Quit: no]
allan0 has joined #zig
FireFox317 has quit [Ping timeout: 246 seconds]
frett27_ has joined #zig
frett27 has quit [Ping timeout: 265 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
skuzzymiglet has quit [Ping timeout: 240 seconds]
waffle_ethics has quit [Ping timeout: 256 seconds]
<Xavi92>
Hrm, my project used to build on llvm-10 and older versions of zig, but now segfaults on latest zig+llvm-11: https://bpa.st/raw/IV6Q
<Xavi92>
As shown, I am compiling a bunch of assembly files using mipsel-unknown-elf-as (used to work well with the older toolchain). Instead, if I add those assembly files into zig, the assembler does not recognize a valid MIPS I instruction: https://bpa.st/raw/TASA
<andrewrk>
Xavi92, did you send the right paste? this is a link error not a segfault
<Xavi92>
andrewrk: the paste reads "make: *** [Makefile:35: main] Aborted (core dumped)" at the bottom. That does not seem zig to be the one crashing, though
<andrewrk>
the interesting bits are the lld: error: lines
<andrewrk>
unfortunately this may be something that has to be fixed in LLVM. one thing you can double check is what CPU features you are targeting
<Xavi92>
andrewrk: I guess "-target mipsel-freestanding-none --single-threaded -mcpu mips1+soft_float" are the target CPU features, right?
<andrewrk>
yes
<andrewrk>
specifically mips1+soft_float
<Xavi92>
I'm targetting the MIPS R3000A on the original Sony PlayStation
<Xavi92>
mips1+soft_float worked on previous versions of zig - can't tell whether a breaking change was recently introduced
<andrewrk>
Xavi92, unfortunately I think the next step here is to file an LLD bug repuort. The good news is that it's quite active, especially for ELF stuff
<Xavi92>
andrewrk: still, thanks a lot for your help :)
<andrewrk>
given that it is a regression from lld 10, it is likely we could see a fix in lld 11.0.2
mmohammadi9812 has quit [Quit: Quit]
mmohammadi9812 has joined #zig
<Xavi92>
User self-registration is no longer allowed on https://bugs.llvm.org, so it might take a few hours or days until I can post the issue here. I'll keep you informed
<Xavi92>
s/here/there
Akuli has quit [Quit: Leaving]
<GrooveStomp>
How do I specify that I want to link with a system library? I'm trying LibExeObjStep.addLibPath and LibExeObjStep.linkSystemLibrary; but I'm getting undefined symbols.
<ifreund>
are you sure you're linking the right library?
<ifreund>
linkSystemLibrary() is what you want
<ifreund>
don't forget to linkLibC() as well
<ifreund>
GrooveStomp: ^
mschwaig has joined #zig
<GrooveStomp>
linkLibC()? I'm doing linkSystemLibrary("c"); is this wrong?
<GrooveStomp>
I'm trying to link libssl. With "ldconfig -p | grep ssl" I see a bunch of options. "/lib/x86_64-linux-gnu/libssl.a" is there; so I'm trying that. exe.addLibPath("/lib/x86_64-linux-gnu"); exe.addSystemLibrary("ssl");
<ifreund>
linkLibC() just calls linkSystemLibrary("c") iirc
<ifreund>
I've never needed to use addLibPath(), addIncludeDir() has been enough
<ifreund>
are the missing symbols from libssl or something else?
<GrooveStomp>
They're from libssl. Well, I *think* they are. Let me double check...
<GrooveStomp>
Ah, missing libcrypto
<GrooveStomp>
Thanks for your help again ifreund!
<ifreund>
no problem!
frett27_ has quit [Read error: Connection reset by peer]
<andrewrk>
it would be nice if C header files told you which library a given function is supposed to be in
marnix has quit [Read error: Connection reset by peer]
<ifreund>
sure would :P
marnix has joined #zig
tane has quit [Quit: Leaving]
Kena has joined #zig
<Kena>
Are the test blocks ignored at compilation for release builds?
marnix has quit [Ping timeout: 260 seconds]
<GrooveStomp>
Is there a way to do a negative optional check? Like: if (!optional_foo) { return Error.Foo; }
<jayschwa>
if (optional_foo == null) return error.Foo;
skuzzymiglet has joined #zig
<GrooveStomp>
Ah, great, thanks jayschwa!
donniewest has quit [Quit: WeeChat 2.9]
<jayschwa>
GrooveStomp, if you immediately "unwrap" the optional after that, an alternative is const foo = optional_foo orelse return error.Foo.
<GrooveStomp>
I suppose that's more idiomatic than repeatedly unwrapping it at every use?
frmdstryr has quit [Ping timeout: 260 seconds]
<daurnimator>
andrewrk: if only there was an answer to that..... POSIX might say one thing; glibc might say another; musl puts them all into one....