ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<aconbere> oh!
<aconbere> actually it does
<aconbere> when I run with exe.linkLibC() my compiler errors about sys not containing AI_NUMERICSERV also go away
<aconbere> :mindblown:
<aconbere> doesn't love that I'm trying to pass null to getaddrinfo, so maybe that's my next challenge
wilsonk_ has joined #zig
wilsonk has quit [Ping timeout: 265 seconds]
factormystic has quit [Remote host closed the connection]
factormystic has joined #zig
factormystic has quit [Remote host closed the connection]
factormystic has joined #zig
factormystic has quit [Remote host closed the connection]
factormystic has joined #zig
factormystic has quit [Remote host closed the connection]
factormystic has joined #zig
factormystic has quit [Remote host closed the connection]
factormystic has joined #zig
<bbuccianti> how do I cast an i32 as a usize?
<bbuccianti> I can't
<waleee-cl> do you get an error?
<bbuccianti> error: unable to evaluate constant expression
<waleee-cl> which way did you use?
<bbuccianti> I made this @intCast(usize, @intCast(u64, w * h)) being w and h i32
dimenus has quit [Quit: WeeChat 3.1]
<waleee-cl> assign w * h to a const and see if it compiles
<waleee-cl> @as should allow the expression I think
voldyman has quit [Quit: Connection closed for inactivity]
<bbuccianti> yeah @as(usize, @intCast(u64, w * h)) did it
<bbuccianti> thanks waleee-cl
<waleee-cl> bbuccianti: the @intCast isn't necessary
<bbuccianti> error: expected type 'usize', found 'i32'
<waleee-cl> ah. ok
gazler has joined #zig
brzg has joined #zig
gazler_ has quit [Ping timeout: 276 seconds]
forgot-password has joined #zig
zags has quit [Ping timeout: 256 seconds]
ifreund has quit [Ping timeout: 260 seconds]
fputs has joined #zig
rslabbert has joined #zig
rslabbert has quit [Client Quit]
rslabbert has joined #zig
squeek502 has quit [Remote host closed the connection]
<oats> are different versions of functions like debug.print() going to be generated for every type you use for the second argument?
<oats> since the struct types are different
earnestly has quit [Ping timeout: 245 seconds]
brzg has quit [Quit: leaving]
<andrewrk> oats, yes
<oats> whew
<oats> thanks :)
forgot-p1ssword has joined #zig
forgot-password has quit [Ping timeout: 256 seconds]
<mikdusan> this looks wrong to me:
<mikdusan> before the big `Compilation.zig` and `link/MachoO.zig` it was this code:
<andrewrk> is_dyn_lib => -static
<andrewrk> yeah that's backwards
<mikdusan> ok just checking.
<mikdusan> lots of corners with cobwebs here. I think eventually we'll fix one that helps llvm12 zig-bootstrap :)
layneson has quit [Ping timeout: 246 seconds]
<oats> how should I approach allocations made by other libraries that utilize libc? should I just utilize free() from stdlib.h?
<andrewrk> if an external API expects you to call free() from libc, then you can call std.c.free
<oats> grrr seems like libedit is leaking memory
<oats> that's cool
terinjokes has quit [Quit: ZNC 1.8.1 - https://znc.in]
terinjokes has joined #zig
powerofzero has joined #zig
<oats> good song
<powerofzero> Hi. I'm working on wrapping a c library in zig, and I would like to bundle the c library. Are there any good examples of others who have done this?
<oats> hah, wrong channel lol
<oats> not you power
<powerofzero> Is this not #zig?
<oats> I'm just a little tipsy
<powerofzero> oh np
<oats> just didn't look where I was posting
powerofzero has quit [Ping timeout: 260 seconds]
Rum has joined #zig
klltkr has quit [Quit: Textual IRC Client: www.textualapp.com]
Rum has quit [Quit: Leaving]
dyeplexer has joined #zig
cole-h has quit [Ping timeout: 256 seconds]
decentpenguin has quit [Read error: Connection reset by peer]
adsr has quit [Remote host closed the connection]
adsr has joined #zig
decentpenguin has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
earnestly has joined #zig
forgot-p1ssword has quit [Ping timeout: 246 seconds]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 246 seconds]
ur5us has joined #zig
powerofzero has joined #zig
powerofzero has quit [Ping timeout: 260 seconds]
mipri has joined #zig
texno has joined #zig
ur5us has quit [Ping timeout: 264 seconds]
forgot-password has joined #zig
ifreund has joined #zig
yyp has joined #zig
dok has quit [Quit: bye]
tughi has joined #zig
rslabbert has quit [Quit: Leaving]
zags has joined #zig
supercoven has joined #zig
forgot-password has quit [Ping timeout: 260 seconds]
yyp has quit [Quit: disconnected]
yyp has joined #zig
forgot-password has joined #zig
yyp has quit [Client Quit]
yyp has joined #zig
forgot-password has quit [Ping timeout: 260 seconds]
forgot-password has joined #zig
kenran has joined #zig
kenran_ has joined #zig
kenran has quit [Quit: Lost terminal]
forgot-password has quit [Ping timeout: 256 seconds]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 246 seconds]
vegai has quit [Ping timeout: 260 seconds]
dreda has quit [Ping timeout: 260 seconds]
vegai has joined #zig
earnestly has quit [Quit: WeeChat 3.1-rc1]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 246 seconds]
dreda has joined #zig
kenran_ has quit [Quit: Lost terminal]
kenran has joined #zig
<yyp> How does linking lld on base compiler work if you strip down cmake magic? pkg-config didn't help
eax has joined #zig
_whitelogger has joined #zig
earnestly has joined #zig
notzmv has quit [Ping timeout: 256 seconds]
Sumera[m] has joined #zig
yyp has quit [Ping timeout: 260 seconds]
eax has quit [Ping timeout: 268 seconds]
yyp has joined #zig
eax has joined #zig
notzmv has joined #zig
eax has quit [Quit: eax]
wootehfoot has joined #zig
kenran has quit [Quit: leaving]
cole-h has joined #zig
pafmaf[m] has joined #zig
kenran has joined #zig
texno has quit [Ping timeout: 276 seconds]
texno has joined #zig
waleee-cl has joined #zig
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 245 seconds]
neptunepink has quit [Ping timeout: 260 seconds]
forgot-password has joined #zig
mikdusan1 has joined #zig
forgot-password has quit [Ping timeout: 265 seconds]
forgot-password has joined #zig
mikdusan has quit [Ping timeout: 246 seconds]
neptunepink has joined #zig
factormystic has quit [Ping timeout: 265 seconds]
factormystic9 has joined #zig
factormystic9 has quit [Read error: Connection reset by peer]
<mikdusan1> quit
mikdusan1 has quit [Quit: WeeChat 3.0.1]
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
Daimanta has joined #zig
<Daimanta> Hi, I have a quesion
<Daimanta> I noticed when running the Zig tests that I made, that the tests seem to stop at the first failure. Is that correct?
<ifreund> yep
<Daimanta> Ok, that answers the question. Question number 2: Is it possible to run all tests and then show the failures in some way?
<ifreund> /buffer 7
<yyp> Daimanta: that doesn't seem to be supported
<ifreund> nope, test failures are just @panic()s
<Daimanta> Ok, that's clear. Are there any plan for support of that functionality?
<ifreund> you could surely implement something with https://github.com/ziglang/zig/issues/6621
marijnfs has joined #zig
<marijnfs> i'm still trying to get some insight in a strange loop my program gets in
<marijnfs> I wonder if the pthread lock in debug.warn is involved
<marijnfs> gdb shows something like this
<Daimanta> Ok, thanks for the answers
factormystic has joined #zig
jumpnbrownweasel has joined #zig
Rum has joined #zig
notzmv has quit [Ping timeout: 256 seconds]
dyeplexer has quit [Remote host closed the connection]
Akuli has joined #zig
aconbere has quit [Quit: leaving]
notzmv has joined #zig
forgot-password has quit [Ping timeout: 260 seconds]
mikdusan has joined #zig
aconbere has joined #zig
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 260 seconds]
forgot-password has joined #zig
<marijnfs> Is there something clearly wrong here? https://github.com/marijnfs/zig-nng/blob/debug/src/serialise.zig
<marijnfs> especially serialise_msg, the union case
<marijnfs> the strangest thing is, if I uncomment line 144, i get a compile error at line 137: serialise.zig:137:17: error: control flow attempts to use compile-time variable at runtime
<ifreund> marijnfs: that gdb output isn't terribly helpful, could you provide a bt full?
<aconbere> Hi! I've been playing with using zig as a "pragmatic c" and running into some bumps along the way. From ziglearn it mentions `zig translate-c` as a tool to quickly lift c into zig.
<aconbere> I took a pretty basic c program and ran it, and translate-c complains about not finding `stdio.h`
<aconbere> gcc happily finds and builds the program, is there something I have to hint translate-c to about the location of headers?
<ifreund> aconbere: you need to tell zig to link libc
<ifreund> pass -lc
<marijnfs> like that?
<marijnfs> there is no obvious recursive call, but it definitely gets stuck in this serialise function
<aconbere> ifreund: works! thanks
<aconbere> hmmmmmmmmmm
<aconbere> okay well zig translates my c (into as it says it will, a bit of a horror)
<aconbere> but I was hoping to glean from that, how to do good c-interopt with zig and I'm afraid I'm still a bit lost
<ifreund> aconbere: using a C library from zig is often as simple as importing the headers into your zig code via @cImport()/@cInclude()
<ifreund> which essentially run translate-c on the headers and @import() the output
<aconbere> ifreund: really what I want to do is write a simple TCP or UDP client / server in zig
<ifreund> you don't need any C for that
<aconbere> would love to have the code /in/ zig for the improved ergonomics
<aconbere> agreed!
<aconbere> but I'm failing to get the syscalls to play nice :)
<ifreund> if you're on linux std.os/std.net should have everything you need
<aconbere> I want to call getaddrinfo with NULL as the nodename
<aconbere> but zig isn't happy with me doing that naively
<aconbere> presumably because it needs to get cast into a c pointer
Rum has quit [Quit: Leaving]
wootehfoot has quit [Quit: Leaving]
Daimanta has quit [Quit: Connection closed]
<aconbere> ifreund: hmmm std.net feels like it has a lot of assumptions already baked in
<ifreund> aconbere: agree, std.net is not great
<ifreund> getaddrinfo isn't really a syscall, just a libc thing that does some logic and syscalls for you
<ifreund> ideally std.net would be able to do everything it does
<aconbere> For what it's worth I don't think that's horrible I just wanted to play with the guts of things
<aconbere> and found it hard haha
<aconbere> Understood!
<aconbere> The pathway here is really something like "oh I heard that zig was a interesting and upcoming c replacement, let's take something I can do in c but isn't much fun, and try it in zig"
<ifreund> anyhow, you're right that the definition of getaddrinfo in std.c should have the first parameter made optional (PR welcome)
<aconbere> ifreund: another question while I'm here :-D
<aconbere> in my journey here I played around in std.net, I've found that I can make obviously breaking changes there, but when I re-compile zig the compiler doesn't error out
<aconbere> is there a flag to the zig build that's required to compile the std library?
<ifreund> marijnfs: I haven't been able to glean anything from the stack trace, it looks like you're deadlocking on the stderr mutex which should only happen if something tries to acquire it while it is already held by the same thread
<ifreund> aconbere: the std (like all zig code) is lazily compiled when it is required by whatever code you have written
* aconbere nods
<ifreund> if you were to change something required by the compiler the build would fail
<ifreund> but if you change stuff the compiler doesn't require and the code still parses fine, you won't get a compile error until trying to use it in a project
<ifreund> marijnfs: are you doing anything weird with threads?
<ifreund> putting a breakpoint in the acquire function might help
<aconbere> ifreund: is there a document that outlines the standard development process for contributors?
<aconbere> I guess what I'm wondering is, how did the std.net package get tested in the first place :-D
<ifreund> oh running the standard library tests should build and test it
<aconbere> my intuition would there would be a flag to either force compilation, or to trigger testing in a way that those units are "used"
<aconbere> ahh
<ifreund> if you run zig build --help in the root of the repo you'll see a lot of opitons
<ifreund> usually I just run zig test /file/im/touching if the changes are limited in scope
<aconbere> interesting, I've been following the instructions that go through cmake etc.
<ifreund> oh you need to go through cmake to build the stage1 compiler first
<ifreund> but once you have that you can use the build.zig to test the std and build the WIP stage2 compiler
<aconbere> goooooot it
via has quit [Ping timeout: 256 seconds]
<aconbere> so i'm bootstrapping the compiler
<aconbere> but typically once bootstrapped folks would use zig to compile zig
<ifreund> yeah, and the stage1 compiler is actually written partially in zig as well
via has joined #zig
<ifreund> so it's building a very limited zig0 compiler which is 100% C++ and then using that to build the zig parts of stage1
<aconbere> cool
<aconbere> pretty impressive how fast it is
<aconbere> so used to something like GCC or Rust or LLVM where I expect compilation to take 3 hours
<ifreund> stage1 is really really slow
<ifreund> just wait till stage2 is done :P
<aconbere> haha
notzmv has quit [Ping timeout: 245 seconds]
<aconbere> oh man
<aconbere> the CONTRIBUTING section of the readme covers all of this
<aconbere> sorry for bother you ha
<aconbere> seems like I'm on a better track now
<ifreund> heh, no worries :)
<aconbere> Yay! And the std.net test appropriately fails
<marijnfs> ifreund: threads are involved. But I manage to get this error also in a simple 'zig build test' that only calls this serialise
<marijnfs> i don't believe threads are involved there
<ifreund> marijnfs: are you using zig master?
<ifreund> more specifically, do you have 89ee4b86?
powerofzero has joined #zig
<marijnfs> yes, have master from today
<marijnfs> ifreund: it also doesn't look like a deadlock, because it goes in a crazy printing loop
<ifreund> oh? what is it printing?
notzmv has joined #zig
<marijnfs> ifreund: basically, I add a print statement in the beginning of 'serialise_msg', and that keeps printing like crazy
<marijnfs> but there is no deep callstack or something, which is very confusing
<marijnfs> maybe it's a recursive callstack, but llvm is smart to optimise it?
<ifreund> what output do you get?
<marijnfs> ifreund: so that test calls 'try serialise_msg(nearest_peer, msg.?);', then the output looks like: https://0bin.net/paste/U8kKAm1t#8kWM-HW5gdmytDA904zo57Lnv3xwBrwtuZWkAyFSbBP
<marijnfs> if I stop the program in gdb, I get this small stacktrace
yyp has quit [Quit: disconnected]
eax has joined #zig
<ifreund> why is it getting called with void?
dok has joined #zig
forgot-password has quit [Ping timeout: 256 seconds]
ur5us has joined #zig
<marijnfs> ifreund: not sure, one of the Response enums is void, but not the one I'm testing
forgot-password has joined #zig
<marijnfs> when i'm trying to print the typeInfo of what i'm serialising, I get a compiler bug:( https://0bin.net/paste/wWd3v1Xi#-2YAdn+s4gHWZj1ekFlU4PeuWxAP/p/VDZ+ZbYhwifd
<marijnfs> but i guess that's unrelated
forgot-password has quit [Ping timeout: 260 seconds]
supercoven has quit [Ping timeout: 246 seconds]
aconbere has quit [Ping timeout: 265 seconds]
texno has quit [Ping timeout: 264 seconds]
texno has joined #zig
aconbere has joined #zig
aconbere has quit [Ping timeout: 245 seconds]
notzmv has quit [Ping timeout: 260 seconds]
aconbere has joined #zig
<aconbere> ifreund_: follow up question from earlier (sorry if you're away), curious about the philosophical stance zig takes on c interopt. For instance it's valid to call getaddrinfo with a NULL hint pointer. But the result is the same as if you had specified a handful of hint values (it's basically shorthand for "default")
<aconbere> Curious if zig would take the stance of being faithful to the original c interface (null is valid, go for it)
<aconbere> or would take a stronger position on safety and say "look just pass in the hint, we can do things to help with defaults"
<ifreund> aconbere: passing in a null pointer there isn't unsafe, zig should allow it
<ifreund> if you want to open a PR making the first argument of std.c.getaddrinfo optional I'll merge it :P
<aconbere> haha
<aconbere> well I'm actually from reading the man page
<aconbere> suggesting a little bit more
<aconbere> node, service, and hints are all valid to be null
<aconbere> (although there is a constraint that both node and service cannot be null at the same time)
<ifreund> well, make 'em all optional pointers then I guess :D
<aconbere> I believe that's the diff I'm suggesting, with just the null node tests pass
<aconbere> haha
<aconbere> but I'll run the full stdlib tests now and see what happens
<aconbere> `./zig build test-std -Dskip-release` is the command I'm running to run the tests
<aconbere> just to check that I'm doing it right
<aconbere> (since this is in the std-lib i'm assuming for the sake of testing locally that those are approppriate)
<ifreund> I doubt allowing null there will break anything, that command is fine though
<aconbere> yeah I hold the same intuition :)
<aconbere> but I also prefer to do my due dillegence
kenran has quit [Remote host closed the connection]
<aconbere> As a person who first read the documentation for zig yesterday
<aconbere> I don't hold my intuition in particularly high value
<marijnfs> ifreund: it does seem to have to do with the void in the union, even though it doesn't get serialised
sundbp has joined #zig
<marijnfs> yeah, if I make that one a usize or whatever things are fine
<marijnfs> voids are not handled well I guess?
<marijnfs> also had issues with parentPtr and voids
riba has joined #zig
powerofzero has quit [Ping timeout: 265 seconds]
powerofzero has joined #zig
powerofzero has quit [Remote host closed the connection]
powerofzero has joined #zig
Akuli has quit [Quit: Leaving]
forgot-password has joined #zig
<ugla> I had a void issue in my BARE lib too. A user reported and fixed it for me, and also opened this issue: https://github.com/ziglang/zig/issues/7866
<ifreund> marijnfs: that looks like the exact bug you're hitting ^
<ugla> Haven't looked into it myself but thought it might be related
decentpenguin has quit [Read error: Connection reset by peer]
fputs has quit [Quit: WeeChat 3.1]
decentpenguin has joined #zig
notzmv has joined #zig
riba has quit [Ping timeout: 245 seconds]
drakonis has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
<aconbere> hmmmm
<aconbere> what am I doing wrong now :P
<aconbere> `./bin/zig build test-std -Dskip-release -Dforce-link-libc=true` results in an error `error: dependency on libc must be explicitly specified in the build command`
<aconbere> I tried `./bin/zig build -lc test-std -Dskip-release -Dforce-link-libc=true`
<aconbere> but that complains `Unrecognized argument: -lc`
<waleee-cl> aconbere: I think you can only pass -lc with zig build-exe/build-lib
wilsonk_ has quit [Quit: Leaving]
<aconbere> oh no! haha
<g-w1> force-link-libc is not what you want
<aconbere> I'll try anything ;-)
<g-w1> it tries to use the self-hosted linker to link stuff which is not complete yet
<g-w1> why do you wanna link libc?
<aconbere> I'm working on a PR to update getaddrinfo's call signature to match libc's (which allows for passing null points for nodename, service, and hint)
<aconbere> I figured, I'll write a test for it!
<g-w1> oh wait nvm thats not what it does, but still not what you want, it forces stage2 to link libc
<aconbere> but the test depends on libc since that's where getaddrinfo comes from
<g-w1> hmm, there must be other tests that depend on libc
<aconbere> anyway so I'm trying to run a test in the stdlib that depends on libc
<aconbere> yeah! std.net for sure
<aconbere> :)
<aconbere> (lib/std/net/test.zig)
<aconbere> since it in turn depends on std.c
<g-w1> this means that the test-harness needs to link libc, so you have to update build.zig (I guess no tests have linked libc yet. maybe this is on purpose. you will get feedback on your pr if this is wrong)
<aconbere> haha
ur5us has quit [Ping timeout: 264 seconds]
<aconbere> okay well, maybe I can ask my other question then and push and see what happens
<aconbere> The reason I decided to make a test, beyond it being a good practice
<g-w1> i would ask in the pr is there any reason why tests don't link libc
<aconbere> well this other question is a baby zig question (because that's what I am)
<aconbere> I'm just not confident I'm constructing a null c pointer correctly
<aconbere> I was hoping I could bang out a quick test to answer that question
<g-w1> ok, yeah try it
<aconbere> I'll push the damn PR and learn a bunch haha
<g-w1> just do test_step.linkLibC() in build.zig
<g-w1> i would add a -Dno-link-libc option in build.zig tho where it does if !(no-link-libc) test_step.linkLibC() then in the test that needs libc `if (!std.builtin.link_libc) return error.SkipZigTest;`
texno has quit [Ping timeout: 260 seconds]
texno has joined #zig
<aconbere> hmmmmm
<aconbere> g-w1: `error: no member named 'linkLibC' in struct 'std.build.Step'`
<aconbere> looks like test_stage2's type has that function
<aconbere> I'm so new to this I'm just kinda... trying stuff though hah
decentpenguin has quit [Read error: Connection reset by peer]
<g-w1> yeah, ill try it too
<aconbere> maybe it matters that I do both exe and test
powerofzero has quit [Ping timeout: 256 seconds]
decentpenguin has joined #zig
<g-w1> nah
<g-w1> its the wrong type, ill find the right one
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
<aconbere> in the meantime I'll put up my rough draft :)
<g-w1> aconbere: see lib/std/io/c_writer.zig:37-end. the test harness is already smart enough to link libc
forgot-password has quit [Ping timeout: 264 seconds]
<g-w1> -Dskip-libc disables all libc tests