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]
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?
<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]
<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
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?
<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
<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