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/
daurnimator has quit [Ping timeout: 272 seconds]
frmdstryr has joined #zig
daurnimator has joined #zig
<pixelherodev> QEMU 2 is *ancient*, yeah
<frmdstryr> When using a package in build.zig, zig appends ".package" to the name. This make gdb give a syntax error when I try to use `p .mypkg.some.var`, how do I print a value from a package with gdb?
<pixelherodev> I don't think that's a build.zig thing
<pixelherodev> I think it's Zig's internal naming - if you have `const a = @import("something.zig")` in your root file, and a contains a global `b`, then it'll be named `.a.b`
<pixelherodev> I could be entirely wrong, I've not had the best experience with it so far either
<frmdstryr> Hmm, ok, I wonder if there's any issues on this
frmdstryr has quit [Ping timeout: 240 seconds]
<keegans> experienced what I believe is a bug, but am not sure how to track down if it has been reported yet. for a statement that can return a set of errors, say X Y Z, if you explicitly handle X and also have a `else => return err;`, X is still in the set of errors that can escape out of that function
<keegans> (when in reality since Y and Z cases resolve to a return err, only Y and Z can actually be returned from the function)
<keegans> hmm seems `else` entirely breaks ErrorSet anyway :(
<keegans> so this behaviour is just a result of that
daex has quit [Ping timeout: 256 seconds]
jabb has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
<pixelherodev> keegans: it isn't a bug, I don't think
<pixelherodev> Never mind, looked at godbolt
<pixelherodev> That does look off
doesntgolf has quit [Ping timeout: 256 seconds]
<jabb> o/
jabb is now known as gruebite
craigo has joined #zig
marnix has joined #zig
nycex has quit [Remote host closed the connection]
nycex has joined #zig
marnix has quit [Ping timeout: 240 seconds]
daurnimator has quit [Ping timeout: 260 seconds]
jjido has joined #zig
jjido has quit [Client Quit]
jjido has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
keegans has quit [Quit: WeeChat 2.7]
decentpenguin has quit [Quit: ZNC crashed or something]
decentpenguin has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
dermetfan has joined #zig
frett27 has joined #zig
marnix has quit [Ping timeout: 256 seconds]
Ashpool has quit [Quit: Leaving]
craigo has quit [Ping timeout: 264 seconds]
<ifreund> o7
Sahnvour has joined #zig
KoljaKube has joined #zig
daurnimator has joined #zig
drewr has quit [Ping timeout: 244 seconds]
drewr has joined #zig
st4ll12 has joined #zig
wootehfoot has joined #zig
marnix has joined #zig
daurnimator has quit [Quit: WeeChat 2.8]
daurnimator has joined #zig
gpanders has quit [Quit: ZNC - https://znc.in]
gpanders has joined #zig
WilhelmVonWeiner has quit [Read error: Connection reset by peer]
waleee-cl has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Nypsie has joined #zig
xackus_ has joined #zig
xackus_ has quit [Client Quit]
craigo has joined #zig
xackus has joined #zig
craigo has quit [Read error: Connection reset by peer]
craigo has joined #zig
<ikskuh> hello
KoljaKube has quit [Ping timeout: 260 seconds]
marnix has quit [Read error: Connection reset by peer]
<Nypsie> Hello
<ikskuh> i wonder if the std debug panic handler should use std.log instead of writing to stdout directly…
marnix has joined #zig
dermetfan has quit [Ping timeout: 260 seconds]
cren has joined #zig
cren has quit [Quit: Swirc IRC client]
marnix has quit [Ping timeout: 265 seconds]
marnix has joined #zig
_whitelogger has joined #zig
jjido has joined #zig
marnix has quit [Ping timeout: 246 seconds]
frmdstryr has joined #zig
st4ll12 has quit [Quit: WeeChat 2.8]
frmdstryr has quit [Ping timeout: 256 seconds]
_whitelogger has joined #zig
<THFKA4> anyone else getting a cImport failure building on HEAD? https://paste.debian.net/1157849/
moo has joined #zig
<ifreund> THFKA4: looks like you need to link libc
<ifreund> either pass -lc or call linkLibC() in your build.zig
<ikskuh> ifreund: this is building stage1
<ifreund> ikskuh: oh
<ifreund> let me pull and try
wootehfoot has quit [Ping timeout: 240 seconds]
<THFKA4> i'm half suspecting the <> instead of "" on that #include
<ifreund> hmm it built fine for me on void
<ifreund> looks like you were running tests though?
<THFKA4> yeah, i noticed that's new. it wasn't running them in the past
<THFKA4> i'll try to turn them off, thanks
<THFKA4> just werkz, problem SOLVED
frmdstryr has joined #zig
Joey152 has joined #zig
<ifreund> \o/
<THFKA4> kind of makes me wonder how CI is green though
nickster has quit [Quit: The Lounge - https://thelounge.chat]
nickster has joined #zig
doesntgolf has joined #zig
Joey152 has quit [Ping timeout: 245 seconds]
marnix has joined #zig
ifreund has quit [Read error: Connection reset by peer]
ifreund has joined #zig
<pixelherodev> ... there haven't been any major PRs since I last looked. This feels weird. I'm so used to them just popping out of nowhere lol
waleee-cl has quit [Quit: Connection closed for inactivity]
knebulae has quit [Read error: Connection reset by peer]
frmdstryr has quit [Ping timeout: 260 seconds]
knebulae has joined #zig
isolier has joined #zig
<danyspin97> I have a os.sockaddr_in*, how can use @ptrCast to convert it to os.sockaddr*?
<danyspin97> found, @ptrCast(*os.sockaddr, myptr)
nikita` has joined #zig
cow-orker has joined #zig
<isolier> danyspin97: Purely out of curiosity, what are you working on?
<danyspin97> I wanted so
<danyspin97> some small project to try zig on
<isolier> Very cool
<danyspin97> thanks!
<isolier> What do you think of source hut?
<danyspin97> it's great but not yet aimed at everyone
<danyspin97> due to its mail based workflow
<danyspin97> do you have projects there?
<isolier> I see. I self host Gitlab, but it is a beast.
<danyspin97> ah, yea it is
<danyspin97> I use gitlab often because the distro I use has a selfhosted instance
<danyspin97> and sometimes it becomes slow. I have also seen that freedesktop pays a lot for its instance
<isolier> It is definitely featureful, but I think I am going to switch to source hut or gitea or something.
<isolier> Yeah, they defintely make it easy to set up your own instance, despite the amazing complexity.
<danyspin97> gitea is good, but I disklike go..
<fengb> You prefer Ruby over Go? 🤔
<danyspin97> yup
<isolier> Indeed. I just want to use though, so hopefully the implementation language doesn't matter so much.
cren has joined #zig
<danyspin97> ruby: modular packages, easy to bootstrap (afaik)
<danyspin97> go: hell to bootstrap, huge packages, bad practices until last year
<fengb> Um... Ruby best practices are... amazing
<fengb> And not sure what you mean by bootstrapping because Ruby doesn’t build itself
<danyspin97> never developed in Ruby, but I am biased packaging some software
<fengb> Oh GOPATH was shitty
<danyspin97> yea, that's why ruby it's good, you can compile it in C
<fengb> I’m glad they finally figured that out
<cren> what exactly did Go do with GOPATH?
<danyspin97> the language choosed how to deal with packages
<fengb> Every “package” in Go needed to be in GOPATH
<danyspin97> and GOPATH was used
<cren> That sounds reasonable enough
<danyspin97> the headaches trying to understand it
<danyspin97> only for local development
<fengb> It’s a global space where all packages go
<ifreund> that sounds horrible
nycex has quit [Ping timeout: 240 seconds]
<cren> That doesn't sound much different from what python does
<fengb> And there’s no way of loading a different path
<danyspin97> no, python is good for this
<ifreund> python package management is also horrible
<danyspin97> it's workable
<fengb> Python let’s you add stuff like virtualenv
<danyspin97> I actually like python package management
<cren> I like that there are a lot of packages
<danyspin97> you can install packages in /usr/lib, use local files or user installed packages
<ifreund> aye with venv it's workable
<fengb> Anyway, Go has actual modules now
<cren> I do not like that you cannot recursively remove a package and its dependencies with pip
<danyspin97> pip without --user it's bad
nycex has joined #zig
<fengb> Most package managers don’t let you exclude a transitive dependency
<cren> Is the last expression in a Zig function returned automatically?
<fengb> No
<ifreund> not anymore at least
<cren> I think that's good
<ifreund> I agree
<cren> As a Python person I don't like implicit things
<fengb> It wasn’t implicit though: return by dropping the terminating semicolon
<fengb> Not very obvious either >_>
<leeward> pip is only good in virtualenv; anywhere else use the distro's package manager
<pixelherodev> I use `pip --user` for local installs when packages aren't available in the normal repos
<pixelherodev> Which isn't often, but happens occasionally
<pixelherodev> Like, twice, ever
<pixelherodev> :P
<leeward> I have a work thing that has to run on CentOS, and the packages I need aren't in the distro so the whole thing goes in a virtualenv that gets installed to the SD card image at build time. Makes it super easy to manage dependencies and debug on the target hardware.
cren has quit [Ping timeout: 260 seconds]
<pixelherodev> I don't use venvs :P I just install to wherever `pip --user install foo bar` goes lol
<pixelherodev> Haven't had any conflicts yet :P
<leeward> "yet"
<pixelherodev> It's been two years.
<pixelherodev> I'm pretty confident that it'll be fine
<leeward> I've been using Python for...a lot longer than that.
<pixelherodev> I haven't had this laptop set up for all that long lol
<fengb> I’ve been using python before you were born 🦖
<leeward> Being able to have python 2 and 3 venvs coexist on the same server is useful.
<leeward> Also knowing that CI, prod, and dev machines have the same set of packages even when they're running distros, and being able to wipe the whole thing and reinstall without worrying about hosing your system is good.
<fengb> This is the reason Docker exists :P
<leeward> I think the first time I looked at Python was either 1999 or 2000.
<leeward> It is, but I'm not putting docker on my production system.
cole-h has joined #zig
<leeward> er, running different distros
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<pixelherodev> Relevantly, finally got mnemosyne running without WINE :)
<pixelherodev> In a glibc chroot for now, until I get around to patching PyQtWebEngine
<pixelherodev> But this is still a major improvement, since I already had most deps in the chroot anyways, and now I can wipe WINE out of it
<leeward> \o/
<leeward> No idea what mnemosyne is, but...cool
marnix has quit [Read error: Connection reset by peer]
jjido has joined #zig
decentpenguin has quit [Quit: ZNC crashed or something]
marnix has joined #zig
manikawnth has joined #zig
<leeward> looks like I found a regression in translate-c
<danyspin97> can I convert a packed struct to a []u8?
<leeward> @bitcast
<leeward> Though I think it would be a [N]u8 first.
<Nypsie> There's also std.mem.toBytes
<leeward> ^probably better
<danyspin97> I'll try it right away
<danyspin97> what about the opposite?
<danyspin97> from []u8 to a packed struct?
marnix has quit [Read error: Connection reset by peer]
KKRT has joined #zig
<scientes> @memcpy
<scientes> (that is how it should be implemented)
<leeward> std.mem.bytesAsValue gets you a pointer.
<scientes> or just @ptrCast()
<pixelherodev> slice.ptr gives [*]u8, which can be ptrCasted
<pixelherodev> std.mem is probably better, since a lot of its functions handle low-level details (like endianness) which everyone tends to overlook
frmdstryr has joined #zig
<leeward> Maybe bytesAsValue should be called fromBytes fro symmetry.
<leeward> Also for symmetry
recombinant has joined #zig
<danyspin97> hmm, this struct cannot be packed because it contains []const u8
<gruebite> Are there any ideas for what the name Zag would be used for? Package manager? :P
<pixelherodev> I used to call the standard library that
<pixelherodev> Then Andrew whacked my PR with a rolled up newspaper and I stopped :P
<ifreund> gruebite: only use case I've heard andrew mention was a name for an unstable/testing branch post 1.0
<ifreund> I have a theory that 50% of first zig projects are named zag though
<leeward> ahah, made a minimal example that shows translate-c being broken
<leeward> Now to turn it into a bug report...
<gruebite> i already have two projects named zag
<ifreund> gruebite: ahead of the curve, I like that :D
<ifreund> my main project was named zag for the first few days, before I found all the others and realized that I was not, in fact, original at all
<leeward> Er, no I haven't. That was the wrong code.
<gruebite> i haven't written much zig yet. waiting on c abi
<danyspin97> allocator.alloc(u8, 18) why does it return []u8 of size 16?
waleee-cl has joined #zig
<pixelherodev> gruebite: we have a C ABI...
<pixelherodev> Wait, is it not fully implemented or something?
<pixelherodev> That wouldn't surprise me too much
<ifreund> pixelherodev: there's some low-hanging fruit with passing structs by value and whatnot
recombinant has quit [Quit: Leaving]
<Nypsie> danyspin97: What did you expect it to return?
<danyspin97> []u8 of size 18
<pixelherodev> ifreund: gotcha
<ifreund> I haven't hit any of it in practice though, and I think I have one of the larger zig projects interfacing heavily with C
<Nypsie> My bad, for some reason I couldn't see the difference between 18 and 16 haha
<danyspin97> np xD
wootehfoot has joined #zig
<danyspin97> i have a packed struct of size 18
<danyspin97> and @bitPack complains
<Nypsie> Packed structs are still quite buggy
<danyspin97> ah, I see
<leeward> Are all the elements in your packed struct aligned to word boundaries? If not, expect problems.
<danyspin97> no idea about aligning
<ifreund> and get excited for stage2 to fix all the bugs :D
<leeward> Those bugs will get fixed once self hosted is working. They're not necessary for writing a compiler, so they got put on the shelf.
<ifreund> pixelherodev: found the tracking issue: https://github.com/ziglang/zig/issues/1481
<danyspin97> leeward: i removed "packed" declaration and left the struct. However it's alloc that does not want to work :/
<fengb> Hmm why can’t call allocator.create(Struct) ?
<danyspin97> source coming
<leeward> danyspin97: Which allocator are you using?
<danyspin97> leeward: c.heap
<danyspin97> std.heap.c_allocator
<danyspin97> afk
marnix has joined #zig
<ifreund> danyspin97: that seems strange, but I think you'd need to post code if we're to make any sense of why the allocator is returning the wrong size
Nypsie has quit [Quit: WeeChat 2.8]
<danyspin97> ifreund: code coming
<danyspin97> http://ix.io/2snr
<danyspin97> http://ix.io/2snt
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ifreund> danyspin97: which line there is the one causing issues?
<danyspin97> last one
<danyspin97> @bitPack
<danyspin97> ./src/benice.zig:42:21: error: destination type 'Rule.Rule' has size 34 but source type '[]u8' has size 16
<leeward> []u8 is the actual slice pointer type, not the length of the array.
<ifreund> ^
<ifreund> you want binary_rule.ptr
<danyspin97> and use @ptrCast?
<ifreund> yes
<leeward> I think what you actually want is std.mem.bytesAsValue
<ifreund> slices are special structs with two fields, ptr and length
<leeward> which will give you a pointer to a Rule.
<fengb> Why not allocator.create(Rule)
<ifreund> yeah and your Rule struct has to be packed or this is UB
<leeward> Oh, that too
<fengb> Your Rule would be misaligned in this case
<ifreund> the rule is on the stack in this case
<ifreund> he is trying to read from a socket into the stack variable
<fengb> Er... the *Rule could be misaligned. That’d require a memcpy to fix
<fengb> Whereas allocator.create() does the right thing for you
<leeward> Yeah, allocator.create is the way to go here.
<ifreund> I don't follow
<danyspin97> me neither :/
<danyspin97> allocator.create allocate a struct
<danyspin97> understood
<ifreund> theres no reason to heap allocate the struct, it's better to have it on the stack
<ifreund> the problem is how best to transform the raw bytes read from the socket into the struct
<danyspin97> wouldn't it be misaligned?
<gruebite> ahh, yeah. C structs by value
<gruebite> ifreund: what is your project?
<ifreund> danyspin97: as I understand it, the complier aligns all stack variables properly
<leeward> Pretty sure std.mem.bytesAsValue is the way to do that, assuming the target struct is packed.
<gruebite> awesome!
<ifreund> yes
<gruebite> i used to use dwm
<gruebite> but now i3
<danyspin97> leeward: with mem.bytesAsValue I don't even need to allocate the space for Rule struct
<danyspin97> I just get the pointer to the already allocated one but treated as *Rule
<ifreund> yes, you don't need to heap allocate the rules struct
<fengb> You can do something like `mem.asBytes(&rule)` to get a slice
<leeward> You don't even need it on the stack.
<fengb> And read the data directly into the slice
<leeward> You just turn the pointer to the array into a pointer to the struct.
<ifreund> i like fengb's way better :D
<ifreund> and afaik a packed struct should work ok in this case since all the members are byte-aligned
<fengb> They're not aligned
<fengb> Well... they're aligned in inconsistent ways. They're not supposed to be aligned
<danyspin97> asBytes compiles fine
<danyspin97> same for valueAsBytes
<ifreund> fengb: I'm sure you know more about it than I do, this is danyspin97's struct: http://ix.io/2snr
<fengb> extern struct might work the best there
<danyspin97> hmm I see
<danyspin97> I am also reading the doc for casting [N]T into []const T
<danyspin97> what about the opposite?
<fengb> Regular struct doesn't have guaranteed memory layout, and packed struct adds padding in a buggy way
<fengb> Slicing with comptime known values will give you a pointer to a fixed array: `foo[0..4]` gives you `*[4]const T`
<fengb> And you can deref that to get the actual value
<fengb> Something like `const array = foo[0..4].*`
<danyspin97> does not work with the return value of alloc.dupe
<ifreund> well, in that case the length wouldn't be comptime known
<ifreund> if you just called allocator.dupe there's no need to copy again though
<danyspin97> it would if I use dupe(u8, myarr[0..16])
<danyspin97> even better dupe(u8, myarr, 16)
<ifreund> no need for dupe then
<ifreund> const foo = myarr[0..16].*
<danyspin97> and it gets copied?
<fengb> Dupe creates a new heap allocation
<danyspin97> yea, that's the point
<danyspin97> ah, no wait
<fengb> ifreund's suggestion copies it into a stack variable
<ifreund> never heap allocate unless you have a runtime-known size
<ifreund> (or maybe if you need very large chunks of memory)
<danyspin97> I see
<danyspin97> the struct needs a compile time known size, so I picked 16
<danyspin97> but I read the value from a Json object, which can be smaller than 16
<danyspin97> and I need to copy that because I the parser will be dealloc'ed before
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
<danyspin97> resolved with @memcpy
manikawnth has quit [Remote host closed the connection]
cole-h has quit [Quit: Goodbye]
marnix has quit [Ping timeout: 256 seconds]
doesntgolf has left #zig [#zig]
dongcarl has joined #zig
<leeward> Whew, allocator interface change was fun...just caught up to that.
<leeward> Well, in the project where it matters.
<pixelherodev> Oh me, more changes
<pixelherodev> yay
<leeward> Where is marler? I have questions.
<pixelherodev> Ping in GH?
<leeward> I could probably find the answers there anyway.
frmdstryr has quit [Ping timeout: 240 seconds]
jjido has joined #zig
dermetfan has joined #zig
KKRT has quit [Quit: KKRT]
ur5us has joined #zig
<leeward> Is there any way to catch a segfault with a test to ensure that it generates one?
<fengb> https://github.com/ziglang/zig/issues/5917 something like fork + join yeah
<leeward> fengb: That's the thing. I wonder how important it is to be able to build tests in environments without fork.
<leeward> Seems like not.
<pixelherodev> Hmm, I disagree, it should be considered important
nikita` has quit [Quit: leaving]
<leeward> Why?
frett27 has quit [Ping timeout: 260 seconds]
<leeward> fengb: Amusingly, when I use that (modified to make it work) I get an error return trace printed out with my segfault, followed by "All 12 tests passed."
<fengb> Yeah I have a special thing that hides stderr
<fengb> It’s not optimal
<leeward> Yep, that's...a way to do it.
<fengb> A better way is overwrite the panic handler and understand that it's a child
<fengb> Hmm... or create a FIFO right before fork, and have the master forward that to stderr
wootehfoot has quit [Read error: Connection reset by peer]
<ronsor> keegans: thanks for the advice on updating the QEMU. it works fine with a newer version.
nycex has quit [Remote host closed the connection]
nycex has joined #zig
xackus has quit [Ping timeout: 246 seconds]
blinghound has joined #zig
<blinghound> what does the 'Avoid local maximums' part of the Zen mean in the context of programming?
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ifreund> it means that one should take the path that leads to the best outcome, even if it requires bactracking/throwing out some work to get there
<blinghound> ohh I see! A long-term oriented design rather than cobbling something 'good enough'
<ifreund> exactly
daex has joined #zig
craigo has quit [Ping timeout: 240 seconds]
Sahnvour has quit [Quit: WeeChat 2.9]
SyrupThinker has quit [Quit: ZNC - https://znc.in]
pmwhite1 has joined #zig
pmwhite1 has quit [Client Quit]
SyrupThinker has joined #zig
pmwhite1 has joined #zig
dermetfan has quit [Ping timeout: 272 seconds]
pmwhite_ has joined #zig
pmwhite1 has left #zig [#zig]
pmwhite_ has quit [Client Quit]
pmwhite_ has joined #zig
pmwhite_ has quit [Client Quit]
pmwhite_ has joined #zig
pmwhite_ has quit [Client Quit]
blinghound has quit [Remote host closed the connection]
pmwhite has joined #zig
<pixelherodev> Tests marked as `std-native-Debug-bare-multi`: what's `bare-multi` there?
* pixelherodev facepalms
<pixelherodev> The SPU II branch fails locally too, I just accidentally muted the tests
<pixelherodev> I eagerly await the day we can use stage2 to work on stage2 :P
<gpanders[m]> Hey all, when I run 'zig targets' it lists my CPU, OS, and ABI under the "native" section as "x86_64", "macosx", and "gnu", respectively (running macOS). Running 'zig build' with no target specified works just fine, but when I try 'zig build -Dtarget=x86_64-macosx-gnu' I get an error with C importing ("error: C import failed"). I'm assuming the problem is that I'm not actually specifying the correct target, but how do I
<gpanders[m]> determine what the right target is?
<gpanders[m]> (For context, I'm trying to write a build script that compiles my program for different architectures, and I'm trying to find the right way to build for macOS)
<fengb> I don’t think macOS cross compile works right now
<pixelherodev> I'm 99% sure it doesn't
<fengb> Might want to try -Dtarget=native_native
<fengb> Er... native-native
<pixelherodev> You could do something like `if (host is macos) { build with native_native } else { error that cross-compilation for macos is not supported yet }`
<gpanders[m]> fengb: yea -Dtarget=native works, but then that wouldn't translate when running the build script on a non-macOS machine, so I was trying to find a more portable solution
<gpanders[m]> I think for now I'll just cross compile for Linux in my script and manage the macOS binaries manually
<fengb> We need to port libc headers at the very least
<pixelherodev> Woot, fixed the bug :)