ChanServ changed the topic of #zig to: zig programming language | | be excellent to each other | channel logs:
earnestly has quit [Ping timeout: 268 seconds]
amk has quit [Remote host closed the connection]
amk has joined #zig
dreda has quit [Quit: leaving]
notzmv has quit [Ping timeout: 265 seconds]
pretty_dumm_guy has quit [Quit: WeeChat 3.2-dev]
daex has quit [Ping timeout: 260 seconds]
daex has joined #zig
bitmapper has joined #zig
<kiedtl> What's the proper way to coerce a string literal to a '*const []u8' when initializing a struct? Just putting the string there `.field = "foo",` leads to the error "pointer type child '[10:0]u8' cannot cast into pointer type child '[]u8'"
<waleee-cl> @as ?
<g-w1> uhh, you probably dont want *const []u8
<g-w1> that is a constant pointer to a mutable slice of u8
<g-w1> you probably want []const u8 :)
<g-w1> wait, its a pointer to a constant slice to mutable u8s
<g-w1> fun!
<kiedtl> welp, you're right
<kiedtl> thanks
<g-w1> np :D
notzmv has joined #zig
klltkr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
recalloc has joined #zig
motersen has quit [Remote host closed the connection]
motersen has joined #zig
hiljusti has joined #zig
ur5us has joined #zig
ur5us has quit [Ping timeout: 245 seconds]
hiljusti has quit [Ping timeout: 260 seconds]
antaoiseach has joined #zig
<antaoiseach> Hello folks, I have worked through the lang ref and ziglearn code (most of them), and am thinking of doing some small toy projects. With this in mind, I have a couple of questions about project layouts.
<antaoiseach> In ziglearn, I found an example of how to make a project a dependency of another - in the dependency, I didn't find a build.zig, but found a zig.mod file. Is this a supported feature of Zig?
<antaoiseach> If so, is this the recommended way? In any case, how would the general way of structuring a library and/or a binary project look like? I know about `zig init`. If you guys could point me to a representative example, that'd be great!
antaoiseach has quit [Quit: leaving]
antaoiseach has joined #zig
<noam> antaoiseach: the zig.mod file there isn't needed for the dependency
<noam> That's for use with an unofficial package manager, I believe
<antaoiseach> noam: aha
<noam> addPackage in build.zig does everything you need
<antaoiseach> So zig init-lib along with addPackage in the client project?
<noam> Yep
<antaoiseach> noam: Nice! Thank you. I'll try it out.
<noam> np :)
zenkuro has quit [Ping timeout: 252 seconds]
<antaoiseach> noam: Hey, that worked rather nicely! :-).. I have a few more questions about that, if you don't mind!
<noam> Shoot :)
<antaoiseach> So in addPackage, in the path, we should always point to the root source file for the project, right?
<noam> I believe so, yeah
<antaoiseach> Also, `pub` is needed for the symbols to be visible directly from other modules, but `export` is sufficient if I'm going to be linking agains the library (static/dynamic)? Is this correct?
<noam> Not *quite*
<antaoiseach> other Zig modules*
<noam> Pub is needed for @import, export is needed for *extern*
<antaoiseach> noam: right, exactly!
<noam> Or for e.g. declaring it extern in C
<noam> addPackagePath just causes build.zig to invoke zig with --pkg-begin NAME PATH --pkg-end
<antaoiseach> That makes sense
<noam> (and with dependencies)
<antaoiseach> Ah, so we could actually invoke it from the command line itself, huh?
<antaoiseach> Cool! However, suppose I generated a dylib/so in a project, and wanted to use that in my client Zig project, then I don't really need the build.zig file?
<antaoiseach> Or can I link it in build.zig so that I don't build the other project?
<antaoiseach> I could simply link it and use it like any other native lib (-I. -libfoo), right?
<noam> Yeah
<noam> build.zig is never *needed*
<antaoiseach> Aha
<noam> it just makes life a *lot* easier
<noam> it's like using makefiles with a C project
<noam> Could you write out the compilation command yourself? Sure
<noam> Do you want to? No. No, you don't. :)
<antaoiseach> hahaha, okay, that makes sense!
<antaoiseach> Just find the steps a bit quirky, but I think I'll get used to it! :D
<noam> Yeah, it can take a bit to wrap your head around it :)
<antaoiseach> (inside the build.zig file that is - it's generated, so that makes life easier for me)
<antaoiseach> noam: hehe, yeah.
allan0 has quit [Quit: no]
<antaoiseach> Okay, that makes things so much clearer now. Thank you so much for your help, noam. Appreciate it! :-)
<noam> No problem :)
<antaoiseach> cheers!
antaoiseach has quit [Quit: leaving]
waleee-cl has quit [Quit: Connection closed for inactivity]
cole-h has quit [Ping timeout: 252 seconds]
knebulae has quit [Read error: Connection reset by peer]
recalloc has quit [Ping timeout: 252 seconds]
recalloc has joined #zig
recalloc has quit [Ping timeout: 246 seconds]
earnestly has joined #zig
recalloc has joined #zig
blueberrypie has quit [Quit: leaving]
blueberrypie has joined #zig
Anzh has quit [Ping timeout: 268 seconds]
TheLemonMan has joined #zig
<TheLemonMan> can anyone replicate the CI error in #8705? on my system ld manages to correctly bind the symbol, no idea about what's so special about Azure's environment
<mikdusan> booting up a vm...
<mikdusan> also do a cat/proc/meminfo - never know how close we are with OOM on ci
<TheLemonMan> there's no i386 libc?
<mikdusan> some distros don't have it
<mikdusan> and some as optional pkg
<TheLemonMan> I wonder how it's even running the i386 tests...
<mikdusan> do i386 tests use system libc? or syscall 32-bit ?
gpanders has quit [Quit: ZNC -]
gpanders has joined #zig
<TheLemonMan> this is i386-linux-gnu, it's using the system libc in theory
<TheLemonMan> I'm now afraid it's using the x86_64
<mikdusan> hahaha i checked out your master branch. llvm 7!
<TheLemonMan> hah, I'm a looong time contributor
<mikdusan> btw this command: `zig build-exe hello.zig -lc -target i386-linux-gnu` produces:
<mikdusan> hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/, for GNU/Linux 2.0.0, with debug_info, not stripped
motersen_ has joined #zig
<mikdusan> and since I don't have /lib/ on archlinux I can't `ldd hello` or anything
motersen has quit [Ping timeout: 240 seconds]
<mikdusan> running that test
<TheLemonMan> add LD_DEBUG=all before the test invocation (not the test harness), that'll tell you more about the symbol binding phase
<mikdusan> I got a failure. hope it's related
<mikdusan> ugh what's markdown to create a collapsed code block
<TheLemonMan> <details> iirc
<mikdusan> thx
<TheLemonMan> FileNotFound? wat
<mikdusan> trying to make sense of this thing...
<TheLemonMan> the FileNotFound errors are brutal, you're forced to strace the compiler to understand _which_ file is missing
<mikdusan> we really really gotta do something about this unrelated error crap
<TheLemonMan> pushed another commit, let's see if installing the right libc fixes the problem
<mikdusan> sanity check: success with `zig test lib/std/std.zig -lc -target x86_64-linux-gnu`
<mikdusan> oh wait i think it's this error; here's what happen when I run the test.exe (renamed it to yeehaw):
<mikdusan> zsh: no such file or directory: lib/std/zig-cache/o/a1017f51bdde1b46a77d9b9ce337bcfe/yeehaw
<mikdusan> shouldn't builder be shunting this through qemu ?
pretty_dumm_guy has joined #zig
<mikdusan> oh never mind.
<TheLemonMan> i386 is native for x86_64
<mikdusan> i see. I think this means I am not duplicating the issue
tjammer has joined #zig
<mikdusan> ok I see what's happening;
<mikdusan> the 2 i386 test targets existing before your branch were abi=none and abi=musl
<mikdusan> when `-target ARCH-linux-musl -lc` is used, it's still a static exe
<mikdusan> and I think your branch enables this to produce something now where it didn't before: `-target i386-linux-gnu -lc` and it produces a dynamic exe
<mikdusan> and while we can run a static i386, running a dynamic i386 on x86_64 linux is problematic
<mikdusan> the reason why I don't get that GLIBC error is because archlinux doesn't even provide /lib/ (the 32-bit ldso)
<mikdusan> different 64-bit linux distro. different results.
<mikdusan> ... deleting my comment in your PR. it's pure noise to the real issue
tjammer has quit [Quit: terminated!]
SimonNa has quit [Ping timeout: 246 seconds]
SimonNa has joined #zig
<TheLemonMan> don't you just need to install lib32-glibc to get the whole 32bit package?
tefter has joined #zig
tefter__ has joined #zig
tefter_ has quit [Ping timeout: 252 seconds]
tefter has quit [Remote host closed the connection]
klltkr has joined #zig
klltkr has quit [Ping timeout: 252 seconds]
klltkr has joined #zig
klltkr has quit [Ping timeout: 252 seconds]
klltkr_ has joined #zig
zenkuro has joined #zig
klltkr_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pretty_dumm_guy has quit [Quit: WeeChat 3.2-dev]
tefter__ has quit [Quit: WeeChat 3.1]
tefter has joined #zig
LewisGaul has joined #zig
<LewisGaul> Hey all, I've just been having problems getting set up with llvm-12 for building zig master branch, and realised I think it's the same problem I had with llvm-11. I solved it thanks to Andrew's answer on this issue from 2017: - (on Ubuntu) I needed to install `liblld-12` and `liblld-12-dev` packages which
<LewisGaul> aren't listed on
klltkr has joined #zig
<LewisGaul> Wondering if it would make sense for me to add something to the zig wiki (e.g. on a troubleshooting page) since just says "Use the system package manager" is an option, what do people think?
klltkr has quit [Client Quit]
knebulae has joined #zig
dreda has joined #zig
xackus__ has joined #zig
LewisGaul has quit [Quit: Connection closed]
wootehfoot has joined #zig
LewisGaul has joined #zig
<mikdusan> eghads. dragonflybsd poll is broken yaay.
<mikdusan> do we have an abstracted select/poll/epoll/kqueue event thing for zig std?
<TheLemonMan> broken?
<TheLemonMan> there's always select if you don't need that many fds
<mikdusan> yeah the code you wrote for child_process.collectOutputPosix() exposes it
<mikdusan> works for linux, openbsd, netbsd, freebsd but not dragonfly.
<mikdusan> so I reduced it and rewrote it in .c and sure enough same thing
<mikdusan> here's the reproduction.c: (one sec. pasting)
<mikdusan> on anything but dragonfly, main.c this works cleanly and quickly
<TheLemonMan> what happens when it's run on dragonfly?
<mikdusan> gets POLLIN event on one or both stdout/stderr in a loop, and read always returns 0 bytes
<mikdusan> well read succeeds, but then keeps getting PILLIN anyways afterwards
<mikdusan> and there is no delivery of POLLHUP
<mikdusan> udpated gist to show sample outputs
klltkr has joined #zig
<mikdusan> dragonfly 5.8.3 and 6.0.0 both manifest; I'm about to try 5.0.0 for shits and giggles
<TheLemonMan> ah that's extra weird, have you tried asking in their irc channel / ML
<mikdusan> oh ignore the double "pipes" print. I put that after fork(). duh.
<mikdusan> not yet. I just got the .c working
kenran has joined #zig
<mikdusan> macos joins the group that main.c works fine
<mikdusan> and linux too
<mikdusan> oh 5.0.0 bad too
antaoiseach has joined #zig
<antaoiseach> Hello folks, I was experimenting with hashmaps a bit and wanted to simulate a globally shared static map, and I managed to get it working, but I have some questions (as comments in the code itself). Could someone please have a look, and 1). Have a look at the questions, if they make sense, etc.?, and 2). Give suggestions to better design this idiomatic Zig?
<antaoiseach> Here is the link to the file (around 50 SLOC)
<antaoiseach> Thanks!
<antaoiseach> Also, I don't like the way I have `catch unreachable` inside the map creation - any way to get rid of it? I get compile errors if I remove them - I would indeed want it to fail if the map insert fails for some reason!
<g-w1> make the function return an error union to remove catch unreachable
<mikdusan> TheLemonMan: technically I can change the code to respond when `read()` == 0, which indicates file has been closed. that works on dragonfly.
<mikdusan> but is it right thing to do?
<antaoiseach> g-w1: Hmmm, I had thought of that, and wondered if I should make the "constructor" return an error union, but yes, that does work indeed.
<g-w1> its fine to do that
<antaoiseach> g-w1: Okay, cool! :-) ... yes, I think it makes sense - if the object creation fails, might as well exit immediately. Thank you!
<g-w1> you might want an errdefer kws.deinit(); after you init it so that if any of the keys fail, you deinit the map to not cause a memory leak
<TheLemonMan> mikdusan, that's perhaps a good way of detecting the eof condition... but I fear this is more a bug on the kernel's end
<mikdusan> yeah more I think about it the bug is simply: why isn't kernel sending POLLHUP
<mikdusan> _even_ if I subscribe to that event, I don't get it. and this will blow your mind:
<mikdusan> if I subscribe to POLLOUT then it loops a lot more but eventually gets POLLHUP !
<mikdusan> makes no sense
antaoiseach has quit [Quit: leaving]
<TheLemonMan> try adding a sleep() call in the child process, there may be a race condition between the poll and the close() calls in there
<mikdusan> I think what I'll do after some precursor commits for crt0 stuff is open a zig issue to track dragonfly issue, and put the workaround for read() == 0 conditional on dragonfly
<mikdusan> tried the sleep. didn't help
<mikdusan> ... and mark that workaround with reference to zig issue
<TheLemonMan> we're hitting a lot of bugs in a lot of sw, that's nice
<mikdusan> ugh. now I have to rebase some general *bsd stuff
<mikdusan> challenge: get all 4 bsds passing tests
<mikdusan> before upcoming release
<mikdusan> (openbsd is done)
<TheLemonMan> bonus points for each system added to the CI heh
<mikdusan> pending a PR that I have
<TheLemonMan> NetBSD was relatively ok last time I checked
<mikdusan> I forget what was stopping a full pass now but I'll hit it again soon enough
<mikdusan> it's harder right now. because the VM size I used to be able to get away with 6 GB building zig and ci
<mikdusan> so having 4 or 5 vms to flip between, compare things, made it a lot easier.
<mikdusan> now I can max 2 vm if not running a bunch of stuff on my desktop
<mikdusan> zig stage1 leak go brrrrrrrr
<TheLemonMan> lucky you, I have to log out and drop to tty to compile stage1
<mikdusan> that... that.... sucks
<mikdusan> laptop?
<TheLemonMan> yeah
<g-w1> i used to have to do that too :(
<TheLemonMan> pretty old, 8y and counting, so I'm a bit torn on upgrading it
<TheLemonMan> and don't get me started on LLVM, every git pull forces a nearly-full rebuild taking ~50m
<mikdusan> wait. 8y laptop, don't tell me it's a spinning disk?
<mikdusan> can't build anything without SSD these days
<TheLemonMan> yessir
<mikdusan> dragonfly is funny. It has a hammer2 filesystem which by default dedupes. So it is by-far the most compact for space use. I set it up for 40GB and it's around 6.5 GB used. other bsds and linux ~15 GB average
<mikdusan> dedupe has a slight perf cost though but I think worth it for dev stuff. wouldn't enable dedupe on a production system though.
<mikdusan> take the plunge. find a 32GB laptop with 1TB SSD. your life will be changed forever.
cole-h has joined #zig
tefter has quit [Quit: WeeChat 3.1]
tefter has joined #zig
[wtf] has joined #zig
Akuli has joined #zig
recalloc has quit [Remote host closed the connection]
sord937 has joined #zig
tefter has quit [Quit: WeeChat 3.1]
klltkr has quit [Ping timeout: 240 seconds]
tefter has joined #zig
[wtf] has quit [Quit: [wtf]]
waleee-cl has joined #zig
klltkr has joined #zig
notzmv has quit [Ping timeout: 240 seconds]
cole-h has quit [Ping timeout: 240 seconds]
koakuma has joined #zig
<semarie> hum. I am seeing that zig-bootstrap version switched from 0.8.0-dev.1939+5a3ea9bec to 0.8.0-dev.1813+88d40fc00 3 days ago. is it expected that the "number of commits" field decreased ? or do I miss something ?
notzmv has joined #zig
<andrewrk> semarie, if I did a re-sync now it would get bumped to 0.8.0-dev.2168+2d1196773. not sure where jakub got that version number from. it's fine though; really only the git tags of that repository are important. I can sync master branch for you upon request
<andrewrk> TheLemonMan, ZSF will purchase you hardware, just let me know what you want and your address in a private message :)
<koakuma> TheLemonMan, I just noticed something with the SPARC syscall6 code
<koakuma> I don't see anything fishy in the IR generated by Zig, so looks like this is another LLVM issue?
<koakuma> When compiled with -OReleaseSafe, it does a load to %o5 before it starts to move other values to its proper place so the original %o5/arg5 is lost
<semarie> if the number decrease enough semver test will fail :) -
<andrewrk> semarie, I'll do a sync now since I want to try jakub's new x86_64-macho improvements too :)
bitmapper has quit [Quit: Connection closed for inactivity]
Bernstein has joined #zig
mikdusan has quit [Quit: WeeChat 3.0.1]
Anzh has joined #zig
LewisGaul has quit [Ping timeout: 240 seconds]
pretty_dumm_guy has joined #zig
<TheLemonMan> andrewrk, is a Ferrari considered as hardware? :P
<TheLemonMan> koakuma, damn, is that happening with the other LLVM patch applied?
<andrewrk> TheLemonMan, sure, but will have to cap the hardware cost at um let's say 4000 USD. think you can find a used one for that amount? :P
<TheLemonMan> I can probably buy a rearview mirror or two heh
<noam> Can you program the mirror in zig?
mikdusan has joined #zig
<noam> I'm not sure stage1 supports the fermion target yet
sord937 has quit [Quit: sord937]
klltkr has quit [Ping timeout: 240 seconds]
notzmv has quit [Ping timeout: 260 seconds]
Dharco has joined #zig
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
pretty_dumm_guy has quit [Ping timeout: 240 seconds]
pretty_dumm_guy has joined #zig
pretty_dumm_guy has quit [Client Quit]
klltkr has joined #zig
klltkr has quit [Ping timeout: 260 seconds]
klltkr has joined #zig
klltkr has quit [Ping timeout: 268 seconds]
klltkr_ has joined #zig
klltkr_ has quit [Ping timeout: 268 seconds]
klltkr has joined #zig
klltkr has quit [Read error: Connection reset by peer]
notzmv has joined #zig
klltkr has joined #zig
Dharco has left #zig [#zig]
Dharco has joined #zig
klltkr has quit [Ping timeout: 260 seconds]
klltkr has joined #zig
wootehfoot has quit [Quit: Leaving]
klltkr has quit [Client Quit]
kenran has quit [Remote host closed the connection]
cr1901_modern has joined #zig
ur5us has joined #zig
<koakuma> TheLemonMan, D101694? Yeah it happens with it applied too. Correctly generated an ldx, but it places it in the wrong place, ahah
klltkr has joined #zig
Akuli has quit [Quit: Leaving]
<mikdusan> Dell xps 17 w/ 64GB, 2TB, UHD isplay, Windows Pro. $3650. but does it run linux well?
cole-h has joined #zig
haliucinas has quit [Remote host closed the connection]
haliucinas has joined #zig
<noam> ... that's like 32x as expensive as my laptop XD
<mikdusan> TheLemonMan, I did a few quick tests on netbsd; don't have time to address these right now but thought I'd share how far it gets:
<mikdusan> - netbsd91-amd64:
<mikdusan> - lib/std/std.zig fails with missing os.SOL_SOCKET stuff
<mikdusan> - standalone/shared_library fails:
<mikdusan> ¦ - can't find the .so, but using system linker with same args passed to ld.lld works
<mikdusan> ¦ - also `ldd test.exe` errors with `invalid ELF class 2; expected 1`
<mikdusan> the ELF class thing I'm guessing because netbsd is glacial and uses old everything