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/
marijnfs1 has joined #zig
marijnfs has quit [Ping timeout: 250 seconds]
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #zig
<daurnimator> FireFox317: opening a file can be async on both windows and linux
<daurnimator> on linux its a new feature though :)
<daurnimator> marijnfs_: for streaming buffers you probably want LinearFifo
<Snektron> shakesoda: i implemented a (relatively) high performance radix sort in C++ for an uni assignment
<shakesoda> Snektron: is it available?
<Snektron> It's on a private repo currently, i'm not sure how to deal with the whole uni thing
marijnfs1 has quit [Quit: Lost terminal]
<Snektron> I have several implementations actually: in place and out-of-place
<andrewrk> O(1) memory?
<Snektron> in-place is O(1)
<Snektron> The problem is that you either need to pick O(1) or stable
<Snektron> stable is a very useful property for radix sort as it allows to you to process the array in steps
<Snektron> So i took a hybrid strategy for my implementation
<Snektron> You can either use the stable variant, process in groups of say 8 bits, repeatedly from array A into array B and then vice versa
<Snektron> (note that you need a small amount of additional memory, to store the prefix-sum. for an n-bit radix sort you need 2^n prefixes)
<Snektron> Or you can use the stable variant
<Snektron> In this case you need to recursively continue the process
<Snektron> I chose to first sort on 10 bits and then use a counting sort, but this was specific for sorting 32-bit ints
<Snektron> In the general case, the out of place algorithm is more efficient
<Snektron> in fact, i also implemented it on a GPU, which means its probably easily SIMD-able
<Snektron> shakesoda: i can probably soon-ish find some time to make a zig port
<Snektron> Did you want to add it to the standard library or for something else?
<shakesoda> Snektron: I wasn't looking for it in the standard library, it's useful for sorting batches in my rendering code
<shakesoda> seems rather specific use (on my part) to advocate for having it in standard lib
<Snektron> Ah cool. I think it'd be an interesting Zig exercise anyway, to port it
<Snektron> What are you making, if i may ask?
<shakesoda> Snektron: games & graphics demos, radix sorting is super useful for quickly sorting the draw keys
<shakesoda> learned this particular trick from bgfx
<Snektron> Is that sorting on gpu or cpu?
<shakesoda> on cpu, although I could totally see doing it in a compute shader if indirect drawing is being done
gpanders has quit [Quit: ZNC - https://znc.in]
gpanders has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
junon has joined #zig
Barabas has quit [Ping timeout: 240 seconds]
<junon> Evening all :)
<mikdusan> hi junon
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 264 seconds]
ur5us has joined #zig
<andrewrk> I got this all the way to successfully creating zig0, next step is to improve build.zig
<andrewrk> `zig cc` building llvm,clang,lld, and finally zig
nephele_ has joined #zig
<junon> andrewrk: got a quick guide on #4827 ? Is there updated syntax or does it work with @cImport out of the box? I want to give it a test.
nephele has quit [Ping timeout: 265 seconds]
<andrewrk> there are no plans for @cImport to support c++
<mikdusan> awesome, which means the zig.exe binary is created with llvm10 optimizer and I assume static-link of bundled libc++ sources?
<andrewrk> it's merely to expose the powers that were already latent due to linking libclang
<andrewrk> mikdusan, yes
<junon> Ah okay, makes sense. Would be kind of neat to support C++ imports. I'd never touch C++ again if I could do that.
<junon> though I know how difficult it is to do that.
<andrewrk> bootstrapping is basically done. now it's just a function of how much % is in c++ and how much % is in zig
<andrewrk> the c++ % will never be 0 because we have to wrap the LLVM, clang, and LLD C++ APIs with a C API wrapper
<andrewrk> also there's some windows COM API code for detecting MSVC that might as well stay c++. *shrug*
<andrewrk> junon, it's not really possible to use c++ APIs with a language other than c++. D can do it a little bit, but that's because D is in many ways c++++
<andrewrk> you can see why they named it what they did
<junon> We wouldn't necessarily want to do c++ in zig, though. It'd be more for compat between libs and not having to write C bindings for everything (e.g. game development would be quite annoying). I just went through my engine and about half of the libs in it would have to have C bindings if I wanted to port/rewrite the engine in Zig (hypothetically)
<junon> So as long as I can invoke things in C++ from zig with certain exceptions (e.g. no lambda support, which should be OK in most cases) then things would be fine.
<junon> Even if I have to call `.operator=()` manually or something, that'd be fine by me (since Zig doesn't do operator overloads).
<andrewrk> to use c++ code from zig you have to wrap it with a C API
<andrewrk> there's not really a way around this
<junon> I know, I'm talking hypothetical functionality.
ur5us has quit [Ping timeout: 256 seconds]
yrashk has joined #zig
layneson has joined #zig
<andrewrk> it works
<andrewrk> I did it
<andrewrk> https://github.com/ziglang/bootstrap successfully builds a static zig distribution for aarch64-linux-musl
<mikdusan> does this mean alpine docket image becomes less imporatnt?
<mikdusan> *docker
<andrewrk> yes
<mikdusan> in case you desire to avoid export CC/CXX: cmake ... -DCMAKE_C_COMPILER= -DCMAKE_CXX_COMPILER= have worked for me in the past
<andrewrk> thanks, good to know
<andrewrk> it feels weird closing https://github.com/ziglang/zig/issues/853
<pmwhite> wow, congratulations.
<mikdusan> so I have my answer ready for Q "How good is zig-cc drop in replacement?" A. "well it's good enough to build or cross-compile LLVM/CLANG/LLD" :)
waleee-cl has quit [Quit: Connection closed for inactivity]
<mikdusan> you don't see this everyday -> "andrewrk modified the milestones: 1.0.0 -> 0.6.0"
<mikdusan> ah nice! when cross-compiling we no longer build zig0
layneson has quit [Ping timeout: 256 seconds]
<pmwhite> andrewrk: do you think there is more potential for things that can be made self-hosted without requiring a C++ version? Like, I assume there will always need to be a C++ compiler and a self-hosted compiler that are separately maintained, but certain things like translate-c do not have C++ alternatives.
<squeek502> if you're asking about things that can be moved from C++ to zig, then i think the issues with both stage1 and stage2 fall under that category: https://github.com/ziglang/zig/issues?q=is%3Aissue+label%3Astage1+label%3Astage2+is%3Aopen
<squeek502> translate-c already was moved out of the C++ code: https://github.com/ziglang/zig/issues/1964
<pmwhite> translate-c does not have a C++ version, which is cool. some things cannot be that way though, such as the parser. i'm wondering if there are more things like translate-c but have yet to be made self-hosted only.
<pmwhite> maybe it's a stupid question.
<squeek502> there might be some more
<pmwhite> ahh, okay, so you did understand my initial question.
<pmwhite> cool, linking is not necessary for the bootstrap compiler.
<mikdusan> squeek502: I think your filter is "stage1 && stage2" ... just filter on stage2 for potential work in that area:
<squeek502> true, thought there might be too many false positives in there (things that are already self-hosted)
dddddd has quit [Remote host closed the connection]
ur5us has joined #zig
ur5us has quit [Quit: Leaving]
ur5us has joined #zig
ur5us has quit [Ping timeout: 240 seconds]
jjido has joined #zig
dermetfan has joined #zig
marijnfs_ has joined #zig
Kingsquee has quit [Quit: Konversation terminated!]
marijnfs1 has joined #zig
marijnfs_ has quit [Ping timeout: 240 seconds]
marijnfs1 has quit [Quit: Lost terminal]
ifreund has joined #zig
mattmurr has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ifreund has quit [Quit: WeeChat 2.7.1]
ifreund has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nephele_ is now known as nephele
knebulae has quit [Quit: Leaving]
knebulae has joined #zig
traviss has quit [Quit: Leaving]
return0e_ has joined #zig
return0e has quit [Ping timeout: 260 seconds]
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 240 seconds]
MajorLag is now known as tgschultz
dddddd has joined #zig
<Cadey> can you use `zig cc` and `zig c++` from a build.zig context?
<yrashk> Cadey: I've used `exe.addCSourceFile("src/code.c", &[_][]const u8{});`
dermetfan has quit [Ping timeout: 272 seconds]
diltsman has joined #zig
<diltsman> Given this line: try std.json.stringify(t1, std.json.StringifyOptions{}, &stdout);
<diltsman> I am getting this error: C:\Zig\zig\lib\zig\std\json.zig:2256:22: error: type '*std.io.out_stream.OutStream(std.fs.file.File,std.os.WriteError,std.fs.file.File.write)' has no member called 'Error'
<diltsman> Any ideas?
<fengb> It doesn’t take a pointer anymore. Try just stdout
<diltsman> Thanks! I missed that part of the change.
<diltsman> When I debug the program, it outputs the JSON in the debug window, but when I run it from the command line I see nothing.
r4pr0n has joined #zig
jjido has joined #zig
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marijnfs_ has joined #zig
<marijnfs_> nice zig can do c++ now?
jjido has joined #zig
mahmudov has quit [Read error: Connection reset by peer]
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 272 seconds]
MajorLag is now known as tgschultz
<fengb> How difficult would it to have a nightly arm32 build?
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<andrewrk> fengb, well within our grasp
<ikskuh> fengb: illiterate guess: looking at zig/bootstrap, not very
TheLemonMan has joined #zig
<andrewrk> drone ci is capable of arm32 builds
<andrewrk> I think it's actually improving the stage1 c++ code to be more 32 bit friendly
<andrewrk> but the motivation to do that is low, since such efforts could instead be focused on getting to self-hosted
<andrewrk> I'm not sure what ikskuh's point is
<ikskuh> andrewrk: as you can crosscompile zig now with zig, it shouldn't be that much work ^^
<andrewrk> ikskuh, ah I misread, I see
<andrewrk> the next major milestone in self-hosting will be when we do not need to cross-compile the c++ stage1 code
<fengb> Hmm if we compile it using zig, could we theoretically get rid of stage0?
<ikskuh> fengb: only if you want to lose the ability to recreate it D
<ikskuh> if you get rid of stage0, you lose the ablity to bootstrap without a zig compiler
<fengb> Not get rid of. Compile lib userland first and link it into zig0 directly without a separate stage
<andrewrk> yeah zig0 goes away after self-hosting. we'll be able to delete a bunch of glue code
<andrewrk> what zig0 buys us right now is ability to self-host *some* things in the meantime
return0e has quit [Read error: Connection reset by peer]
<andrewrk> you know what's amazing, the master branch source tarball is 0.5 MiB smaller than the 0.5.0 tarball
return0e has joined #zig
<fengb> o_O
<andrewrk> oh, that's because we don't ship LLD sources anymore
<fengb> Ah
<BaroqueLarouche> compiling zig is also faster because it doesn't need to compile lld anymore as well
mahmudov has joined #zig
<ikskuh> why isn't this necessary anymore?
<fengb> We had a patch that finally got merged upstream
<andrewrk> because we filed upstream bug reports, and sent patches, and followed up on them
<andrewrk> I believe it was TheLemonMan's patch that was the last one that finally got merged
<andrewrk> and now, the macho code of LLD will finally be maintained: http://lists.llvm.org/pipermail/llvm-dev/2020-March/139641.html
<TheLemonMan> the old mach-o linker is slated for removal, nice
tgschultz has quit [Ping timeout: 240 seconds]
tgschultz has joined #zig
jjido has joined #zig
mahmudov has quit [Remote host closed the connection]
jjido has quit [Client Quit]
jjido_ has joined #zig
diltsman has quit [Ping timeout: 240 seconds]
jjido_ has quit [Client Quit]
adamkowalski has joined #zig
<adamkowalski> How was the zig documentation generated? Do we have a tool that will let us do that for our own projects?
<adamkowalski> I ran the zig compiler with -femit-docs and it doesn't seem to pick up any of my files. It only shows the std library docs
<adamkowalski> zig test src/main.zig --cache off --verbose-link --main-pkg-path . -femit-docs
layneson has joined #zig
layneson has quit [Client Quit]
layneson has joined #zig
mahmudov has joined #zig
waleee-cl has joined #zig
<andrewrk> adamkowalski, lazy evaluation can be a bit of a problem here. you can take a look at some of the std lib files and how they intentionally reference declarations in test mode
marijnfs_ has quit [Quit: leaving]
dermetfan has joined #zig
MajorLag has joined #zig
<andrewrk> TheLemonMan, was this your bug report? https://bugs.llvm.org/show_bug.cgi?id=45078
<andrewrk> they deleted all the github issues
tgschultz has quit [Ping timeout: 256 seconds]
MajorLag is now known as tgschultz
<andrewrk> eh seems to be a solved problem anyway
TheLemonMan has quit [Ping timeout: 265 seconds]
marijnfs_ has joined #zig
Akuli has joined #zig
tgschultz has quit [Ping timeout: 260 seconds]
tgschultz has joined #zig
jjido has joined #zig
<shakesoda> re: sorting, I ended up implementing a simple radix sort last night, which works fine, although I'd definitely prefer something in-place instead
<shakesoda> i wonder if i'd see any benefit of using something similar but in-place or if i should just eat that memory cost
<adamkowalski> andrewrk: I utilize this std.meta.refAllDecls(@This());
<adamkowalski> It's been working pretty well for me as far as running all the tests. If I zig test src/main.zig it will run all 450 tests, but it seems like that's not enough for the docs?
reductum has joined #zig
<marijnfs_> i'm having some trouble with c-pointer conversion. It works automatically in a member-function, but when i call if in another file i get: error: expected type '[*c]const .p2p.cimport:11:11.struct_zmq_msg_t', found '*.p2p.cimport:8:11.struct_zmq_msg_t'
<marijnfs_> i call the same function, but one case its f(&self.my_pointer) in a member, the other is f(&my_object.my_pointer) from another file
adamkowalski has quit [Quit: Lost terminal]
marmotini_ has joined #zig
reductum has quit [Quit: WeeChat 2.7.1]
reductum has joined #zig
marmotini_ has quit [Ping timeout: 258 seconds]
adamkowalski has joined #zig
jcharbon has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<mikdusan> is it a const mismatch thing?
jjido has joined #zig
Yardanico has joined #zig
<pmwhite> I'm updating some zig code I haven't touched in a while. What happened to std.io.readLine?
<andrewrk> people were using it for the wrong use case, so I deleted it
<andrewrk> you probably want one of the functions that std.io.InStream offers
<andrewrk> that function was for the terminal prompt of a repl, not for reading a line from a stream
<marijnfs_> mikdusan: i was also thinking that, tried to make the argument const but didn't help
<marijnfs_> anyway non-const to const should not be a problem right
<ifreund> marijnfs_: do you have the code up somewhere?
<marijnfs_> ifreund: let me see how i can put it together in a friendly way
SimonN has quit [Remote host closed the connection]
<adamkowalski> andrewrk: can we run all tests that DONT match a tag?
<adamkowalski> I want to have some longer running tests, which are great to ensure a certain algorithm works properly, but it's an end to end test in a sense
<adamkowalski> I don't want to run it all the time, just maybe before a check in to master
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
<marijnfs_> ifreund: So basically, this doesn't work without case: https://github.com/marijnfs/zig-p2p/blob/messing-around/src/process_functions.zig#L71
<marijnfs_> without cast i mean
adamkowalski has quit [Quit: Lost terminal]
<shakesoda> anyone have a workaround for cimports that pull in win32 stuff erroring out on LCS_sRGB nonsense?
<diginet> I have a kind of general question about the zig compiler: what strategy does it use to determine whether a value is actually resolvable at comptime? seems like it would require some kind of complex unification
<ifreund> marijnfs_: huh, yeah that's pretty weird. maybe worth opening an issue?
<ifreund> oh wait, can you try making one c.zig file and doing your imports there
<ifreund> and then include that in the other files
<ifreund> iirc I had to do that to get things working smoothly
<marijnfs_> shit double @importC of same file is an issue?
<marijnfs_> @cImport
<ifreund> not sure, but I think it's worth a try
<marijnfs_> i thought it's cached or some shit
<marijnfs_> k ill try
<ikskuh> killtry?
<ikskuh> 😱
reductum has quit [Quit: WeeChat 2.7.1]
<marijnfs_> ifreund: thats also nicer anyway to put it together
<ifreund> yeah it's quite a bit cleaner
<shakesoda> andrewrk: any chance of https://github.com/ziglang/zig/issues/4194 being worked around before release?
<marijnfs_> ifreund: ok it didn't work, but it looks nicer;)
<shakesoda> it breaks builds entirely if anything by any means ends up including the gdi header, so no winsock :\
<andrewrk> shakesoda, not from me but possibly from another contributor
<shakesoda> i'm adding a whole bunch of defines to work around it but it's frustrating
<shakesoda> andrewrk: ok, just asking
<ifreund[m]> marijnfs_: hmm, same error message?
<marijnfs_> yup
<ifreund[m]> Same numbers for the cimport type as well?
<ifreund[m]> Notice that those were different earlier
<marijnfs_> yeah saw that too
<marijnfs_> i've seen this issue before but it was confusing
<marijnfs_> what pastebin do you use here
<ifreund[m]> I like https://paste.rs
<marijnfs_> https://paste.rs/du7 is my error
<marijnfs_> .p2p.cimport:11:11.struct_zmq_msg_t and .p2p.cimport:3:15.struct_zmq_msg_t
oats has joined #zig
<gonz_> Did something change with regards to `stdcallcc`?
<ifreund[m]> Hmm I’m still reading that as these two structures have different types
<ifreund[m]> Not that there’s something wrong with the [*c] vs *
<shakesoda> ended up just copying the cimport.zig and deleting all the offending code to workaround
<shakesoda> ugly, but functional
<fengb> It’s pointing at two different types, one defined at line 3 and one at line 11
<gonz_> `callconv(.C)`, huh...
<marijnfs_> ifreund[m]: no wait, i missed some cImports. got rid of them and now it works!
<ifreund[m]> Cool, consolidation into a single @cImport is the way to go
<marijnfs_> thansk!
<ifreund> no problem
<gonz_> Ugh
<gonz_> This callconv change is a maintenance hassle
<gonz_> Was there a real point to it at least?
jcharbon has quit [Quit: Connection closed for inactivity]
<andrewrk> gonz_, you know that zig fmt fixes it for you automatically?
<gonz_> No
<gonz_> And it doesn't help when zig format seems to crash on the file anyway
<andrewrk> hmm that is surprising. would welcome a bug report for that
<gonz_> I'll see about making one
<andrewrk> thanks. but yeah instability a pretty big downside of a pre-1.0 language
<gonz_> the fix to the repo has been made
<gonz_> It's just the zig-win32 repo
<gonz_> The files are massive, obviously
marijnfs1 has joined #zig
rjtobin has joined #zig
layneson has quit [Ping timeout: 265 seconds]
marijnfs1 has quit [Client Quit]
Akuli has quit [Quit: Leaving]
marijnfs_ has quit [Ping timeout: 260 seconds]
marijnfs_ has joined #zig
<gonz_> Honestly `zig fmt` seems to just fail with either `FileNotFound` when given a file path :/
<gonz_> Normally I just trust the zig VSCode plugin and it does fine, but it crashes with these files
dermetfan has quit [Ping timeout: 256 seconds]
dermetfan has joined #zig
<gonz_> Being that zig fmt is supposed to take care of it in normal cases it's not really as big an annoyance as I thought.
<gonz_> It's just that zig-win32 is 67k lines of pathological case in one file
r4pr0n has quit [Quit: r4pr0n]
r4pr0n has joined #zig
cole-h has joined #zig
r4pr0n has quit [Client Quit]
r4pr0n has joined #zig
r4pr0n has quit [Client Quit]
layneson has joined #zig
r4pr0n has joined #zig
r4pr0n has quit [Client Quit]
<Snektron> how does zig nightly find its lib/ folder?
r4pr0n has joined #zig
ur5us has joined #zig
r4pr0n has quit [Quit: r4pr0n]
<mikdusan> zig searches from exe's dirname, and looks for `{lib,lib/zig}/std/std.zig` . if not found, checks parent dir. repeat.
r4pr0n has joined #zig
<Snektron> ah, thanks
r4pr0n has quit [Client Quit]
<mikdusan> that way it works from git workspace with "lib/std/std.zig", with a standard APP/bin,APP/lib install, and with zig's distribution where there is no "bin/" dir
r4pr0n has joined #zig
r4pr0n has quit [Client Quit]
r4pr0n has joined #zig
darithorn has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<shakesoda> can i disable some of the safety features in c sources with my build.zig
<shakesoda> i'm getting some illegal instructions in debug builds for mysterious reasons (trying to use enet) that work fine in release
r4pr0n has quit [Quit: r4pr0n]
<marijnfs_> upon error i'd like to continue with the code
r4pr0n has joined #zig
<marijnfs_> how do i do that? catch printSomething(); doesn't work, catch unreachable is fine
ur5us has quit [Ping timeout: 240 seconds]
<daurnimator> marijnfs_: doesn't work how?
<daurnimator> shakesoda: sounds like enet is relying on undefined behaviour.... you might want to compare with running enet with -fsanitize=undefined
<shakesoda> daurnimator: i want the check to go away, heh, i just don't want to fight this issue right now
<shakesoda> i'll look at that though
adamkowalski has joined #zig
<marijnfs_> daurnimator: i mean i call a function bla() that could return an error.
<marijnfs_> when it does i just want to print an error, but i don't want to exit the function
<marijnfs_> that seems not possible now.
<daurnimator> shakesoda: you'll need to figure out which undefined behaviour it hit, but options like -fwrapv exist to make certain things defined