<yrashk>
(zig cc and zig c++ behave the same way in this case)
<yrashk>
same goes for stdio.h, etc.
ur5us has joined #zig
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 265 seconds]
nephele_ has joined #zig
nephele has quit [Ping timeout: 272 seconds]
return0e has quit [Remote host closed the connection]
return0e has joined #zig
return0e has quit [Remote host closed the connection]
return0e has joined #zig
dermetfan has quit [Ping timeout: 246 seconds]
<andrewrk>
yrashk, macosx is unfortunately the most problematic cross compilation target
<andrewrk>
we don't have the ability to provide libc for that target when cross compiling
darithorn has joined #zig
<redj>
looks like I might have to debug zig cc here
<redj>
I don't know why it would say it can't find those .a files which it clearly compiled :P
<redj>
andrewrk: I'm wondering if I could print the translated flags the zig cc will use when running the clan main or if it has any issues parsing any of these simple flags? I don't think it would...
<yrashk>
andrewrk: I remember doing something in this direction a few years ago; required a manual download of something from Apple. I can look into that.
<yrashk>
Even if it'll still be a required manual step...
waleee-cl has quit [Quit: Connection closed for inactivity]
<redj>
lld: error: unable to find library -lecBootstrap
<redj>
lld: error: unable to find library -lecereBootstrap
<redj>
mikdusan: I want to know why my linking isn't working
<mikdusan>
hmm.. I don't think we have all the verbosity that I'd like to see, but for now this _seems_ to show some linker output. try: `zig cc -### -o foo ...`
<daurnimator>
on the other hand, if you already use an IDE with gdb/lldb integrations, zig should fit right in
<redj>
daurnimator: thanks, I should for sure install something like that
<redj>
daurnimator: I would normally just use our "in-house" ide but I'm sure this will come with a number of issues to fix but it should already support debugging cpp
<mikdusan>
the raw info about "L" is excellent. it says "Link_Group"
<mikdusan>
and we can see that it is defined as stuff passed on to linker
<mikdusan>
so tools/update_clang_options.zig would have to be enhanced to relay that info
<redj>
yeah all this info about command flags is pretty cool
<mikdusan>
not all of it. just what is needed. so "linker_flag" bit or somesuch
<mikdusan>
then remember, this is .zig code. we _bridge_ it back to C++ via C struct/enums/whatever
<redj>
well, that should definitely be my first contribution
<redj>
mikdusan: thanks for all the pointers!
<mikdusan>
and eventually it ends up that main.cpp can see it. so here is an EQUIVALENCE between .zig and .cpp that is apropo:
<redj>
yes, I saw the _bridging_ in the stream
<redj>
mikdusan: I _think_ I should be able to figure it all out thanks to all your help... now I wish it wasn't quite this late :P
<mikdusan>
heh ok. just look at src-self-hosted/stage2.zig vs. src/stage2.hpp/.cpp -- see Stage2ClangArg or whatever
<redj>
I might have to wait until friday :P
<redj>
that is if I can resist giving it a go sooner :P
<mikdusan>
while at it I would love to see other sub-tool flags tracked. clang says it supports a few but these sound like we will need them: -X{assembler,linker,preprocessor}
<mikdusan>
anyhow good luck!
Patrice_ has joined #zig
<redj>
mikdusan: thanks, and I'll keep that in mind
<yrashk>
on the cross-compilation front, does anybody have it working from linux to osx? I tried to compile an empty hello-world zig file for -target x86_64-macosx and it fails to start on OSX with undefined reference to __tlv_bootstrap; if I make it --single-threaded, it fails to start with undefined reference to ___error
<daurnimator>
yrashk: we can't target OSX yet because we don't have a source of free/open source libc headers
<daurnimator>
(cross-target that is)
<daurnimator>
if you know some, we could support it everywhere
<yrashk>
daurnimator: I just had zig cc test.c work with C headers for OSX
<yrashk>
well, not *work* but compile, it still fails to start in a different way
<yrashk>
I was able to use the instructions from osxcross project to extract Xcode.app and just point zig to its include directory
<yrashk>
but I can't get cross-compiled artifacts (neither Zig nor C) start on OSX. Zig ones have those undefined references
<daurnimator>
yrashk: are you dynamically linking libc?
<yrashk>
and C one is failing with dyld: libdyld.dylib support not present for LC_MAIN
Patrice_ has quit [Read error: Connection reset by peer]
<daurnimator>
yrashk: do you have `-lc` on your command line?
Patrice_ has joined #zig
<yrashk>
yes
<yrashk>
I compiled C code with `zig cc test.c -o test -target x86_64-macosx -I ~/osxcross/tarballs/xc/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -lc`
<yrashk>
resulting in the above LC_MAIN error upon startup
<daurnimator>
yrashk: sorry, I think this is where my knowledge runs out
<yrashk>
I compiled Zig code with `zig build-exe test1.zig -target x86_64-macosx -lc`
<yrashk>
getting `dyld: Symbol not found: __tlv_bootstrap` upon startup
<daurnimator>
yrashk: what version of OSX?
<daurnimator>
yrashk: output of `ldd test` / test1?
<yrashk>
it does showcase x86_64-macosx cross-compilation
<TheLemonMan>
not our fault if nobody took care of the mach-o part of lld
<TheLemonMan>
grab your pitchfork and head to the apple headquarters
<yrashk>
¯\_(ツ)_/¯
terinjokes has joined #zig
<daurnimator>
yrashk: as I also said above.... if you know any way to get libc headers without agreeing to an apple license
<yrashk>
I don't know of any. Only one with the license agreement as per osxcross method
<yrashk>
Obviously it won't help to ship these with Zig. It'll only work as a manual method
<daurnimator>
yrashk: the other thing is: if you're on OSX, I'd love to have some zig <> objc bridge
<yrashk>
I'm actually on Linux. OSX is not my main machine at all
<yrashk>
I was just all giddy about trying to cross-compile to osx because the intro suggested that's possible :)
<TheLemonMan>
you only have to link the objects with another linker, no need to be snarky
<TheLemonMan>
as I told you before I'm linking osx binaries using Apple's ld64 running under darling
<TheLemonMan>
if you have osxcross you should also have some kind of linker that works
<yrashk>
I didn't intend to be snarky at all. Genuinely interested in opinions on the matter.
<yrashk>
I'll try out osxcross' linker once I build it
<yrashk>
Haven't actually used it in a good while
FireFox317 has joined #zig
<daurnimator>
yrashk: perhaps its something we could add to the libc config file
<daurnimator>
(see `zig libc`)
cole-h has quit [Quit: Goodbye]
<TheLemonMan>
FireFox317, yo
<FireFox317>
TheLemonMan, morning
<TheLemonMan>
I think I found the offending line
<FireFox317>
For me the assembly looked so confused, first `mov r10, #0` and later on checking if it's zero
<TheLemonMan>
in line L19976 there's a &stack->base where stack may be a nullptr
poga has joined #zig
<TheLemonMan>
the control flow is a bit messy because of the many checks inserted by the sanitizers
<TheLemonMan>
you call ir_resolve_bool, then check if the return is zero, then check if stack_is_non_null is a legal bool (whose value is either 0 or 1, that's the cmp+bhi)
<FireFox317>
TheLemonMan, i think that is indeed the case yes. When I steped through the code yesterday i didn't hit `ir_analyze_optional_value_payload_value`
<TheLemonMan>
then you `tst r0,#1` that branches on stack_is_non_null
<TheLemonMan>
r10 is initialized to nullptr and that's `stack`
<TheLemonMan>
and clang adds some checks to make sure that `stack` is well-aligned and non-null because we're dereferencing it
<FireFox317>
damn your debugging skills are so helpful here, i'll have some breakfast and then check if that was indeed the case
ur5us has joined #zig
<TheLemonMan>
afair doing pointer math on a null pointer is legal in C (and it's how offsetof is/was implemented)
<Kingsquee>
iirc it's undefined behaviour but works in practice
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
return0e has quit [Remote host closed the connection]
return0e has joined #zig
riba has quit [Read error: Connection reset by peer]
jjido has joined #zig
riba has joined #zig
<FireFox317>
TheLemonMan, i just added an extra variable for the `stack->base` and only assign it inside the if statement (when stack ptr is valid). Does that sound as a reasanable solution?
<FireFox317>
found the same pattern somewhere else when `ir_analyze_fn_call` is called
<TheLemonMan>
yup, that or `stack ? &stack->base : nullptr` is fine
marijnfs_ has joined #zig
<FireFox317>
jup indeed, we are 1 step further, now another SIGILL
<FireFox317>
in `ir_analyze_async_call`
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Patrice_ has quit [Read error: Connection reset by peer]
Patrice_ has joined #zig
ur5us has quit [Ping timeout: 252 seconds]
tdeo has quit [Remote host closed the connection]
tdeo has joined #zig
<TheLemonMan>
grab the disasm, I suspect it is yet another pointer-op on nullptr
wootehfoot has joined #zig
marijnfs_ has quit [Ping timeout: 240 seconds]
<Kingsquee>
pixelherodev: enjoy your (int8_t)127 + 1
<FireFox317>
TheLemonMan, hmm its seems it is on ir.cpp:18985 `&call_result_loc->source_instruction->base` and source_instruction is a nullptr
* pixelherodev
sobs
<fengb>
daurnimator: most of Apple’s libc headers are under permissive license with an exception being stdint.h for some reason
<TheLemonMan>
FireFox317, are you sure call_result_loc is non-null?
<FireFox317>
TheLemonMan, regarding your earlier question, which IR node?
<TheLemonMan>
call_result_loc
wootehfoot has quit [Ping timeout: 264 seconds]
<FireFox317>
when we enter the function, all the fields in call_result_loc are zero. at the exception the written field is true and it has a resolved location, but source_instruction is still zero
Kingsquee has quit [Quit: Konversation terminated!]
<TheLemonMan>
your guess is as good as mine, you're in the land of the result_loc
<TheLemonMan>
if you want a quick fix just s/&call_result_loc->source_instruction->base/source_instr/ and call it a day
<FireFox317>
yeah we probably need andrewrk for this stuff. will try if that gets me an further
marmotini_ has joined #zig
moo has quit [Quit: Leaving]
<redj>
mikdusan, daurnimator: I guess I need to fill my first PR :)
<FireFox317>
TheLemonMan, well that did fix the issue. succesfully compiled hello world on raspbian with a zig that is compiled with zig XD
<TheLemonMan>
try running the behavior tests
<TheLemonMan>
if you don't have enough ram to run the std.zig tests too you can selectively test some zig files
<TheLemonMan>
this way you exercise (pretty much) all the code paths
<FireFox317>
uhm, i can just copy the test directory and build.zig?
<FireFox317>
because i just have the zig binary and lib/std on the raspberry
<TheLemonMan>
oh, you can run the tests on lib/std/*.zig files then
marmotini_ has quit [Remote host closed the connection]
<FireFox317>
nvm, can just clone the zig repo on the raspberry and use the crosscompiled zig binary i guess
cow-orker has joined #zig
<FireFox317>
hmm build.zig tries to find llvm-config
<FireFox317>
TheLemonMan, assertion hit in const_ptr_pointee_unchecked_no_isf line 849
<FireFox317>
TheLemonMan, ir.cpp:800 sentinel is null
<TheLemonMan>
lel
<TheLemonMan>
FireFox317, what's the array_val->type->name ?
<FireFox317>
TheLemonMan, @Vector(4, bool) fmt.zig line 1673
<TheLemonMan>
the real question is why/what is accessing memory past the end of the vector?
<FireFox317>
hmm yes indeed, something in fmt apparently?
<FireFox317>
maybe the typeinfo on the vector or something?
<TheLemonMan>
yeah, check if the typeinfo on the vector is sane
marmotin_ has joined #zig
marmotin_ has quit [Ping timeout: 256 seconds]
riba has joined #zig
rzezeski has quit [Quit: Connection closed for inactivity]
<redj>
broken binaries produced by zig cc :(
<redj>
Illegal instruction
<ikskuh>
redj: then not the binary is broken, but the code you've compiled :D
<FireFox317>
redj, what platform did you compiled for?
<ikskuh>
zig cc introduces UBsan, a facility that traps on undefined behaviour
<FireFox317>
i'm working on arm32 now, and already had some illegal instruction fixes
<redj>
I'm not trying to cross compile yet, I'm on linux
<ikskuh>
how large is the code? only a small example or a bigger project?
<redj>
larger project
riba has quit [Ping timeout: 240 seconds]
<redj>
I do see with strace that this is an issue in the code
<redj>
but when I compile with gcc or clang there's no such issue :P
<FireFox317>
redj, because they don't enable the checks by default, zig does. we want safe code :)
* redj
wants safe code too
<redj>
but I wonder how I'm going to debug this though
<ikskuh>
compile with clang
<FireFox317>
redj, gdb :)
<ikskuh>
-fsanitize=undefined
<ikskuh>
afaik
<ikskuh>
or yeah
<ikskuh>
use GDB, it will halt at the location uf UB
<FireFox317>
TheLemonMan, the assertion is also hit when i just have a simple zig file with `const vbool: @Vector(4, bool) = [4]bool{ true, false, true, false };`
<redj>
does llvm come with libubsan? I'm having difficulty linking...
dermetfan has joined #zig
<TheLemonMan>
FireFox317, that's extra weird, what element index is it trying to deref?
<redj>
going to pick it up again later today :P
<redj>
still missing many __ubsan* symbols when linking despite -lubsan
<FireFox317>
TheLemonMan, one thing that is bit weird in the backtrace it is saying: `const_ptr_pointee_unchecked_no_isf (g=<optimized out>, const_val=<optimized out>)`
<FireFox317>
i have some trouble trying to put a breakpoint on that function because it is called very often, how would you do that?
<FireFox317>
however i can go back up the stack to `const_ptr_pointee_unchecked` and from there const_val is not optimized out, which is how i printed the fields
mahmudov has quit [Ping timeout: 256 seconds]
mahmudov has joined #zig
<FireFox317>
TheLemonMan, elem_index is 0, but `array_val->type->data.array.len` is also 0
xackus has joined #zig
frett27_ has joined #zig
frett27 has quit [Ping timeout: 265 seconds]
mahmudov has quit [Ping timeout: 256 seconds]
mahmudov has joined #zig
ifreund has joined #zig
rappet has quit [Ping timeout: 272 seconds]
rappet has joined #zig
dddddd has joined #zig
zfoo has joined #zig
<FireFox317>
TheLemonMan, do you have some time?
r4pr0n has joined #zig
<TheLemonMan>
FireFox317, in a hour or so, is that a problem for you?
<TheLemonMan>
redj, there's no support for the sanitizers runtime atm
zfoo has quit [Remote host closed the connection]
<FireFox317>
TheLemonMan, that's fine. Now it is an bug in the shr bigint implementation
waleee-cl has joined #zig
r4pr0n has quit [Quit: r4pr0n]
r4pr0n has joined #zig
r4pr0n has quit [Client Quit]
r4pr0n has joined #zig
r4pr0n has quit [Client Quit]
r4pr0n has joined #zig
zfoo has joined #zig
<FireFox317>
TheLemonMan, disassembly: https://pastebin.com/mfQr3xuc the last line is the one that branches to the sigill. its in behaviour/bit_shifting.zig line 94, its comptime shifting to the right with 64. using addr2line it is pointing to bigint.cpp:1433
mahmudov has quit [Ping timeout: 250 seconds]
<andrewrk>
redj, if you use `-fsanitize=undefined -fsanitize-trap=undefined` then there is no ubsan lib dependency; it will simply insert illegal instructions
<TheLemonMan>
FireFox317, oh that's some classic UB, the shift count should always be < than the type bit count
<TheLemonMan>
you should factor out `digit >> leftover_shift_count` as `(leftover_shift_count < 64) ? digit >> leftover_shift_count : 0`
<TheLemonMan>
or something equivalent
<TheLemonMan>
andrewrk, it seems that calling __getdirentries64 on darwin is frowned upon (https://github.com/golang/go/issues/31244), shall we switch to an Apple-approved API too?
<andrewrk>
hmmmm that's rather annoying but I suppose we have no choice
Patrice_ has joined #zig
<andrewrk>
I would make this low priority though. who knows, maybe they add a more useful api before zig becomes stable
<TheLemonMan>
the silver lining is that we have one less alias to take care of :P
<andrewrk>
it's also worth considering whether app store vs non app store are two different use cases of zig
<andrewrk>
certainly we will have to deal with this issue at some point though
<andrewrk>
yo apple maybe there's a reason everyone is calling getdirentries64 instead of the shitty libc api
frett27_ has quit [Ping timeout: 265 seconds]
<BaroqueLarouche>
Apple: Why are you still using C ? Why aren't using shiny new Swift and latest new API we forced on you 2 updates ago
<BaroqueLarouche>
Sorry lost all hope at Apple since that notarization bullshit
<shakesoda>
BaroqueLarouche: heh, yeah, i dropped apple support too
<shakesoda>
it's a shame, I really like using their systems, but as a developer I haven't exactly been given much confidence in dealing with them
<shakesoda>
oh, you're using opengl? how about not. oh, you distribute outside the app store? haha cute
<shakesoda>
you support older systems? one does not simply run on anything that is not blessed by your overlords
<yrashk>
speaking of Apple and cross-compilation.. maybe we should put a footnote in the intro on the main page saying that cross-compiling from non-osx to osx doesn't currently work? otherwise, the intro kind of suggests it does.
<shakesoda>
andrewrk mentioned that this exact fact might get them dropped from being listed as tier 1
<shakesoda>
iirc
<BaroqueLarouche>
GPU API is a mess
<TheLemonMan>
HN is gonna have a huge meltdown if you demote OSX to tier 2
<shakesoda>
TheLemonMan: sucks for HN
<yrashk>
too bad!
<shakesoda>
seems kind of like a difficult situation to avoid
<shakesoda>
somewhat topical, though, I might end up getting a work mac this (?) year
<shakesoda>
i'd very much rather get a much rumored arm mac
<andrewrk>
yrashk, I agree that point needs to be clarified on ziglang.org. will clean that up before the release
<shakesoda>
anyway, much as i'm not dealing with their crap, there's a fair bit of work available for me in dealing with their crap for other people lol
<shakesoda>
i do really like using macos though :(
<yrashk>
in the meantime, I am trying to convince osxcross to build on my nix :) to see if I can use their linker to use zig for cross-compiling to osx
<yrashk>
(not that this is a high priority to me...)
* shakesoda
plays a tune in honor of the death of tier 1 macos
mahmudov has joined #zig
<andrewrk>
note that this is not zig being worse on macos; rather it's the requirements of tier 1 raising the bar
<companion_cube>
ahah andrewrk you're ballsy
<fengb>
Tier creep
<fengb>
Introduce a tier 0 🙃
<BaroqueLarouche>
S tier, like in japanese video games
<andrewrk>
freebsd and macos have equivalent support right now. but we can actually ship freebsd .h files and libc start files, which would bump freebsd to tier 1
<mikdusan>
thanks c++ switch fallthrough. I hate you.
<andrewrk>
those bugs can be gnarly
<fengb>
andrewrk: I still think most of the headers can be included. The only one that wasn't usable I found (out of ~20 I opened) was stdint.h
<fengb>
I can do a deeper audit
<shakesoda>
mikdusan: the worst one for me is accidental = inside of if
<shakesoda>
switch fallthrough is also real bad
<andrewrk>
fengb, and that one is probably an accident. since these headers are meant to be compiled statically into proprietary software
<shakesoda>
the = inside of conditions thing has compelled some people i know to reverse all their conditions into yoda form (if true == thing)
<shakesoda>
to reduce the possibility of that error not being a compile error
<fengb>
Yeah it looks like generic boilerplate where they forgot to relicense
<andrewrk>
it's hard to make that argument though, and also hard to get apple to change it
<shakesoda>
feels like a really weird bug report to make
<ikskuh>
shakesoda, mikdusan: gcc and clang allow both of those mistakes to be errors by settings to corresponding warning to an eror
<fengb>
From a clean room perspective... is it okay to just write a program to spit out the values and manually stitch that into a header file?
<fengb>
I wouldn't be looking at the source file, just consuming its outputs
<shakesoda>
ikskuh: the people in question use msvc, which i don't think says anything about it
<shakesoda>
does cl have a flag for that?
<ikskuh>
dunno
<ikskuh>
never digged deep into cl, always preferred mingw on windows
<shakesoda>
still a nasty language defect though :(
<shakesoda>
good that gcc and clang have options here though
<mikdusan>
ikskuh: ah nice
<andrewrk>
fengb, I'm not sure but I bet you could work with someone who was not in the clean room with you, who tested your stdint.h implementation, while looking at the official one, providing you example test cases that pass/fail
<andrewrk>
as long as you don't look at the official one I think this is allowed
<andrewrk>
so person A is in the clean room writing the impl and can't look at official. person B is looking at official, not in clean room, and gives example test cases to person A. Person B is qualified to know when person A's job is complete
<ikskuh>
oh, also -Werror=return-type
<ikskuh>
^= compile error on missing return
<mikdusan>
heh I found one fallthrough in zig's c++ source ... and ... andrew has a comment sticking out "// fallthrough" :)
<andrewrk>
if there's a way to annotate that which allows us to enable the warning, I'd be in favor of that
<shakesoda>
i'd be fine with fallthrough if it were just explicit
<shakesoda>
like case foo: pass;
<mikdusan>
andrewrk: sadly, the `[[fallthrough]]` annotation is minimum c++17
<ikskuh>
andrewrk: for C++11 and the following:
<ikskuh>
[[fallthrough]];
<ikskuh>
oh, it's c++17?
<ikskuh>
damn
frett27 has joined #zig
<shakesoda>
TIL
<ikskuh>
i'm so used to that statement now :D
<shakesoda>
i'm still on c++11 across the board since so little of interest has happened since
<shakesoda>
i'd rather move away from c++ than update :)
<ikskuh>
c++17 has a lot of nice features actually
zfoo has quit [Remote host closed the connection]
<fengb>
Back in my day, C++98 wasn’t even implemented by everyone! 🦖
Patrice_ has quit [Ping timeout: 250 seconds]
<yrashk>
I was able to build osxcross (not on NixOS but in an Alpine container) but so far that didn't help finishing the linking of Zig-built .o into something that'd work on OSX. I might as well give up on this effort for now :)
<shakesoda>
as far as I can tell every c++ update just makes everything yet more complicated, and the software built against every newer c++ version becomes... yet more cryptic
<mikdusan>
I have one word for a pleasant C++ experience: CFront
<andrewrk>
mikdusan, ah that's too bad. and I do want to keep stage1 c++ code at an easier c++ standard to implement. I'd even stick to pure C if llvm/clang didn't bring in the c++ dependency
<shakesoda>
fortunately zig is here to save me from such horrors ;)
<fengb>
Well they keep stapling on new legs without removing anything
<ikskuh>
shakesoda: wanted to to say: zig provides a lot of those features
<ikskuh>
tagged enums, optional, ... :D
<mikdusan>
andrewrk: there _might_ be an avenue for us to def macro if gcc using their attribute, or use clang's [[clang::fallthrough]] attribute which predates c++17 iirc. but already we are getting icky
<fengb>
It can't ever get less complicated
<andrewrk>
I'd be fine with that as long as it theoretically works on other compilers too
<ikskuh>
echo > source.cpp
<shakesoda>
ikskuh: and zig is designed such that almost every class of madness c++ has doesn't exist!
<andrewrk>
by "works" I mean "doesn't cause compile errors"
<shakesoda>
best of both worlds
<ikskuh>
. The Microsoft C++ compiler currently does not warn on fallthrough behavior, so this attribute has no effect compiler behavior.
<ikskuh>
should be possible to do a FALLTHROUGH macro
<shakesoda>
I distinctly remember c++'s optional having a footgun designed in though I can't remember what
<shakesoda>
maybe the way dereference works
<andrewrk>
yeah I'm saying I'm fine with compiler-specific directives that are harmless for other compilers
<ikskuh>
which resolves to nothing on compilers without support
<ikskuh>
shakesoda: getting the actual address of the optional: &*foo
<ikskuh>
♥
<fengb>
I'm really happy that Zig solves 99% of my usecases without fuss. I'm happy to ignore that 1% itch
<shakesoda>
fengb: same
<ikskuh>
+1
<shakesoda>
it also improves cases i had that i didn't realize i had, which i now realize are structural problems in... every program i've ever made
<companion_cube>
like what? :)
<shakesoda>
zig's allocators have spoiled me forever.
<companion_cube>
ah yeah, nice.
<ikskuh>
yep, same here
<ikskuh>
also error handling
<shakesoda>
yeah, that too
<shakesoda>
the convention for passing allocators everywhere makes it feel really obvious in just how many things i have certainly not chosen the right tool for the job, because of using the default one
<ikskuh>
also you start to think: "do i really need to allocate here"
<yrashk>
speaking of passing allocators... is there a way to get system allocator in build.zig?
<shakesoda>
ikskuh: yeah, for sure, although i work on relatively low powered machines where i've had that thought in mind for a long time now
<ikskuh>
there's builder.allocator
<yrashk>
I had to recursively walk a directory in build.zig to run all tests in all files, and that walker wanted an allocator (had to resort to a fixed size one)
<FireFox317>
Thanks, TheLemonMan!
decentpenguin has joined #zig
<ikskuh>
run all tests in all files sounds like you don't reference all the files in your artifacts?
<shakesoda>
further zig is evidence that one can have nice things without all kinds of implicit ways of hiding the truth of what is happening
<andrewrk>
yrashk, the `b` thing has an `allocator` field which is just an arena for the whole run of zig build
<TheLemonMan>
FireFox317, thank you! you're single-handedly removing all the UB from stage1 heh
<yrashk>
andrewrk: oh, perfect -- I somehow missed it
<yrashk>
<3
<andrewrk>
yrashk, generally you can use that and don't worry about freeing anything since your zig build command is probably going to do some small amount of work and then terminate
<ikskuh>
i learnt these days that i'm not supposed to delete my strings in the build() function :D
<andrewrk>
yeah I mean it doesn't hurt anything, but it also doesn't help since that allocator is an arena
rzezeski has joined #zig
<ikskuh>
it does hurt actually
<ikskuh>
because the builder doesn't clone the string
<andrewrk>
it's been fun implementing certain file system abstractions without memory allocations
<ikskuh>
*strings
<shakesoda>
is there an easy way to figure out the executable location for zig tests or build exec
<shakesoda>
use case: debugger
<ikskuh>
so if i calculate file paths, i am not to free them
<shakesoda>
for regular outputs this is trivial, i'm just not sure what to make of tests
<andrewrk>
makePath, deleteTree, atomicFile, none of these heap-allocate
<andrewrk>
sure, plenty of things can go wrong when you try to do these operations, but at least running out of memory is not one of them
<shakesoda>
andrewrk: knowing that build step has an allocator gives me a few spots to remove code :)
<mikdusan>
wow... so I define a macro and clang actually LEARNED that macro and tells me to insert `ZIG_FALLTHROUGH; to silce this warning` in clang diagnostics
<andrewrk>
it's the `*std.Builder` that has it
<shakesoda>
right
<andrewrk>
mikdusan, wow!
<fengb>
Clang passes the Turing test
<mikdusan>
the thing is self aware. I'm just waiting for it to clear up a few PRs now
<ikskuh>
crazy
<ikskuh>
i think most modern C++ compilers are more black magic than anything else
<shakesoda>
just like most modern c++ code, including and especially the stl
<ikskuh>
heh
<ikskuh>
i read some code of libc++
<ikskuh>
and that looks quite sane
<ikskuh>
compared to libstdc++
<fengb>
Aren’t all compilers black magic?
<shakesoda>
there are definitely tiers of black magic involved
<shakesoda>
some of them are dark magic, but i wouldn't call them black magic
<fengb>
C++ is vantablack
<shakesoda>
some of them are perhaps only grey magic
<mikdusan>
anyone familiar with tokenizer; this is currently fallthrough. correct or missing break?:
<TheLemonMan>
that was a trick question, what do I win?
<mikdusan>
SawBarBar falls through to SawSlash; sorry my highlighting may have mislead
<ikskuh>
wait
<ikskuh>
yeah this is fallthrough
<shakesoda>
that certainly does look like an error
<TheLemonMan>
oh shit, the break is for the switch
<shakesoda>
yeah.
<shakesoda>
sinister, isn't it
<ikskuh>
good we have code analysis for that
<andrewrk>
nice catch mikdusan
<TheLemonMan>
let's use the same keyword _everywhere_, what could go wrong?
<shakesoda>
ikskuh: if only we had a language that outright forbid it... ;)
<ikskuh>
😱
<ikskuh>
btw, i'm planning a small socketing library written in zig targeting windows and linux by creating a thin wrapper around the berkeley sockets API
<shakesoda>
this is exactly something I was going to look into doing myself for embedded debugging shaders/images
<ikskuh>
same
riba has joined #zig
frett27 has quit [Read error: Connection reset by peer]
frett27 has joined #zig
<dermetfan>
If you have sensible feature ideas let me know. For example I was thinking about a callback so you can compute and attach metadata on the fly
lrosa007 has joined #zig
jmiven has quit [Quit: bye]
jmiven has joined #zig
lrosa007 has quit [Remote host closed the connection]
<xackus>
what are your thoughts on a len() function in the new ArrayList API? for example: table_entry.attrs.items.len vs table_entry.attrs.len()
<andrewrk>
xackus, my strong opinion is no len function; rely on items.len
<xackus>
I thought you would say so
riba has quit [Ping timeout: 265 seconds]
jjido has joined #zig
<fengb>
How about we make it a packed union so .len and .items.len are the same? 🙃
lrosa007 has joined #zig
lrosa007 has left #zig [#zig]
<FireFox317>
TheLemonMan, your fix was almost correct. `leftover_shift_count` was actually 0, so it was the line below doing `something << 64`. i think the only remaining issue is the assertion with the vector code.
<shakesoda>
sounds a touch arcane
<TheLemonMan>
FireFox317, oh right, that's the remainder from mod 64, it'll always be less than 64
<FireFox317>
Yes indeed
<TheLemonMan>
so, back to the vector
<TheLemonMan>
you said the length is also zero... that's weird
<TheLemonMan>
can you dump the data.array structure?
frett27_ has joined #zig
<FireFox317>
for reference i'm testing it on a vector.zig file with a main and one line: `const vbool: @Vector(4, bool) = [4]bool{ true, false, true, false };`
frett27 has quit [Ping timeout: 260 seconds]
<FireFox317>
TheLemonMan, (gdb) p $7.type.data.array $8 = {child_type = 0x82e0e50, len = 0, sentinel = 0x0}
<FireFox317>
child_type.id is a bool
frett27 has joined #zig
<TheLemonMan>
thefuck.bat
<TheLemonMan>
put a conditional bp on get_vector_type if len is zero
<TheLemonMan>
wait, what's the type.id ?
frett27_ has quit [Ping timeout: 260 seconds]
<FireFox317>
of array_val->type?
<TheLemonMan>
yep
<FireFox317>
TheLemonMan, vector
<FireFox317>
specifically ZigTypeIdVector
<TheLemonMan>
uh...
<TheLemonMan>
is .type.data.vector ok?
<FireFox317>
jup
<FireFox317>
len = 4
<FireFox317>
and elem_type again correct a bool
<TheLemonMan>
ZigTypeVector and ZigTypeArray share the same first element, child_type in both cases
<FireFox317>
jup but the len isn't shared and it should be?
<TheLemonMan>
nah, that would just fix half of the problem, the sentinel is missing in the vector payload
<TheLemonMan>
just add a switch on array_val->type and make it access the right payload
<TheLemonMan>
oh wait, there's a lot of code pulling this shit
<FireFox317>
ah the len in the vector is a u32 and in array it is u64
<TheLemonMan>
yeah so I think the best way to solve this problem is to make the two layouts match
<FireFox317>
i think if the len field in the ZigTypeVector is also u64 it would see the correct lengt
<FireFox317>
and what about the sentinel? it shouldnt be in the zigTypeVector right?
<TheLemonMan>
nope, but a lot of code is just switching on ConstPtrSpecialBaseArray without checking the base type
<TheLemonMan>
so a lot of code is just reading garbage that's hopefully zeroed
<FireFox317>
hmm yeah that's no good indeed
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<andrewrk>
FireFox317, mind updating the test case for #4896? I think the new error column is good. I locally ran the rest of the compile error tests and the rest pass
<TheLemonMan>
IMO stage1 doesn't deserve any love, pad ZigTypeVector so that it has the same size as ZigTypeArray and make sure to zero this padding in get_vector_type
<andrewrk>
I tried it on my system but wasn't able to static link
<andrewrk>
really, anyone can do this task, we just need a tarball that we can download & extract on the CI
<mikdusan>
sure, I'm just working on some 0.7.0 PR so I can put that on hold
dermetfan has quit [Ping timeout: 252 seconds]
marijnfs1 has joined #zig
<FireFox317>
Yess!! All the behavior tests are passing on the raspberry pi! Thanks again, TheLemonMan!
<TheLemonMan>
FireFox317, o/
<shakesoda>
FireFox317: which one?
<FireFox317>
shakesoda, running on armv8, binary is for armv7
marmotini_ has joined #zig
marmotini_ has quit [Read error: Connection reset by peer]
oats is now known as ots
ots is now known as bloats
bloats is now known as hafer
hafer is now known as oa
oa is now known as moats
moats is now known as hugs
frett27_ has joined #zig
frett27 has quit [Ping timeout: 240 seconds]
<FireFox317>
andrewrk, TheLemonMan #4896
r4pr0n has quit [Remote host closed the connection]
Sahnvour has quit [Quit: WeeChat 2.7]
lrosa007 has joined #zig
r4pr0n has joined #zig
<andrewrk>
\o/
<fengb>
Any chance for armv6 too? :P
<andrewrk>
which one?
<andrewrk>
v6, v6j, v6k, v6kz, v6m, v6sm, v6t2
<fengb>
Uh... whichever for rpi1 / rpi0
<andrewrk>
ah we have a known cpu for those: arm1176jzf_s
<andrewrk>
it's v6kz
<fengb>
Ah okay cool. This is so confusing >_>
lrosa007 has quit [Quit: Leaving.]
<andrewrk>
I need to improve flag handling of zig cc in order to test that one
<fengb>
Is v6kz a subarch? So it's handled by CPU features in Zig
<fengb>
nvm, I see it in cpuFeatures
frmdstryr has quit [Ping timeout: 256 seconds]
marijnfs_ has quit [Ping timeout: 240 seconds]
marijnfs2 has joined #zig
<redj>
andrewrk: there's no mention of -I in the zig cc issue (https://github.com/ziglang/zig/issues/4784) -- doest that mean it's not meant to be supported? that's the next flag I would need to build ecere-sdk with zig-cc
<fengb>
Reading Zig's list of cpuFeatures is so much more rewarding than hunting down hardware specs
marmotini_ has joined #zig
jjido has joined #zig
marmotini_ has quit [Ping timeout: 260 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xackus has quit [Remote host closed the connection]
marijnfs_ has joined #zig
dermetfan has joined #zig
r4pr0n has quit [Quit: r4pr0n]
marijnfs1 has quit [Ping timeout: 250 seconds]
nycex_ has joined #zig
nycex has quit [Ping timeout: 240 seconds]
marijnfs_ has quit [Ping timeout: 250 seconds]
ifreund has quit [Ping timeout: 258 seconds]
ifreund has joined #zig
ur5us has joined #zig
* shakesoda
brings up arm1176jzf-s pretty relentlessly
<ifreund>
so is it considered good style to drop the curly braces on if/while/for?
<shakesoda>
no
<shakesoda>
dropping them is just useful sometimes (for e.g. ternaries)
<ifreund>
alright, i guess that makes sense
<ifreund>
i must admit, I kinda miss blocks being expressions from rust
<andrewrk>
blocks are expressions in zig, to be clear. what you're missing is the syntax sugar
<ifreund>
fair enough
<andrewrk>
but you know about `break` accepting a block label argument right?
<ifreund>
having to label block you want to break from isn't super ergonomic though
<andrewrk>
yeah everyone agrees with you on that
<fengb>
At one point, Zig automatically returned the last line's value if it was missing a semicolon
<ifreund>
interesting, do you have a link to the proposal removing that handy?
<andrewrk>
daurnimator, yes thank you for pointing that problem out
<companion_cube>
Kingsquee: is that a fixed-point arith module?!
<marijnfs2>
what happened to Buffer?
<daurnimator>
marijnfs2: see.... 7 lines up
<daurnimator>
in 95% of cases people were using std.Buffer when they shouldn't be. The new name reflects what it actually does, and should hopefully steer people away
cncl_ has joined #zig
<marijnfs2>
daurnimator: I see, catchy name
<marijnfs2>
but yeah Buffer was pretty weird for this thing
<marijnfs2>
ArrayList is still a bit double for me
dch_ has joined #zig
<daurnimator>
"a bit double"?
<marijnfs2>
array and list
<marijnfs2>
a list of arrays?
<marijnfs2>
a list and also an array
<daurnimator>
There are many ways to make a list
<daurnimator>
ArrayList is the style of list where its stored as an Array
<daurnimator>
vs SinglyLinkedList
<marijnfs2>
why not array
<marijnfs2>
isn't an array a collection of things
<marijnfs2>
thats indexable
<ifreund>
cause it's not fixed size
<daurnimator>
we already have arrays in zig: [50]T
<daurnimator>
we already have vectors: @Vector()...
<marijnfs2>
wait whats that then
<daurnimator>
(they are simd vectors)
<ifreund>
maybe I'm missing something, but I never understood why c++ called arraylists vectors
<marijnfs2>
ah
<BaroqueLarouche>
vector is a terrible name for a Dynamic Array type
<marijnfs2>
damn names
<marijnfs2>
i guess vector is more mathematical
<companion_cube>
arraylist is also a terrible name, it's so nondescript
<daurnimator>
Also note.... many people are probably looking for LinearFifo rather than ArrayList
<companion_cube>
(is it an array or a list? is it a list of arrays?!)
<daurnimator>
ArrayList for FILO, LinearFifo for FIFO
<marijnfs2>
linearfifo?
<marijnfs2>
damn
<marijnfs2>
i mean it sounds funny
<companion_cube>
why not just Stack?
<ifreund>
stack implies that random access is forbidden
<ifreund>
at least to me it does
<companion_cube>
does it?
<marijnfs2>
yeah i guess array is already used for [], vector is for math
<marijnfs2>
so not much left
<companion_cube>
ifreund: to me `list` implies it's a linked list, so… 🤷
<marijnfs2>
to me too
<marijnfs2>
but i guess we are biased
<ifreund>
hey I'm not saying ArrayList is perfect, but I don't think Stack is better
<companion_cube>
I mean, there's only one clear implementation of a stack :)
crimson_pingvin has joined #zig
frett27_ has joined #zig
<companion_cube>
arrayList sounds like some weird java contraption
<marijnfs2>
i guess there are still a lto of choices how you would allocate
dch has quit [*.net *.split]
letoram has quit [*.net *.split]
cncl has quit [*.net *.split]
meowray has quit [*.net *.split]
crimson_penguin has quit [*.net *.split]
Flaminator has quit [*.net *.split]
crimson_pingvin is now known as crimson_penguin
dch_ is now known as dch
<marijnfs2>
companion_cube: that is true
cncl_ is now known as cncl
letoram has joined #zig
<marijnfs2>
I didn't mind buffer, but maybe termination could be a parameter
<marijnfs2>
Buffer(Terminated)
<shakesoda>
oh we're bikeshedding today
<shakesoda>
put me down for DynamicArray
frett27 has quit [Ping timeout: 256 seconds]
<marijnfs2>
thats not a bad name
jjido has quit [Ping timeout: 246 seconds]
<companion_cube>
DynArray? :p
[1]MrMobius has joined #zig
MrMobius has quit [Ping timeout: 256 seconds]
[1]MrMobius is now known as MrMobius
<ifreund>
hey, that's prettty good
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
<fengb>
"The name list is also used for several concrete data structures that can be used to implement abstract lists, especially linked lists and arrays." so sayeth Wikipedia
<fengb>
I have no idea why I'm using middle english
dingenskirchen1 is now known as dingenskirchen
<marijnfs2>
list is used for structures that implement lists
<andrewrk>
you're highlighting the fact that while Wikipedia can be perceived as a source of authority, such authority may be questioned as possibly being outdated or applying to another time or circumstances
<marijnfs2>
nice wikipedia
lrosa007 has joined #zig
return0e_ has joined #zig
<fengb>
"In computer science, a list or sequence is an abstract data type that represents a countable number of ordered values, where the same value may occur more than once."
<fengb>
I shoulda injected more satire. so sayeth the infallible Wikipedia
<marijnfs2>
lol
meowray has joined #zig
<fengb>
Maybe call it ArraySeq and LinkedSeq. Confuse everybody :P
<Snektron>
ContinuousAreaOfMemory
<fengb>
Is it really area if it's 1 dimensional? 🤔
<mikdusan>
UnpackedAlignedStretchOfItems
<Snektron>
Or just not export them as a name, but rather provide a function to select the properties you want
<marijnfs2>
i'd rather just std.Map(std.LinearTime)
<marijnfs2>
shakesoda: lol
nephele has quit [Read error: Connection reset by peer]
nephele_ has joined #zig
plumm has joined #zig
<plumm>
andrewrk: are there any plans to add @line() & @file() builtins?
_Vi has quit [Ping timeout: 250 seconds]
lrosa007 has quit [Quit: Leaving.]
<shakesoda>
i wonder if blender's build stuff respects CC/CXX
<Kingsquee>
BaroqueLarouche: @.@
<shakesoda>
seems like a good large thing to attempt to compile with zig
<Kingsquee>
companion_cube: yes, I've been trying to write it in rust but it's been going fairly poorly due to the hacky nature of type-level numerics
<Kingsquee>
I have an idea for a sort of allocation-centric form of "compile-time floating point ops" using fixedpoint that might make them a lot easier to use in practice
<Kingsquee>
tldr just allocate the maximum number of bits for int or frac that the operation could return, based on the number of int and frac bits of the values you're working on
<Kingsquee>
frac bits can easily be infinite, so we'd just keep them at the user-specified amount, but int bits tend to grow or shrink in an expected way, so might be able to remove some of the cognitive overhead of fixedpoint
<Kingsquee>
ye I'm pretty pumped ))
frett27_ has quit [Ping timeout: 240 seconds]
<Kingsquee>
also zig has native fixedpoint on the roadmap, and has ops like `+` and `%+`, which fit the floating_add and fixed_add split pretty well
<plumm>
andrewrk: i asked because i was thinking about doing the logging module stuff and wanted a way of determining package
<pixelherodev>
Could just look at the stack trace?
<pixelherodev>
Cache address -> file/line
<pixelherodev>
So that if you e.g. have a log call in a hot loop, it only looks it up in source info once
<pixelherodev>
Also, I second (third? Fourth?) DynamicArray as a good name
<shakesoda>
this is the chance! break every single zig program by renaming it on 4/1, so people think you're kidding!
<shakesoda>
:D
<mikdusan>
andrewrk: do you have an existing qemu-static tarball for CI?
ur5us has quit [Ping timeout: 252 seconds]
<pixelherodev>
I second shakesoda's proposal!
<pixelherodev>
I had a suggestion for a bigger joke, but then I realized that it's a terrible idea to toy with people's compilations for a prank
<pixelherodev>
"What did you do for April Fool's Day?" "I deployed a trusting trust compiler that causes all binaries to randomly display skull GIFs!" "wat"
<ifreund>
might as well do all the breaking at once
<fengb>
We gonna Thompson hack the Zig compiler?
<pixelherodev>
I mean, the license does say "no warranty is implied," right? What are they going to do, *stop* using a compiler that messes with their binaries?
<pixelherodev>
oh right
ur5us has joined #zig
ifreund has quit [Ping timeout: 256 seconds]
<andrewrk>
mikdusan, no; we use apt-get to install it currently