<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.
<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.
<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.
<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
<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
<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…]
<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
<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