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/
iceball has joined #zig
dongcarl has quit [Quit: Ping timeout (120 seconds)]
bsrd has quit [Read error: Connection reset by peer]
dongcarl has joined #zig
leah2 has quit [Read error: Connection reset by peer]
ur5us has quit [Ping timeout: 245 seconds]
tefter has quit [Quit: WeeChat 3.1]
gracefu_ has quit [Ping timeout: 252 seconds]
gracefu_ has joined #zig
ur5us has joined #zig
haliucinas has quit [Ping timeout: 268 seconds]
haliucinas has joined #zig
arkurious has quit [Quit: Leaving]
koakuma has quit [Read error: Connection reset by peer]
ur5us has quit [Ping timeout: 245 seconds]
notzmv- is now known as notzmv
recalloc has joined #zig
<recalloc> Hi, is there a really quick way to determine if the object I have is a string, i.e. it errors on .format() unless I specify explicitly {s} vs {*} instead of {}?
<recalloc> It looks like the only option I have is following through fmt.format() and following each type to see if it gives the "must use {s} or {*}" error.
ur5us has joined #zig
<daurnimator> recalloc: what *is* a "string"? zig sadly does not define at the type level
<recalloc> all right, fair enough
<recalloc> Preventing XY problem, I'm writing an SVG constructor that makes statements like `outStream.emitRect(10, 20, 30, 40, .{ .stroke = "salmon" })` roughly equal to `underlyingWriteStream.print("<rect x={} y={} w={} h={} stroke="{}"/>", .{10, 20, 30, 40, "salmon"})`. I'm expecting all field types from the given ad-hoc struct to be either a number (decimal or floating point), or a "string", whatever a "string" is.
<recalloc> I currently have it so that anything array-"ish" with a u8 child type is assumed to be a printable string, and so is formatted with `{s}`. I don't think this is perfectly sane, though, since it goes through each way a type could be array-"ish".
<daurnimator> recalloc: zig used to do something similar itself: if the slice/array was of u8, then assume string; otherwise print as an array. but we ended up taking that away as it was too much of a special case
<recalloc> haha, figured not having a {} default was there for a reason
ur5us_ has joined #zig
ur5us has quit [Ping timeout: 250 seconds]
_aaron_ has joined #zig
<_aaron_> hi folks, i'm using the public 0.8.0-dev.2274 release, I just want to check re: "warning(compilation): -femit-h is not available in the stage1 backend; no .h file will be produced" that this is something forthcoming or could i be possibly doing something wrong? (just enabled emit_h flag on lib build)
<daurnimator> _aaron_: it broke after the 0.6.0 release; instead of fixing it we removed it for now and will rewrite in future
<_aaron_> ok, thanks for the update i thought i saw something about that in issues 👍
zenkuro has quit [Ping timeout: 240 seconds]
zenkuro has joined #zig
earnestly has quit [Ping timeout: 245 seconds]
_aaron_ has quit [Quit: Leaving]
cCCCCcccccCCc has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
cr1901_modern has quit [Ping timeout: 245 seconds]
zenkuro has quit [Ping timeout: 252 seconds]
sord937 has joined #zig
plumm has quit [Quit: Textual IRC Client: www.textualapp.com]
ur5us_ has quit [Ping timeout: 252 seconds]
sord937 has quit [Remote host closed the connection]
sord937 has joined #zig
cole-h has quit [Ping timeout: 240 seconds]
novakane has joined #zig
leah2 has joined #zig
recalloc has quit [Ping timeout: 240 seconds]
recalloc has joined #zig
recalloc has quit [Ping timeout: 240 seconds]
recalloc has joined #zig
jokoon has joined #zig
Bernstein has joined #zig
recalloc has quit [Ping timeout: 245 seconds]
recalloc has joined #zig
ur5us_ has joined #zig
earnestly has joined #zig
recalloc has quit [Ping timeout: 252 seconds]
tefter has joined #zig
jokoon has quit [Quit: Leaving]
recalloc has joined #zig
recalloc has quit [Ping timeout: 268 seconds]
ur5us__ has joined #zig
ur5us_ has quit [Ping timeout: 245 seconds]
recalloc has joined #zig
ptrchak has joined #zig
ur5us__ has quit [Ping timeout: 260 seconds]
knebulae has joined #zig
<ptrchak> hello! zig newb here with a quick question: why is the .wasm output of `zig build-lib example.zig -target wasm32-freestanding -O ReleaseSmall` so large (50KiB and it seems that it exports a bunch of math functions) when example.zig contains just one function that adds two i32s together? is it possible to shrink it somehow?
<ifreund> ptrchak: this is a known issue, but nobodies done the work to fix it yet: https://github.com/ziglang/zig/issues/7133
cr1901_modern has joined #zig
<ptrchak> ifreund: thanks for the reply! thankfully filesize doesn't matter much for my use case, but it's still nice to know i'm not messing something up.
leon-p has joined #zig
[wtf] has joined #zig
Stephanie is now known as Stephie
[wtf] has quit [Quit: [wtf]]
[wtf] has joined #zig
arkurious has joined #zig
Kingreil has joined #zig
koakuma has joined #zig
zenkuro has joined #zig
recalloc has quit [Ping timeout: 245 seconds]
recalloc has joined #zig
waleee-cl has joined #zig
zenkuro has quit [Ping timeout: 265 seconds]
zenkuro has joined #zig
a_chou has joined #zig
[wtf] has quit [Quit: [wtf]]
a_chou has quit [Ping timeout: 250 seconds]
a_chou has joined #zig
hiljusti has joined #zig
hiljusti has quit [Ping timeout: 245 seconds]
Akuli has joined #zig
zenkuro has quit [Ping timeout: 252 seconds]
tefter has quit [Quit: WeeChat 3.1]
xackus_ has quit [Read error: Connection reset by peer]
xackus__ has joined #zig
gpanders has quit [Quit: ZNC - https://znc.in]
gpanders has joined #zig
gpanders has quit [Client Quit]
gpanders has joined #zig
dyeplexer has joined #zig
gpanders has quit [Client Quit]
TheLemonMan has joined #zig
_aaron_ has joined #zig
<mikdusan> andrewrk: ping
<mikdusan> andrewrk: just fyi, bumping qemu on ci. PR is all green. it's for the msghdr zero-init patch applied to qemu-static
cole-h has joined #zig
gpanders has joined #zig
qbit has quit [Quit: WeeChat 3.1]
xackus_ has joined #zig
xackus__ has quit [Ping timeout: 265 seconds]
justin_smith has joined #zig
xackus__ has joined #zig
a_chou has quit [Quit: a_chou]
xackus_ has quit [Ping timeout: 240 seconds]
xackus__ has quit [Read error: Connection reset by peer]
xackus_ has joined #zig
<Nypsie> andrewrk: I managed to implement structs in the wasm backend. However, when testing incremental compilation I noticed that for structs `freeDecl` is called, but not `allocateDeclIndexes` and `updateDecl`. Was wondering if you were aware of this. Now we're trying to free a decl that was never initialized in the backend :)
<ifreund> Nypsie: are you working off the full file astgen branch? if not that code has almost certainly changed significantly there
<Nypsie> ifreund: No, master. Hence my question if he's aware of it not. Don't want to make an issue if it's known and fixed in the astgen branch.
<mikdusan> oh archlinux has taken the gcc11 plunge
plumm has joined #zig
xackus has joined #zig
<ifreund> I wonder what joy that will bring :D
xackus_ has quit [Ping timeout: 265 seconds]
zenkuro has joined #zig
<mikdusan> OOM frequent flyer miles?
pretty_dumm_guy has joined #zig
pretty_dumm_guy has quit [Client Quit]
pretty_dumm_guy has joined #zig
<andrewrk> hi mikdusan
<ifreund> andrewrk: hey, not sure if you've seen this issue yet, but I'd be happy to try and fix it if you agree with my conclusions: https://github.com/ziglang/zig-bootstrap/issues/57
_aaron_ has quit [Quit: Leaving]
<andrewrk> ifreund, yep sounds right
sm2n_ has joined #zig
<ifreund> cool, I'll give it a go
sm2n has quit [Ping timeout: 240 seconds]
<andrewrk> Nypsie, the lifetime of structs and decls is significantly reworked in #8554
<Nypsie> Gotcha, just making sure :) Thanks
<andrewrk> can you share your example code? I'll make sure with another backend that the allocate/update/free calls match up
<Nypsie> Sure 1 sec
* ikskuh feels bad for not patching up the build.zig PR
<ikskuh> i should do that soon :(
<Nypsie> https://zigbin.io/3bc298 Here you go. Above example is initial version, below example is updated version with incremental compilation.
<Nypsie> I'll just finish the implementation, get wasi working and then rebase it on top of #8554 when that hits master
sm2n has joined #zig
sm2n_ has quit [Read error: Connection reset by peer]
sm2n has quit [Ping timeout: 260 seconds]
<andrewrk> Nypsie, looks like the same problem exists in 8554: https://clbin.com/tS3ia
<andrewrk> thanks for pointing this out
<Nypsie> You're welcome. Glad we found it, I may have lost some hair in the proces when wondering what was going on in my code hehe
sm2n has joined #zig
gpanders has quit [Quit: ZNC - https://znc.in]
gpanders has joined #zig
sm2n has quit [Excess Flood]
sm2n has joined #zig
gpanders has quit [Client Quit]
gpanders has joined #zig
dyeplexer has quit [Remote host closed the connection]
<fengb> What hair
<andrewrk> wow, low blow
sm2n has quit [Read error: Connection reset by peer]
sm2n has joined #zig
<andrewrk> so I think the expected behavior would be to get allocateDeclIndexes (side note: this should probably be renamed to allocateDecl) in the first update, and then updateDecl in the second update
gpanders has quit [Client Quit]
<andrewrk> or, also valid: allocateDecl and updateDecl in the first update, freeDecl and then another set of allocateDecl and updateDecl in the second one
gpanders has joined #zig
<andrewrk> I think in this case the frontend is going to want to destroy the old struct and make a new one
<Nypsie> Will it be called on the top level declaration? Right now, freeDecl seems to be called on an anonymous one (the struct created on the stack I presume)
<Nypsie> Oh it does also call it on the top level declaration when it has no more references
gpanders has quit [Client Quit]
sm2n has quit [Ping timeout: 260 seconds]
gpanders has joined #zig
gpanders has quit [Client Quit]
gpanders has joined #zig
<andrewrk> err wait a minute, I think none of these functions are supposed to be called, because hasCodeGenBits() is false for types
<andrewrk> I think I kinda need to try implementing it in a backend in order to figure out how it should work in the frontend for this situation
<andrewrk> can you share some insight on what makes sense from the perspective of the wasm backend?
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<mikdusan> should a good citizen be using hash_map.count() or hash_map.size ?
ptrchak has quit [Quit: WeeChat 3.1]
notzmv has quit [Ping timeout: 240 seconds]
klltkr has joined #zig
<andrewrk> if your codebase makes use of both kinds of hash maps, or makes use of managed/unmanaged variants, probably count() will be less churn. otherwise size is nice because it is not a function call
<ifreund> damn, I gave the llvm build too many cores and soft locked my computer for 10 minutes untill the OOM killer did its job
<ifreund> I wonder how many cores is safe with 16 gigs of ram
<Nypsie> andrewrk: Sorry had to make a call. I'm not sure either tbh. Right now, structs are kind of treated as a local variable for each struct field (for wasm). It doesn't require allocDecl/updateDecl to work. However, that may change once default values for struct fields are implemented, as I expect those values need to be codegen'd too (for example an array).
<andrewrk> ifreund, I recommend -GNinja -DLLVM_PARALLEL_LINK_JOBS=1
<Nypsie> (or perhaps the default value just generates a .store and .struct_field_ptr instructions)
<andrewrk> Nypsie, default values for struct fields is actually implemented already in my branch, and the good news is there are no code chances needed in the backend codegen code :)
<ifreund> andrewrk: do we have a nice way to make zig-bootstrap use those? I didn't see one
<Nypsie> Oh wow haha, that's wonderful
<andrewrk> ifreund, ah I see
<andrewrk> no, I wanted to keep the system dependencies to a minimum, and -GNinja seemed like more of one than make
<Nypsie> But that makes me wonder if it was just never supposed to call `freeDecl` at all
<andrewrk> yeah maybe that's actually the issue
<andrewrk> it's probably missing a check to hasCodeGenBits()
<Nypsie> Ah, that makes sense
<andrewrk> yep it is, found it
<Nypsie> Great! Beat that yak, you don't need to be shaved
<andrewrk> haha
klltkr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
motiejus has left #zig ["User left"]
<ikskuh> andrewrk: quick idea: replace LibExeObjStep.libc_file with an optional structure instead?
<ikskuh> .libc = std.build.LibC { .include_dir = "/usr/include" };
<kiedtl> will terser syntax for 'catch unreachable' be added in the future? (or is there already in master? I didn't see any in 0.7.1)
<ikskuh> no, as it is generally considered bad practise and should also have a doc comment why the error can never be reached
<g-w1> i think it is like that for a reason: to discourage you from doing it ;)
<g-w1> like this: `const b = a catch unreachable; // the flag must be set`
<kiedtl> I get why that'd be a good thing in libraries, but for other things where you don't care about cases where appending to an array could generate a OOM error it gets tedious quickly
<ikskuh> even then, "catch @panic("oom")" is the right thing
<g-w1> yea, you don't want ub
<ikskuh> "catch unreachable" will happily continue to execute code after the error in non-safe build modes
<andrewrk> the syntax for catch unreachable is `.!` but zig purposefully doesn't have it :)
<kiedtl> lol
<kiedtl> ikskuh: huh, I didn't realize that, thanks for pointing it out
<ikskuh> kiedtl: unreachable is literally a "this code cannot be reached, optimize for it!"
<ikskuh> "catch unreachable" will pretty much remove any error-related branches in your code
<kiedtl> I knew that, but didn't realize it could just continue onwards :v
<Raito_Bezarius> I'm reading https://github.com/AndreaOrru/zen/blob/master/kernel/ipc.zig#L13 and it seems like there is some definition of MailboxId in the Zig standard library? I guess it was deleted recently as there was some will to not hardcode hobby OS in Zig standard library, so where might this code be now?
<g-w1> zen stuff got removed from std, ill try to look for the commit
<Raito_Bezarius> I quickly looked on the ziglang/zig repo but without any luck
<g-w1> dcbd5ad1553c5994353de47babc0e07e02153bd8
<g-w1> git log | less; /zen
<Raito_Bezarius> nice, I need to increase the git-fu level
<g-w1> hmm, that doesn't remove os/zen.zig tho
<Raito_Bezarius> I'm on 4d747d452fba0987332244c777dfd3a29d5a20bd
<g-w1> found it https://clbin.com/2EwNz
<ikskuh> wow that code is 3 years old :O
<andrewrk> yeah generally I'm happy to have non-mainstream stuff upstreamed as long as it is active
<Raito_Bezarius> am I right to think I can implement something like std.os.zen in my own code without having to modify Zig, andrewrk ?
amk has quit [Ping timeout: 240 seconds]
<andrewrk> yes; the thing that got deleted was std lib support for a hobby OS
amk has joined #zig
<g-w1> pub const os = thing iirc
<Raito_Bezarius> alright
<andrewrk> we have this concept of Bring Your Own Operating System to allow third party projects to enable std lib support for any OS. however it needs some attention to be useful
<Raito_Bezarius> and how does Zig std finds out the real implementation of POSIX syscall it might need for some stuff?
<g-w1> wdym?
<andrewrk> Raito_Bezarius, it has explicit logic that checks the target and decides what to do
<Raito_Bezarius> as in, my operating system uses SYSENTER/SYSRET to do syscalls, I have a file which explains how to perform those syscalls
<Raito_Bezarius> I want to explain to Zig std that those are the syscalls it needs to use
<Raito_Bezarius> so by writing something like lib/myos.zig like zen.zig and using it everywhere in my userspace code, it should just work™ also in build.zig I need to use lib.os.myos as target I assume
<g-w1> see, os.zig os/linux.zig for example, and os/bits.zig
<Raito_Bezarius> thanks!
<g-w1> then for example std.fs uses std.os which abstracts the target
<g-w1> but its all a little posixy
<Raito_Bezarius> I'm okay with being POSIXy
<Raito_Bezarius> I want to be POSIX in fact
<Raito_Bezarius> :D
<ikskuh> i killed the stdlib
<ikskuh> <xq> __SIZEOF_PTHREAD_MUTEX_T is ded when compiling with .android abi :D
<ikskuh> <xq> oh wait
<ikskuh> <xq> hm. why does zig link pthread, rt and util?
<ikskuh> <xq> nope, looks like it's not my fault
<ikskuh> <xq> libutil and librt come from glibc, but i'm not using the system libc (explicit libc file)
<ikskuh> hm, this linking error didn't happen at FOSDEM time
<ikskuh> what did change since then regarding libc linking?
<g-w1> i dont know anything about your usecase, but recently zig started using system libc files by default (i think); see discussion from yesterday
<ifreund> only if targeting the native os/abi, which is not the case if targeting the android abi
<ikskuh> yeah, it breaks with .gnu abi for "aarch64-linux-gnu"
<ikskuh> as well
<ikskuh> (using an explicit CrossTarget)
<ifreund> ikskuh: ah, you are passing --libc though?
<ikskuh> yeah
<ikskuh> i have to :D
<ifreund> zig will still try to link all libc libc it knows about, since our builtin.link_libc is just a bool
<ifreund> *all the libc libs
<ikskuh> erm
<ikskuh> that is wrong :D
<ikskuh> there is no pthread on android
<ikskuh> no rt and no util
<ifreund> ikskuh: sounds like the fix is as simple as adding android to that switch then :)
<ikskuh> and building llvm12 myself :(
riba has joined #zig
<ifreund> nah, just use nix
<ifreund> or grab from the arch staging repo
<g-w1> it wasn't that bad when nixpkgs built it for me /shrug
<ifreund> or I can send you a static zig tomorrow with that change and you can test that
<ikskuh> hm
<ikskuh> or i can hack a workaround *screams*
<ikskuh> addDynamicLibrary("pthread", "empty.zig", .unversioned)
<ifreund> please lets get this fixed even if you have a workaround for now
<ikskuh> yeah, i agree!
<ikskuh> but i want to figure out everyting before starting a patch series of 50 single-line PRs
<ifreund> 50 single line PRs fixing simple problems are way easier to review than one massive one
<ifreund> if you want to get a llvm12 binary from nix, I have a shell.nix here you can use: https://github.com/ifreund/dotfiles/blob/trunk/local/nix/zig.nix
sord937 has quit [Quit: sord937]
<Raito_Bezarius> I guess IntrusiveLinkedList were removed from zig?
<Raito_Bezarius> git log | less trick shows only when they were added to the index.zig :>
<ifreund> indeed
<ikskuh> nix is installing
novakane has quit [Quit: WeeChat 3.1]
<g-w1> ❯ ./zig build test-stage2 -Denable-qemu
<g-w1> All 41 tests passed.
<g-w1> \o/
notzmv has joined #zig
tefter has joined #zig
Bernstein has quit [Remote host closed the connection]
<mikdusan> score. archlinux w/ gcc 11.1 and rebuilt llvm12, and zig master. passes `zig build test`
<mikdusan> (llvm12 non-distro build that is)
ur5us__ has joined #zig
riba has quit [Ping timeout: 265 seconds]
Akuli has quit [Quit: Leaving]
CodeSpelunker has joined #zig
tefter has quit [Ping timeout: 252 seconds]
gpanders has quit [Changing host]
gpanders has joined #zig
<ikskuh> ifreund: i didn't do any weird hacks, i hope i find some time tomorrow for getting a proper LLVM12 build of zig
mikdusan has quit [Quit: WeeChat 3.0.1]
pretty_dumm_guy has quit [Quit: WeeChat 3.2-dev]
sm2n has joined #zig
CodeSpelunker has quit [Quit: CodeSpelunker]
<Raito_Bezarius> Unreachable at /build/source/src/stage1/target.cpp:288 in get_llvm_os_type. This is a bug in the Zig compiler.thread 2210718 panic:
<Raito_Bezarius> I tried to use .os_tag = .other in my build.zig
<Raito_Bezarius> and something with a .abi = .musl
<Raito_Bezarius> maybe I misunderstood how to use this feature
<Raito_Bezarius> My objective is to generate an ELF with a "standard" POSIX ABI
<g-w1> wdym standard?
<Raito_Bezarius> standard is definitely not the right term
<Raito_Bezarius> I just want minimalist assumptions on the target wrt to POSIX ABI
<Raito_Bezarius> for example, I do not want TLS stuff to appear, etc.
hiljusti has joined #zig
nathanael has quit [Remote host closed the connection]
nathanael has joined #zig
<Raito_Bezarius> okay, I think I got it
<Raito_Bezarius> I need to override os.system at the root of my file
ur5us_ has joined #zig
ur5us__ has quit [Ping timeout: 250 seconds]