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/
dermetfan has quit [Ping timeout: 252 seconds]
<fengb> How hard is compiler_rt? Just port over the LLVM code?
<mikdusan> andrewrk: diff and basic notes for qemu static: https://gist.github.com/mikdusan/0b51f2d6a2a95ff6b9739f9eabce4fc4
<mikdusan> the diff is just a cherry pick and rebase from alpine's port of qemu (currently at 4.2.0)
hugs is now known as oats
return0e has quit [Remote host closed the connection]
return0e has joined #zig
<Kingsquee> rise again, lovecraftian crash messages
<Kingsquee> rust would not have ye, but zig shall be thy vessel
<Kingsquee> if but till the moon rises
<pixelherodev> Kingsquee, what?
<mikdusan> it's unfortunate the naming pattern `pointer` and `pointee` is just asking for trouble if applied to `slice` and `slicee`
<fengb> Slicer?
<mikdusan> that makes sense but I'll still end up with a slice/slicer/slicee and it's the slice/slicee existing in same block/context that's eww
<Kingsquee> fengb: slice/slicer => pointer/pointerer?
<mikdusan> slice/cheese
_Vi has quit [Ping timeout: 252 seconds]
<Kingsquee> :thinkign:
marijnfs_ has joined #zig
<mikdusan> sliceable
<mikdusan> or maybe just the target; bah
marijnfs has quit [Ping timeout: 260 seconds]
<Kingsquee> target sounds nice for both
<fengb> target / targee
nephele has joined #zig
nephele_ has quit [Ping timeout: 252 seconds]
<Kingsquee> time to write the zig docs in lojban
<Kingsquee> so, is there a way to generate a prettier error than this? https://zig.godbolt.org/z/cVHa_A
<andrewrk> fengb, yes exactly, just port over the llvm code
<andrewrk> mikdusan, nice work. if I host this on ziglang.org want to try hooking it up in the CI on a branch and merging TheLemonMan's "moar simd" PR into it? (or feel free to hand off the task, of course)
<Kingsquee> some condition I can use to typecheck for Qi and generate a @compileError if it's not
<mikdusan> andrewrk: yes I'll try that but first against my local archlinux VM and then CI
<mikdusan> LemonBoy comment in #4737 says linux failed due to qemu and the log shows a qemu-x86_64 execution... and I can see the test, but how can I tell on my re-run if it is a qemu test? is the "behavior-x86_64-..." vs. "behavior-native-..." indicate qemu?
<andrewrk> mikdusan, the -Denable-qemu should do it
<andrewrk> if you pass that to `zig build` then you should see all the architectures from https://github.com/ziglang/zig/blob/f6d384450fd7a9c6da236928ef84629bfbfbb781/test/tests.zig#L39-L266
<andrewrk> at least the musl and no-libc ones (the glibc ones require additional setup that takes a long time to obtain)
<mikdusan> ok I think there is progress; with new qemu, #4737 rebased to master, local VM:
<mikdusan> behavior.vector.test "behavior-aarch64-linux-none-Debug-bare-multi vector shift operators"...expected 1, found 8388607
<mikdusan> I'll prep a CI change and PR soon
<andrewrk> nice!
<andrewrk> the great thing about that is that we now have a process to upgrade to newer qemus quickly
<mikdusan> yeah and qemu dropped into my VM just fine too so that helps
<mikdusan> andrewrk: #4905 is already merged
<mikdusan> err hell I'm confused. #4905 is based'd off latest master, plus #4737, plus CI change to qemu. what else needs to be merged?
<andrewrk> mikdusan, oh I was suggesting to do it *without* lemonboy's changes, and we can get that into master
<mikdusan> ah ok
<andrewrk> then the ball is back in TheLemonMan's court
<mikdusan> ok so I'll close #4905 and the PR with ci bump to static-qemu5 is already open #4906
<andrewrk> great work
<fengb> Egads, these C macros make everything so hard to read :(
waleee-cl has quit [Quit: Connection closed for inactivity]
<andrewrk> you might benefit from poking around zig's compiler-rt sources, some of those macros might have already been factored into some common helper functions in zig
<fengb> I've never seen spaghettified code like this before >_>
<fengb> I guess I have but it's been buried for awhile
<andrewrk> mikdusan, looks like it's working great!
<mikdusan> i can't believe that qemu tar.xz is only 28 MB
<andrewrk> qemu is incredible
boothby has joined #zig
<mikdusan> we can slice an array, slice a (pointer to an array), slice a slice, but how about slice a (pointer to a slice) ?
<andrewrk> all the other ones have 1 indirection. a pointer to a slice has 2
<fengb> `void __atomic_store_c(int size, void *dest, void *src, int model)` the order comes in as a runtime argument. Should I manually unroll that into comptime args?
<andrewrk> it looks like __atomic_store_c is actually the __atomic_store symbol. so the ABI is important here
<andrewrk> the model comes in as a runtime arg
<andrewrk> I see what you mean about macro spaghetti
<fengb> Yeah I pasted the easier to unwind piece :P
<fengb> The Zig side requires a comptime order. I guess for more explicit maintenance, we should manually map the values over huh?
<andrewrk> not sure if I understand, but generally to get from runtime to comptime you have to switch over the value and then each prong can use the comptime value
<fengb> Right, I just mean manually switch each number instead of relying on @intToEnum
<andrewrk> hm if you're asking whether the zig enums are ABI-compatible with the compiler-rt values I think the answer is no
<andrewrk> so yeah I think the switch will be the best bet
<fengb> This Zig code looks so much better than macros though :P
<andrewrk> :)
<andrewrk> in theory the optimizer would figure out if a switch was just mapping numbers to the same numbers and turn into a no-op
<fengb> Ah good point
<boothby> so I patched the //!(eof) and ///(eof) to emit doc tokens which won't be terminated in newlines. if that threw an error instead, it wouldn't be a special case for people building doc tools. thoughts?
<fengb> Alright, I'm calling it for now. Have a good night!
<andrewrk> night
ur5us has quit [Ping timeout: 240 seconds]
dddddd has quit [Ping timeout: 265 seconds]
boothby has quit [Ping timeout: 252 seconds]
cole-h has quit [Ping timeout: 256 seconds]
frett27 has joined #zig
_Vi has joined #zig
junon has joined #zig
<junon> andrewrk: are you around by any chance?
BitPuffin has quit [Quit: killed]
pmwhite has quit [Quit: killed]
dtz has quit [Quit: killed]
pltrz has quit [Quit: killed]
ifreund[m] has quit [Quit: killed]
AlexMax has quit [Quit: killed]
ianc6209 has quit [Quit: killed]
Snektron has quit [Quit: killed]
sammich has quit [Quit: killed]
fengb has quit [Quit: killed]
alva has quit [Quit: killed]
BaroqueLarouche has quit [Quit: killed]
hryx has quit [Quit: killed]
afontain_ has quit [Quit: killed]
D3zmodos has quit [Quit: killed]
pmwhite has joined #zig
return0e has quit [Remote host closed the connection]
return0e has joined #zig
afontain_ has joined #zig
pltrz has joined #zig
BitPuffin has joined #zig
ifreund[m] has joined #zig
alva has joined #zig
dtz has joined #zig
AlexMax has joined #zig
sammich has joined #zig
BaroqueLarouche has joined #zig
Snektron has joined #zig
ianc6209 has joined #zig
hryx has joined #zig
fengb has joined #zig
D3zmodos has joined #zig
marijnfs has joined #zig
dermetfan has joined #zig
ur5us has joined #zig
<pixelherodev> Using `errdefer` to reset state makes things so much easier
marijnfs1 has joined #zig
marijnfs has quit [Ping timeout: 256 seconds]
return0e has quit []
frett27_ has joined #zig
frett27 has quit [Ping timeout: 256 seconds]
<daurnimator> junon: he usually goes to sleep ~3 hours before you asked. usually back in ~5 hours from now
<junon> cool, thanks daurnimator :)
marijnfs has joined #zig
marijnfs1 has quit [Ping timeout: 265 seconds]
ur5us has quit [Ping timeout: 252 seconds]
ifreund has joined #zig
Kingsquee has quit [Read error: Connection reset by peer]
dddddd has joined #zig
<junon> Trying to make a fix in the standard library but `zig test` is behaving oddly. Built master zig and installed it system-wide, then running `zig test lib/std/unicode.zig` gives me a plethora of errors (that don't normally exist when using the standard library).
<junon> Am I doing something wrong?
<daurnimator> junon: you shouldn't need to install to test
<daurnimator> just run directly from your git clone
<junon> running `build/zig test lib/std/unicode.zig` causes a permission error since `zig-cache` isn't generated.
<junon> (where `build/` has the cmake compilation within it)
<daurnimator> permission error? are you on windows by chance?
<junon> amcos
<junon> maocs*
<junon> my goodness
<junon> macos*
<daurnimator> what is the permission error?
<junon> `Unable to check cache: zig-cache/h: access denied`
<daurnimator> why doesn't zig-cache exist?
<daurnimator> it should get created as required.
<junon> So if I run using the system installed `zig`, it generates it when I run `zig test`
<junon> If I remove `zig-cache` and then run using `build/zig test` instead, it doesn't generate it at all.
<junon> There's a bug somewhere, just not sure where or why - I thought that `build/zig` was the same executable that was installed system-wide.
<daurnimator> that's odd....
<daurnimator> yeah it is
<daurnimator> can you try and run under `dtruss` and see for any weirdness?
<junon> Yeah just confirmed with `shasum`, they're the same.
<junon> o-o this is weirder
<junon> running with dtruss gives me the same output as running it with the system installed zig
<junon> performs the analysis and attempts a build, etc.
<junon> oh the difference is elevated permissions daurnimator
<junon> if I run `build/zig test` under sudo it works fine.
<junon> (not that I want to do this long-term...)
<junon> does `zig` get the sticky bit or something on macos?
<daurnimator> nope
<daurnimator> maybe some new apple mechanism?
<daurnimator> maybe your home dir mounted noexec?
frett27 has joined #zig
junon has quit [Ping timeout: 252 seconds]
frett27_ has quit [Ping timeout: 256 seconds]
junon has joined #zig
<junon> daurnimator: the code isn't in my home directory
<junon> I have a /src/<github_user>/<repo_name> layout - never been an issue before.
waleee-cl has joined #zig
rzezeski has quit [Quit: Connection closed for inactivity]
<pixelherodev> If I need to call a Zig function from JITed code, I need to `export` the function and use the platform's native C ABI?
<ikskuh> you don't have to export it
<ikskuh> just make it callconv(.C)
<pixelherodev> Ah right
<pixelherodev> Thanks!
tzekid has joined #zig
mahmudov has quit [Ping timeout: 264 seconds]
marijnfs has quit [Quit: leaving]
marijnfs has joined #zig
frmdstryr has left #zig ["Konversation terminated!"]
mahmudov has joined #zig
<daurnimator> (or any other calling convention you care to use)
plumm has quit [Quit: Lost terminal]
<ikskuh> dermetfan: just looked at the source of your directory includer
<ikskuh> you can make that 100% allocation-free with just a bunch of string compares
frett27_ has joined #zig
frett27 has quit [Ping timeout: 264 seconds]
marijnfs1 has joined #zig
decentpenguin has joined #zig
marijnfs has quit [Ping timeout: 264 seconds]
<pixelherodev> It works!!!
<pixelherodev> I implemented a variadic function for generating function calls
<pixelherodev> And based on argument type, it'll assign it a class and then register / stack space as per the x64 ABI
<pixelherodev> `block.call(ebus.reset, self.parent.ebus); block.ret(); block.run();` JITs the equivalent of `self.parent.ebus.reset();` :D
tzekid has quit [Remote host closed the connection]
frmdstryr has joined #zig
<mikdusan> junon: it is likely that because you have run zig as root, it create files/dirs with root permissions; now zig running as user will never be reliable until a cleanup is done. that cleanup involes nuking local and global caches, and anything else created by root
<junon> mikdusan: that's not the issue; removing zig-cache entirely and running unprivileged results in the same error.
<mikdusan> clarify: this also includes removing global cache ?
<pixelherodev> Maybe do an `strace`?
nephele_ has joined #zig
<mikdusan> junon: running on catalina?
<junon> mikdusan: there's a global cache?
<junon> and no, mojave
<mikdusan> ~/"Library/Application Support/zig"
<dermetfan> ikskuh: i should benchmark the difference in performance then. this suggests compares would be even faster: https://github.com/ziglang/zig/wiki/FAQ#why-is-switching-on-u8-strings-not-supported
<fengb> Best to measure and possibly inspect the assembly output
<fengb> I had to do some rain dances to convince LLVM to optimize if/else chains into a jump table
nephele has quit [Remote host closed the connection]
<pixelherodev> daurnimator, thanks for the fifo support :D
mahmudov has quit [Ping timeout: 258 seconds]
marijnfs1 has quit [Quit: Lost terminal]
<daurnimator> pixelherodev: hmm?
<pixelherodev> in std
<pixelherodev> std.fifo?
<dermetfan> i'm not yet an assembly wizard, could just implement both and let the user choose
<pixelherodev> that was you, right?
<daurnimator> pixelherodev: yes it was
<daurnimator> pixelherodev: but why the sudden appriciation?
<pixelherodev> Well, I appreciated it earlier already, but I'm using it for part of a dynarec and it's making life a lot easier
<fengb> dermetfan: don’t need to be an expert. Godbolt is your friend :)
<daurnimator> pixelherodev: cool :) there's some parts of its API that aren't obvious
<daurnimator> e.g. that you read/write from a network or file buffer then you can use readv/writev for optimal syscalls
<junon> mikdusan: yep, that was it - for some reason, had root perms
<junon> why is there a global cache? :( that seems like bad design
nephele_ is now known as nephele
<junon> yep fixed it right up
<mikdusan> 👍
<dermetfan> fengb: looks interesting, thanks!
<pixelherodev> daurnimator, interesting; care to elaborate?
mahmudov has joined #zig
dermetfan has quit [Ping timeout: 252 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
lrosa007 has joined #zig
lrosa007 has quit [Client Quit]
lrosa007 has joined #zig
frmdstryr has left #zig ["Konversation terminated!"]
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
marijnfs has joined #zig
<ikskuh> andrewrk: should a non-pub function in a pub strut be callable from another file?
<ikskuh> f.get() // works
<ikskuh> F.get(f) // doesn't work (get is private)
<ifreund> yeah that kinda threw me too when I discovered it
FireFox317 has joined #zig
TheLemonMan has joined #zig
<pixelherodev> How would I cast from `[42 * 4]u8` to `[42]u32`?
<pixelherodev> Using `mmap`
<pixelherodev> to allocate a register file (because it has to be in the lower 32-bit of the address space)
<ifreund> uh, can you @ptrCast()
<ikskuh> pixelherodev: @bitCast
<pixelherodev> ifreund, slices != pointers; I tried that :P
<pixelherodev> ikskuh, thanks!
<ikskuh> oh wait
<ikskuh> that's a slice
<ikskuh> :scream:
<ikskuh> pointercast then
<pixelherodev> ...
<pixelherodev> neither one works :(
<pixelherodev> "Expected pointer, found [42]u32`
<ikskuh> or use sliceToBytes and bytesToSlice :D
* ikskuh is stupid
<ikskuh> it's arrays, not slices
<ikskuh> so go bitcasting
<pixelherodev> oh right, that's an array :P
<pixelherodev> Unable to bitcast from pointer type
<pixelherodev> gahh
<mikdusan> pointer? you said 2 arrays
<ikskuh> this is getting confusing
<pixelherodev> From mmap-ed memory (slice) to array
<pixelherodev> `mmaped.ptr`
<ikskuh> having comptime known indices?
<ikskuh> mmaped[0..42*4] => [42*4]u8
<pixelherodev> I have a `[42*4]u8`
<pixelherodev> I want a `[42]u32`
<ikskuh> this should be bitcastable
<pixelherodev> The raw slice?
<ikskuh> there is no slice
<ikskuh> these are arrays
<ikskuh> if you have pointers to them, then use ptrCast
<pixelherodev> ... gahhhh
<pixelherodev> Sorry, tired
<pixelherodev> Ah wait
<pixelherodev> I have a `[]u8` with len 42*4
<pixelherodev> Not a `[42*4]u8`
<ikskuh> then use known-size slicing
<ikskuh> => yields array
<ikskuh> then use bitcast :D
<pixelherodev> `mmaped[0..4*42]` gives a pointer-to-array? :confusion:
<pixelherodev> ./src/dynarec/emitter.zig:20:98: error: unable to @bitCast from pointer type '*align(4096) [168]u8'
<ikskuh> ah yeah
<ikskuh> now only dereference
<ikskuh> and yes, this is new behaviour and it's daaaamn useful :D
<pixelherodev> I can just ptrCast *that* though!
<ikskuh> yep
<ikskuh> cast all the things!
<pixelherodev> Thanks!
<pixelherodev> Had to change the type of the field to `*align(4096)[48]u32` but it's good now
<pixelherodev> I didn't realize that `[0..]` and `[0..known_len]` gave different types
<ikskuh> it's not that long ago
<ikskuh> mikdusan: added the slicing thing to https://github.com/ziglang/zig/wiki/Master-Branch-Notable-Changes
<mikdusan> oh could you put that at top of March? top is more recent
<ikskuh> okay
<ikskuh> btw, thanks for doing this list :)
<ikskuh> i'll try to keep an eye out and update that as well
dermetfan has joined #zig
lrosa007 has quit [Quit: Leaving.]
dermetfan has quit [Ping timeout: 272 seconds]
dermetfan has joined #zig
<pixelherodev> Found the single best use for errdefer
<ikskuh> oh
<pixelherodev> It's the first line in my main() function
<ikskuh> i'm scared now :D
<pixelherodev> Want to guess?
<ikskuh> nah, i prepare for running away screaming
<pixelherodev> `errdefer std.debug.warn("\x1b[31m", .{})`
<pixelherodev> The nice thing is, the stack trace logic *resets it*
<pixelherodev> So you have red-colored `error: the_error` then a normal stack traace
<pixelherodev> s/aa/a
lrosa007 has joined #zig
<ikskuh> i cannot understand how you can work on CRT
<ikskuh> better use a real one than this thing
<pixelherodev> Because I honestly don't like any of the available options
<pixelherodev> and CRT with all options disabled is sufficient
<pixelherodev> It's barely distinguishable from e.g. lxterminal
<ikskuh> hm. i use termite
<ikskuh> it just does nothing ^^
<ikskuh> it has "some" features, but afaik less then xterm and is even more usable
<pixelherodev> Only reason I don't use a TTY is the inability to take a screenshot
<pixelherodev> and that's only a problem because I can't remember what tool can do that
<pixelherodev> There's a way to snapshot the framebuffer but I only ever remember it when I'm away from my computer :P
<pixelherodev> Anyways
<pixelherodev> the point of the picture wasn't my terminal :(
<ikskuh> :D
<ikskuh> but i cannot see a red "error: something"
<ikskuh> but another message that is red
danyspin97 has quit [Quit: ZNC - https://znc.in]
<pixelherodev> Oh whoops that was before I made the change
danyspin97 has joined #zig
<pixelherodev> I have waaaay too many screenshots polluting ~
<ikskuh> use a script that does auto-uploading
<ikskuh> and hashing
<ikskuh> and deleton
<ikskuh> → clean environment and quick links
<pixelherodev> Or just `rm ~/*png`
<ikskuh> that would delete way too many stuff :D
<pixelherodev> for i in ~/*.png;do eom $i; read; if [[ $REPLY == y ]];then rm $i -f;fi;done
<pixelherodev> and done
<pixelherodev> that wasn't too bad
<pixelherodev> Unrelated: pretty proud of this one https://i.imgur.com/3Jpvp8R.png
<pixelherodev> The full thing runs in single-digit milliseconds and I can trace all of what it's doing and honestly say that there's not much room for optimization
cole-h has joined #zig
rzezeski has joined #zig
<fengb> So ultra-fast debug build time?
lrosa007 has quit [Read error: Connection reset by peer]
<companion_cube> what's that profiling tool?
<pixelherodev> KCacheGrind
<companion_cube> pretty cool!
<pixelherodev> It's a frontend for CallGrind files
<pixelherodev> I don't use KDE, but I still love it
<pixelherodev> The alternative I've used is a small shell script that integrated with a GNU perf tool to generate a PNG
<pixelherodev> Which was good
<pixelherodev> But this is *interactive*
<TheLemonMan> the new gnome sysprof is also nice
marijnfs1 has joined #zig
marijnfs has quit [Ping timeout: 256 seconds]
<andrewrk> I've never tried gnome sysprof, I'll have to give it a spin
<pixelherodev> Link?
<pixelherodev> I found a page from 05
FireFox317 has quit [Ping timeout: 265 seconds]
<TheLemonMan> I wonder how much time we could shave if the docgen steps were executed in parallel
<andrewrk> that's all in zig code too
<andrewrk> might be worth implementing a little something even before async I/O is stable
<andrewrk> same with compile errors
<pixelherodev> fengb, super fast, yes; however it still depends on the frontend speed
<pixelherodev> Currently, waiting for Zig to emit LLVM IR takes most of the time
<pixelherodev> Well, it would if not for the cache
marijnfs has joined #zig
Akuli has joined #zig
marijnfs1 has quit [Ping timeout: 250 seconds]
<TheLemonMan> andrewrk, isn't #938 a prerequisite for that?
<andrewrk> TheLemonMan, that would be a prerequisite for the async I/O route (which is where I want to get to eventually). But it's possible today to implement a simple thread pool and run (blocking) child processes in separate threads
<andrewrk> it's such a shame too, the drone ci box has an insane number of cores and we only use 1 at a time
<andrewrk> I've been focusing on climbing the "global maximum" (e.g. work on async I/O) rather than the "local maximum" (implement some thread pool thing for now to speed up test runs). but it is tempting
<TheLemonMan> compile-error takes ~3min, docgen ~5min
<pixelherodev> Isn't it better to have short-term speed to make long-term gains easier?
FireFox317 has joined #zig
<FireFox317> TheLemonMan, time to debug another bug with me?
<TheLemonMan> FireFox317, sure thing!
<FireFox317> behavior tests are passing, std tests not yet. Its hitting an udf in `hash_const_val`, but i can't reproduce it with a test case and also putting a breakpoint on there doesn't work because its called so often. backtrace: https://pastebin.com/PJ6iCHpq
frett27_ has quit [Ping timeout: 240 seconds]
<FireFox317> did figure out the source_instr -> /home/pi/zig-source/lib/std/fmt.zig:182:35
<TheLemonMan> hmm, line 5341 is empty for me
frett27_ has joined #zig
<TheLemonMan> get a disasm so we can see why it's getting to the udf
<andrewrk> are these udf's coming from building with zig cc in debug mode so that -fsanitize=undefined is enabled?
<FireFox317> yes i think so andrewrk
<andrewrk> neat
<FireFox317> well i'm pretty sure this one also crashed in release mode
<andrewrk> ah
<FireFox317> not sure tho XD
<andrewrk> well what was the -DCMAKE_BUILD_TYPE arg, if any?
<andrewrk> the bootstrap repo hard codes it to Release
<FireFox317> Yeah i changed it to Debug now, because i'm debugging and want a proper back trace :)
<andrewrk> yep so zig is passing -fsanitize=undefined to clang, unless you overrode that flag with -fno-sanitize=undefined
<andrewrk> it's likely you could reproduce this with zig built natively, passing -target to the std lib tests
<FireFox317> TheLemonMan, oh probably this binary wasn't compiled with master, but its pointing at the beginning of the function, because that is where the udf is. I can't break on the function to see where exactly it is jumping to there, because `hash_const_val` is called so often
<TheLemonMan> nice, get a disasm once you hit the udf
<TheLemonMan> if it's stuck at the beginning the input may be null/non-aligned garbage
<FireFox317> one moment, will build a zig binary of current bootstrap/master
<FireFox317> hmm andrewrk, build release now (unintentionally) and still hitting the sigill.
<andrewrk> hmm that is a mystery that I cannot explain
<FireFox317> TheLemonMan, i'm not able to see how it ends up at the udf, because i can't break on `hash_const_val` because it is called so often. How would you conditionally break on that one?
<TheLemonMan> uh, can't you just let it crash on the sigill and then get the backtrace?
<FireFox317> yes, but it is a backtrace of functions. not a backtrace of what happend in the function itself
<TheLemonMan> err, I meant disasm
<FireFox317> i can, but it won't be clear which branch actually jumped to udf, there are a lot of checks which could branch to the udf. disasm: https://pastebin.com/F8Tuy5C2 udf at line 1356
<FireFox317> that is why i need to break on the function so i follow which check actually jumps to the udf. but i'm not able to break on the function :)
<TheLemonMan> well you said the backtrace points to the function start, if the debug infos are correct it means you're not going past the zig_assert
<TheLemonMan> that narrows it down to only 4 possible branches
<TheLemonMan> you can try with `b hash_const_val if $r0 == 0`
marmotini_ has joined #zig
marmotini_ has quit [Read error: Connection reset by peer]
<FireFox317> hmm yes it does point to the assert, but i have a feeling that it is just pointing there because it doesnt know. addr2line on the udf also returns the beginning of the function, but it could end up there from anywhere in the function
<TheLemonMan> right, debug infos are often untrustworthy, especially in release mode
<FireFox317> but its zig in debug mode, but i found a way to break on the function. will check which branch will jump to the udf
<TheLemonMan> I said _especially_, not only... the udf is introduced by llvm and so it has no mapping to the source file
<FireFox317> ah yes indeed, my bad
<FireFox317> TheLemonMan, okay its line 1252 in the disassembly that jumps to the udf. compiler_rt.__mulodi4 bug?
<TheLemonMan> you have an overflow there
<TheLemonMan> r0-r1 are a, r2-r3 are b and the overflow pointer is passed on stack
<TheLemonMan> the ZigTypeIdEnumLiteral case
<FireFox317> yes indeed, it should be doing a 32 bit multiplication there?
<FireFox317> but compiler rt is doing a 64 bit one
<FireFox317> TheLemonMan, maybe i have to put a (uint32_t) in front of the number?
<FireFox317> or the number should be smaller such that it is not a long?
<TheLemonMan> ...how can a multiplication between two u32 overflow an u64?
marmotini_ has joined #zig
<pixelherodev> Can't?
<pixelherodev> Quick calculation says that the highest 32-bit number squared is 8589934590 less than the highest 64-bit number
<pixelherodev> (pow(2,64)-1)-(pow((pow(2,32)-1,2))
<pixelherodev> (pow(2,64)-1)-(pow(pow(2,32)-1,2))
marmotini_ has quit [Ping timeout: 250 seconds]
<TheLemonMan> oh wait, __mulodi does a signed multiplication
<ikskuh> (1<<32)^2 = 18446744073709551616
<ikskuh> to me
<TheLemonMan> adding a (uint32_t) should work
frett27_ has quit [Ping timeout: 250 seconds]
<TheLemonMan> FireFox317, there's another stray signed literal in ZigTypeIdOptional
decentpenguin has quit [Quit: decentpenguin]
<pixelherodev> ikskuh, if you shift a bit starting as bit 1 over 32 times it becomes bit 33
<FireFox317> TheLemonMan, whoop! nice find! we are making stage1 safer over time :)
* ikskuh is confused about pixelherodev
<pixelherodev> you need to then subtract to get the highest 32-bit number
<FireFox317> now it's cristal clear to me why we need zig, c/c++ is not made for cross-compilation code basically
<TheLemonMan> we're hitting pretty much every kind of UB
<FireFox317> TheLemonMan, what about the xor's?
<TheLemonMan> you don't spill any bit with xor (nor or nor and nor not)
<fengb> Sometimes I find it amazing C even has a standard >_>
frett27_ has joined #zig
<pixelherodev> ikskuh, the highest two-bit number is three, (2^2-1); the highest 32-bit number is `(pow(2,32)-1)`, not `pow(2,32)`
<pixelherodev> ` (1<<32)^2` doesn't give the highest result of a 32-bit mult; ((1<<32)-1)^2 does
<ikskuh> yes
<ikskuh> but doesn't change a thing ;)
<ikskuh> ((1<<32)-1)^2 = 18 446 744 065 119 617 025
<ikskuh> it's the uupper 31 bit set and the lowest bit set
<pixelherodev> Actually, there's a very big difference
<pixelherodev> pow(pow(2,32),2) is the same 2^64 oh wait
<pixelherodev> I think we were both showing the same thing in two different ways :P
<ikskuh> haha :D
<ikskuh> well
<ikskuh> btw, recommendation for such stuff: use speedcrunch!
<FireFox317> andrewrk, how would i partially test the std? running all the tests at once needs to much ram for my raspberry
<ikskuh> very fine programmers calculator
<andrewrk> FireFox317, you can use a combination of `zig test file.zig` and `--test-filter foo`
<FireFox317> hmm yeah, but pretty cumborsome for all files xd
<andrewrk> FireFox317, in std.zig you can remove "refAllDecls()" and explicitly reference only the ones to test
<andrewrk> for example: `_ = ArrayList;`
<FireFox317> ah yes indeed, that would be easier i guess
companion_cube has quit [Ping timeout: 250 seconds]
Ziemas has joined #zig
chivay has quit [Quit: RIP]
<andrewrk> oh wow. multiply by an integer literal, invoke UB
<andrewrk> that's so easy to do on accident
chivay has joined #zig
<fengb> Oh yuck
<FireFox317> jup, i'm still wondering why this was also caught in release mode
ur5us has joined #zig
<TheLemonMan> integer promotion rules are tricky
<FireFox317> Finally! Passed all the behavior and std tests on the raspberry :) So happy!
<andrewrk> wow well done FireFox317 and TheLemonMan
<andrewrk> that really made the difference between having a v7a tarball for 0.6.0 or not having one
<andrewrk> I believe we can enable 32-bit arm on drone CI now too
<FireFox317> one last thing i want to know is why it is still emitting all the safety checks in release mode
<FireFox317> nvm i know why
<TheLemonMan> andrewrk, #4737 is green, llvm is still fucking up the "nonstandard-sized" vectors on many arches
companion_cube has joined #zig
<andrewrk> nice
<andrewrk> idk what llvm expects us to do, this is how they set up debug info to work
<FireFox317> andrewrk, it was my fault :) i still had a zig compiler on the aarch64 box that did not understand the -O3 flags yet, because i was so early using the bootstrap repo :)
<TheLemonMan> well they begged us not to generate those weird vector shapes
<andrewrk> I thought they said only to not store weird vector shapes in memory
<andrewrk> but that's the only way to do debug info
<FireFox317> wait, -O3 is a linker arg as well?
<TheLemonMan> the weirdness doesn't stop there, in #4737 there's something going wrong with the array->vector->array conversion
<TheLemonMan> and sometimes there are problems with such vectors being fn params
<andrewrk> TheLemonMan, why does llvm miscompile? it looks like your new test only uses power of 2 bit sizes
<TheLemonMan> the shifts are u5/u6 vectors
<andrewrk> oh I see it now
<andrewrk> wow you implemented a lot of SIMD ops
<andrewrk> can you add a runtime safety test for the new safety checks you added?
<andrewrk> (or let me know if you want a hand off)
<TheLemonMan> if writing some test cases tickles your fancy then go for it! I was wondering how to do that without having to write a new case for each runtime check
<TheLemonMan> and GH is down! time to log off then!
* TheLemonMan dies
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<andrewrk> why not a new test case for each runtime check? that's how it's done now
frett27_ has quit [Ping timeout: 256 seconds]
<andrewrk> a github page that was already open and had the information I wanted already displayed, just changed itself into a 500 error page
Akuli has quit [Quit: Leaving]
<yrashk> anybody aware of https://github.com/zetzit/zz ? different goals, but interesting nevertheless.
<yrashk> "undefined behaviour is not allowed in ZZ"
<fengb> Hmm, it looks like it's trying to embed formal methods into an actual programming language?
<yrashk> something like that (using an SMT solver)
<pixelherodev> `a github page that was already open and had the information I wanted already displayed, just changed itself into a 500 error page` Just say NO to yavascript!
_Vi has quit [Ping timeout: 252 seconds]
<via> can you have a struct with fields that are or are not there based on comptime values?
marijnfs1 has joined #zig
marijnfs has quit [Ping timeout: 256 seconds]
<shakesoda> pixelherodev: ah, twitter syndrome
<andrewrk> via, not really but you can have the field have a different type
<andrewrk> such as void
dermetfan has quit [Ping timeout: 272 seconds]
<andrewrk> I was able to build an i386-linux tarball with ziglang/bootstrap, check off 1 more tarball for the release
<Yardanico> maybe I should try Zig again now that https://github.com/ziglang/bootstrap is there :P is it usable yet? (I'm cloning it rn and I'll try building for x86_64-linux-gnu)
<Yardanico> ah nvm I can use "x86_64-linux-musl" which is OK
<andrewrk> see the note about musl vs glibc
<Yardanico> yeah I saw, just forgot that Zig uses musl by default (which is cool) :)
gazler has joined #zig
gazler_ has quit [Ping timeout: 240 seconds]
MrMobius has quit [Read error: Connection reset by peer]