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/
<andrewrk> marijnfs, look what lib/std/os.zig does, the first test in the file at the top
<marijnfs_> andrewrk: ok, so the @import on a file directly seems to include it?
<andrewrk> yes if you @import a file then the tests in that file will be scanned. but `zig test` won't chase imports that aren't referenced
<marijnfs_> I added an import for my serialization file, and also for serialization.zig and i see the tests seem to have issues
<marijnfs_> so and @import("file.zig").SomeStruct wont do it right?
<andrewrk> if @import("foo.zig") gets analyzed then the tests from foo.zig will get picked up
<andrewrk> this has the potential to modify `zig test` behavior
adamkowalski has joined #zig
<marijnfs_> interesting
<marijnfs_> yeah i noticed the tests of serialization.zig didn't run (added an expect(false))
<marijnfs_> maybe thats on purpose though
<andrewrk> yes. lazy decl analysis is a strength and a weakness
<marijnfs_> ok cool. Im adding some serialization for arrays and all that. I need to serialize chats, so structs with []u8 and all that
adamkowalski has quit [Ping timeout: 250 seconds]
r4pr0n has quit [Quit: r4pr0n]
recombinant has quit [Read error: Connection reset by peer]
r4pr0n has joined #zig
MajorLag has joined #zig
MajorLag is now known as tgschultz
<andrewrk> damn I'm a bit behind on issues for the release
<pltrz> when is the release scheduled for?
<andrewrk> april 13
<pltrz> cool stuff; thanks
<pltrz> man I wish I were a more experienced programmer to help and get more involved
<andrewrk> pltrz, start simple! there are lots of interesting projects you can work on to learn more
<andrewrk> try to do this: https://www.learn-c.org/ and then do the code examples in zig too
<pltrz> tahn
<pltrz> that's a great idea!
<pltrz> never thought to translate simple programs to practice :)
adamkowalski has joined #zig
<adamkowalski> andrewrk: would it be possible to have "lazy" keyword in zig? That way you could implement "if" in userland by having a function which takes a condition and two lazy parameters, and then you evaluate the parameter depending on the value of the conditional
return0e_ has joined #zig
return0e has quit [Ping timeout: 250 seconds]
marijnfs_ has quit [Quit: Lost terminal]
r4pr0n has quit [Quit: r4pr0n]
redj has quit [Read error: Connection reset by peer]
redj has joined #zig
pixelherodev has quit [Quit: ZNC 1.6.2 - http://znc.in]
<mikdusan> ugh I can't remember, was `zig0 test -mcpu=baseline --dynamic-linker myfoo.zig` supposed to let zig0 run a test? I get: "Unable to get native target: unrecognized architecture"
adamkowalski has quit [Quit: Lost terminal]
ifreund has quit [Ping timeout: 240 seconds]
gpanders has quit [Ping timeout: 265 seconds]
gpanders has joined #zig
junon has quit [Ping timeout: 264 seconds]
marijnfs_ has joined #zig
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #zig
marijnfs has quit [Ping timeout: 240 seconds]
sorenbug has joined #zig
<sorenbug> Shoutouts to me `/join`ing `zig` and not `#zig`
<sorenbug> Trying to use a Rank-2 type causes zig to not work: https://mystb.in/ewosuzemip.zig
nephele has quit [Ping timeout: 256 seconds]
nephele_ has joined #zig
wootehfoot has joined #zig
wootehfoot has quit [Ping timeout: 265 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
wootehfoot has joined #zig
sorenbug has quit [Ping timeout: 240 seconds]
ur5us has quit [Ping timeout: 256 seconds]
pixelherodev has joined #zig
suppi has quit [Ping timeout: 240 seconds]
<watzon> Found an interesting bug in zig cc where I'm getting a core dump in a simple C program
<watzon> I don't get the core dump when it's compiled with gcc
<watzon> Basically just compile this with zig cc https://github.com/Leandros/PackCC
<watzon> Then try to use it to compile this grammar https://gist.github.com/watzon/4adfb3c63c5285ca8b29b4d6cb704af7
<watzon> A grammar with a single expression compiles, but with multiple it breaks
urluck has quit [Ping timeout: 246 seconds]
urluck has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
<mikdusan> watzon: can you paste the result of `zig targets` somewhere? also confirm `zig cc` and executing on same host?
wootehfoot has quit [Ping timeout: 250 seconds]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
frmdstryr has quit [Ping timeout: 240 seconds]
<pixelherodev> CMake isn't finding the Clang libraries on my new Gentoo build :(
<pixelherodev> Is Clang supposed to be version 9 or 10?
<pixelherodev> LLVM 10 is detected, so I built Clang 10 too...
suppi has joined #zig
dingenskirchen has quit [Read error: Connection reset by peer]
dingenskirchen1 has joined #zig
<pixelherodev> Guess I'll have it build Clang 9 overnight and try that in the morning
<pixelherodev> Well
<pixelherodev> Later in the morning
<pixelherodev> It's already three :(
dingenskirchen1 is now known as dingenskirchen
dddddd has quit [Ping timeout: 250 seconds]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
_Vi has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
<wilsonk> pixelherodev: are you trying to build zig master as of today? You need llvm/clang/lld 10 for that (so not sure why you are trying 9)
<wilsonk> watzon: did you get any further on that packcc error?
wootehfoot has joined #zig
wootehfoot has quit [Client Quit]
nephele_ is now known as nephele
<wilsonk> watzon: it appears that zig cc is perhaps defaulting to some stricter casting checks or something. There is a 'ud2' illegal instruction being inserted into the function 'hash_string' in packcc.c when zig cc is run. This illegal instruction has two ops after it that designate the __file__ and __line__ of the issue (I can't seem to see those values in gdb though)...anyways, after hash_string iterates over 5 incoming letters of the string to
<wilsonk> The fix: change the 'h' variable in hash_string to a long and then cast to an int for the return (ie. int i=0; long h=0; ... return (int)h; ). That should fix things but I am not exactly sure how to fix the overall problem or if andrew would still prefer this stricter check on casting?
return0e_ has joined #zig
<wilsonk> watzon: then your test grammar should work and the example at the bottom of the packcc documentation also works
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
return0e has quit [Ping timeout: 250 seconds]
dermetfan has joined #zig
gazler has quit [Quit: Leaving]
ur5us has quit [Ping timeout: 256 seconds]
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
marijnfs has joined #zig
marijnfs has quit [Quit: leaving]
marijnfs has joined #zig
marijnfs1 has joined #zig
<mq32> hey
r4pr0n has joined #zig
slowtyper has quit [Ping timeout: 240 seconds]
ur5us has joined #zig
<wilsonk> hey mq32
<wilsonk> a little late, but... :)
ifreund has joined #zig
ur5us has quit [Ping timeout: 240 seconds]
_Vi has joined #zig
lunamn has quit [Quit: Ping timeout (120 seconds)]
lunamn has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
_whitelogger has joined #zig
TheLemonMan has joined #zig
marijnfs2 has joined #zig
marijnfs1 has quit [Ping timeout: 264 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
dingenskirchen has quit [Ping timeout: 240 seconds]
mahmudov has quit [Ping timeout: 265 seconds]
<pixelherodev> wilsonk, I was trying nine because CMake failed to find 10 :(
<wilsonk> pixelherodev: failed to find it in /usr or /usr/local? I always build and install in /usr/local and it seems to work, that is why I mention it...but I assume it is in /usr on Gentoo
<pixelherodev> Yeah
<pixelherodev> Works on my laptop, too
<pixelherodev> But that's using 9 still?
<pixelherodev> Weird
<wilsonk> you are on master as of today and it builds with llvm-9?
<wilsonk> You must have a 10 lying around if that is the case because llvm-10 is required as of 2 days ago
<pixelherodev> I have 10 installed
<pixelherodev> *and* 9
<wilsonk> oh, I see
<pixelherodev> So my guess is it's still allowing the old paths because the right version is also lying around
<wilsonk> hmm, can you retarget the output dir of the build to /usr/local easily on Gentoo without having to rebuild the whole llvm suite?
<pixelherodev> I don't think that's the issue, because I think I found it
<pixelherodev> Even on my laptop, Clang 10 doesn't have as many libraries showing up locally
<wilsonk> oh, do you have some dynamic llvm libs and some static?
<pixelherodev> That's the thing, they're all dynamic
<pixelherodev> 15 files in /usr/lib/llvm/10/lib64; *421* in 9/lib64
<wilsonk> because on MacOS they dynamic libs for clang and lld were picked up instead of the static ones I had...just mentioning
<wilsonk> whoa, that seems strange
<pixelherodev> On a different note, if I wipe the build/ folder I had and set up cmake from scratch, it errors out expecting LLVM 10
<pixelherodev> Yay?
<wilsonk> hmm, can you remove llvm-9 (ie. xargs rm < install_manifest.txt)? I assume you still have the build around? Or maybe not
<wilsonk> I have llvm/clang/lld-8 and 9 and 10 all built on each of my machines and then just overwrite when moving up in versions if there is an error...or remove all and then just install the one version I need to test zig, then install the older versions using my package manager. That way zig always picks up the /usr/local version and any other programs that need 8 or 9 can still pick them up from /usr. This assumes one has enough disk space on
<pixelherodev> I installed nine after it didn't find ten :(
<wilsonk> via Gentoo's build system or your own, so you could install to /usr/local (not that it should really make a difference with Gentoo, I suppose...just seems really weird that there are so few libs for 10)
mahmudov has joined #zig
<pixelherodev> I'm 99% sure that won't do anything
<wilsonk> ok, I am not a Gentoo guy so I am just taking shots in the dark anyways ;)
dingenskirchen has joined #zig
<marijnfs> Hi, i made a pull request to expand the serialization capabilities, is that how I should do it? https://github.com/ziglang/zig/pull/4824
rzezeski has quit [Quit: Connection closed for inactivity]
dddddd has joined #zig
mahmudov has quit [Ping timeout: 240 seconds]
mahmudov has joined #zig
<pixelherodev> I think Clang 10 has BUILD_SHARED_LIBS turned off in Gentoo...
<pixelherodev> Going to manually tweak that and rebuild :(
<pixelherodev> After much tweaking and annoyedly updating the hash, it's building with -BUILD_SHARED_LIBS=on
<pixelherodev> The problem isn't on Gentoo's end, it's on Zig's AFAICT: the recommended build model by LLVM upstream is to have a single giant library instead of a bunch of small ones, but Zig doesn't know how to link against just -lLLVM
<pixelherodev> Correction: Clang, not LLVM
<fengb> Oh it changed in LLVM10?
waleee-cl has joined #zig
<wilsonk> hmm, interesting
mattmurr has left #zig ["Kicked by @appservice-irc:matrix.org : issued !quit command"]
<TheLemonMan> llvm-config should just work™
<jwh> aww, LoLa-native doesn't build for me
<andrewrk> zig does know how to link against just -lLLVM
<mq32> jwh: What's the problem?
<mq32> and yes, the build process right now is hacky a.f.
<jwh> it dumps me out at unreachable
<jwh> /usr/lib/zig/std/debug.zig:228:14: 0x23a4cb in std.debug.assert (build)
<jwh> if (!ok) unreachable; // assertion failure
<mq32> can you send me the stack trace in query?
<jwh> yeah sec I'll put it up
<jwh> oh I see, looks like libc maybe
<mq32> more the libc++ probaby :D
<jwh> lols
<mq32> but this looks like it's actually the libc
<mq32> what OS are you?
<jwh> abyss, experimental distro, musl+llvm
<mq32> ah
<mq32> hm, then somebody else has to help :D
<jwh> just need something to package to make test zig, scripting seemed like a useful one to consume
<jwh> s/make/help/
<jwh> is it a hard dep on glibc?
<mq32> nah, but i depend on libc++
<mq32> on the system-libc++
<mq32> but that should not care for the libc type
<mq32> looks more like the build system fails to recognize musl
<jwh> its bailing on that
<mq32> this will be the culprit
<jwh> ah hm
<mq32> but i think you have to explicitly state what OS your targeting
<mq32> try to remove this
<mq32> i have arch and i had problems with a glibc-version too high
<mq32> but could be that this enforces glibc to be used instead of musl
<jwh> looks like it
<jwh> if I handhold it a bit, it tries to build but can't find stddef.h, weird
<jwh> I don't know enough about zig to fix it :P
<mq32> hrhr
<mq32> i'm waiting for #4827 to be merged, then this can be simplified and should be the usual zig experience: "just works"
<jwh> well
<mq32> right now, using C++
<jwh> using exe.linkLibC(); instead does the right thing
<mq32> ah, good to know :D
<mq32> is a semi-supported usecase :D
<jwh> but I dunno whats up with the headers
<jwh> its almost like its ignoring /usr/include, even though -I /usr/include exists on the cmd
rzezeski has joined #zig
<pixelherodev> andrewrk, I know
<pixelherodev> `<pixelherodev> Correction: Clang, not LLVM`
<pixelherodev> Either it doesn't know about -lclang-cpp, or my system is even more broken than I realized
<mq32> btw, jwh: what exactly did bring you to compile LoLa? :D
<jwh> checked the list of community projects on the wiki, seemed the most useful to package first :P
<mq32> haha :D
<mq32> it's by far not ready to package or something like that :D
<jwh> well, to have something in-tree it needs to have a consumer otherwise its liable to rot
<jwh> soooo
<jwh> scripting is an obvious choice
<mq32> but it's not general purpose scripting :D
mokafolio has quit [Quit: Bye Bye!]
<jwh> well sure, but it looked enough to write at least hello world in
mokafolio has joined #zig
marijnfs2 has quit [Ping timeout: 250 seconds]
<mq32> but it's meant for a very specific use case (scripting in gaming where the player writes the code)
<mq32> so it's "hardened" against endless loops and such
<mq32> yeah, true
<mq32> and doesn't allow too generic code :D
<jwh> its the only one that looked like it could really be runtime tested easily (does it output string X? y/n)
<shakesoda> you can harden lua against that stuff reasonably easily
* shakesoda hasn't read full context, yet
<mq32> shakesoda: with suspending the lua code and resume it later?
<mq32> at any place?
<mq32> even in FFI functions? :D
<fengb> Suspend resume... you taking advantage of Zig async? :P
<mq32> no, definitily not :D
<mq32> it's a simple state machine system
<mq32> so async functions run framewise
<mq32> every frame i call some "process" and check the return value
<shakesoda> you can yield the vm wherever you can hook it, but that excludes when you're inside code that lives outside of the lua vm
<shakesoda> so, not c api or ffi functions
<mq32> yeah
<mq32> Something like "Sleep(100)" should not block
<mq32> The idea is that the scripting allows finegranular execution slices
<mq32> "Please execute 500 instructions or until yield"
<fengb> Ah okay, basically a consistent frame loop
<fengb> I suppose that makes sense for a game heh
<mq32> yeah
<mq32> bad when the player does while(true) { }
<mq32> and your game freezes
<mq32> also it's meant for high parallel count of VMs
<fengb> Just put it on a different thread!
<mq32> doesn't help when you want to limit "execution per frame"
<mq32> :D
<mq32> so you can deploy hunderts of computers in game that all run some cool scripts and interact with each other
<fengb> Like... minecraft but for programs?
<mq32> kinda?
<fengb> So nothing like minecraft
<fengb> I dunno why I mentioned minecraft lol
<mq32> If you want to see the idea of this in an actual game, look at `else Heart.Break()`
<mq32> they kinda had the idea right
<shakesoda> https://github.com/shakesoda/tinyfx/issues/35#issuecomment-605083186 tinyfx's zig wrapper is committed now, although it's certainly not well formed to be used like a library or anything just yet
<pixelherodev> So you mean like... what's it called... GreenArray?
<fengb> I'm curious if we can auto-translate common C patterns into Zig patterns
<fengb> Fake namespacing into real namespacing, making actual methods, etc.
<ifreund> that would be pretty neat, sounds non-trivial though
<fengb> Yeah and probably not good for std, since it's all a bunch of handwavey heuristics
<mq32> fengb: i think the other way round would be cool as well
<mq32> const ns = struct { pub export fn someapi() void { } }
<mq32> =>
<mq32> extern void ns_someapi();
<shakesoda> would @divTrunc or @divFloor be the correct conversion for integer division in c code
<mq32> yes
<fengb> I believe C spec is divFloor
<mq32> depending on what you want :D
dirkson has joined #zig
<shakesoda> I'm converting some C code and want to be sure I got it right
<shakesoda> with what it did to begin with
<fengb> Oh shoot I’m wrong. It’s truncate towards 0
<shakesoda> trunc, then?
<ifreund> trunc is the c spec yes
<dirkson> Hey all. Do we have any benchmarks for zig as a build system? I've got some vague curiosity.
<shakesoda> thank you
<mq32> dirkson: in what terms?
<dirkson> mq32: Tup, for example, does a lot of database storage and is crazily fast as a result - a rebuild with no changes is basically instant, it handles huge numbers of files with slow linear performance degredation, etc
<mq32> yeah sounds like zig build :D
tane has joined #zig
<mq32> note that if you compile a project with libc
<mq32> zig build compiles the whole libc
<mq32> (or, rather: zig compiles the whole libc)
<mq32> and it's done "instantly" when finished with that once
<dirkson> Interesting
<mq32> huh what's that link? :D
<dirkson> Does the zig build system have a usable way of pulling in non-zig-build dependencies? I.e. Can I reasonably include a project built with cmake or [insert build system here] as a dependency for my project?
<mq32> yeah, you can
<mq32> eerm, dunno about the link r4pr0n
<mq32> dirkson: you can execute arbitrary commands in zig build and then depend on files output by them
<dirkson> mq32: Great
<mq32> so call cmake, premake, gnumake, then link everything together with zig build
dermetfan has quit [Quit: WeeChat 2.7.1]
<dirkson> I kinda figured that'd be the answer, but it's easy to ask before I invest a bunch of time
<dirkson> I don't see a 'zig build clean
<ifreund> r4pr0n: maybe you're looking for https://apt.llvm.org
<ifreund> rm -r zig-cache
<dirkson> Awesome
dermetfan has joined #zig
<watzon> mikdusan: Here's the output of `zig targets` https://gist.github.com/watzon/3f57e2b8f0961329a162e04a3de39581
<watzon> I know for a fact it was using `zig cc`. I used it directly.
<dirkson> So Zig is still on 0.5. Are there any portions of the language that are promised to be stable as of now?
<mq32> dirkson: "rm -rf" does the job :D
<mq32> dirkson: on perf of building stuff with zig
<mq32> [felix@denkplatte-v2 demo]$ time zig build-exe -lc --c-source src/main.c -target aarch64-linux-musl
<fengb> Nothing is promised to be stable until 1.0
<mq32> real0m54,338s
<mq32> real0m0,181s (second run)
<r4pr0n> but can i install them on any distribution? ifreund
<r4pr0n> i'm not using a debian based system
<mq32> user time is about 0.07s
Akuli has joined #zig
<fengb> But other than the new anon function syntax, I don't think there's any other big breaking change that's scheduled
<ifreund> r4pr0n: you may be able to get binarys from there to work, or just wait for your distro to package llvm 10
<dirkson> mq32: Yeah, that's how I clean my tup builds. Theoretically I wouldn't ever need to do that if my entire build environment was managed by tup, but it turns out operating systems are a thing and sometimes you really do need to clean
<ifreund> or compile yourself of course
<r4pr0n> yeah i'd like to do that, but my cpu isn't powerful enough, it takes very long
<dirkson> mq32: I'm assuming that horribly slow first build speed is just zig compiling all the 'system' dependencies, like libc?
<mq32> yep
<mq32> that first build was "make compiler_rt, musl-libc and my code for aarch64-linux"
<mq32> second build was "check everything"
<dirkson> mq32: Mind changing something in main.c and re-timing for me?
<dirkson> Do we have windows/osx cross compiles for C compiles yet?
<mq32> real0m0,214s
<mq32> dirkson: doing a win64 build right now, same program
<mq32> [felix@denkplatte-v2 demo]$ time zig build-exe -lc --c-source src/main.c -target x86_64-windows-gnu
<mq32> real1m14,417s
<mq32> real0m0,128s
<mq32> second time is fast again :)
<mq32> is cross compiling C to mac supported?
<dirkson> 200ms seems long for a small change. Although checking, my meson/ninja/script takes 400ms for a similarly small change, and I don't notice that, soooo whatever!
<fengb> It should be
<mikdusan> watzon: ok thanks; yup I get illegal instruction on my host too
<mq32> dirkson: 95% of the time is disk I/O ;)
<mq32> fengb: don't see a libc for mac though
<watzon> Interesting case. Probably an easy fix, but I wouldn't know where to start.
<fengb> Oh yeah, that's not ready yet
<mq32> cross-compiling zig code to mac works
<dirkson> I don't think I have a working c-based tup build at the moment. Although an unchanged build for tup is real0m0.004s and a single source file change is 0m0.088s, that's almost certainly just capturing compilation time
<dirkson> mq32: That's a cool metric. It could still be doing unnecessary IO though
<fengb> We had some questions about header licensing. I found a dumb header <stdint.h> that was actually private
<mq32> i don't think so, andrew is pretty proud of his caching system
<mq32> also: zig checks about 2k files when doing a cross build :D
<dirkson> Like, a 'correct' build the way zig does it is to check every single built library file every time it builds, but those files are only likely to change when zig is updated.
<mq32> yeah
<mq32> but then it also only builds those files that have changed :)
<mq32> and you are free to mutate your libc in any way you want
<dirkson> Right, but it might still be hashing them each time
<mq32> and still get safe and stable builds
<mq32> nope, i'm sure it does not :D
<dirkson> I think it's probably More than fast enough for my purposes, based on your tests, so I'm doing more devil's advocate than anything at the moment :)
<mq32> hrhr :D
<dirkson> Do you know if I can build without compiler-rt and libunwind, offhand?
<mq32> i think so
<mq32> but compiler-rt is required for working builds
<mq32> but it's not included in static libraries by-default
<mq32> but for executables and shared objects
<pixelherodev> Nope, I was right; Zig doesn't know about -lclang-cpp
<pixelherodev> Building the individual libraries got it detecting Clang
<dirkson> compiler-rt seems to do a lot of things, most of which aren't needed for many builds - i.e. your release build probably doesn't need profiling and asan hooks most of the time. Does it also do things that are absolutely required?
<TheLemonMan> yes
<dirkson> (Also I've got no idea what apple's 'blocks' is, and I distrust it because it says apple and I am some sort of stodgy foss man)
<TheLemonMan> it contains a lot of builtins that llvm (and also GCC) expects
<TheLemonMan> eg. some 64bit math ops for some 32bit targets
<mq32> btw, i random thought i had:
<mq32> is it sane to allow zig building the whole libc with -flto?
<mq32> this would allow some crazy cross-file-inlinings
<dirkson> Yeah, I saw that specific bit, lemon, but figured that not everyone was building for 32 bit targets (I'm usually not)
<andrewrk> mq32, I don't see any reason that shouldn't work
<mq32> i can imagine that would speed up the final executable by a lot
<andrewrk> not sure it would help much though, libc is ABI-bound
<TheLemonMan> it contains several other builtins that are not related to the target being 32 or 64 bits
<mq32> if everything is compiled LTO, it could ignore ABI-boundaries
<mikdusan> when using `zig cc` how do I specify -mcpu=baseline or something to make it just minimal x86_64 ?
<dirkson> TheLemonMan: Yeah, I was slowly working that you based on your responses :)
<TheLemonMan> you can get rid of compiler-rt if you manage to avoid referencing any builtin, but that's hard
<dirkson> Fair
<andrewrk> mikdusan, need to add -mcpu -march etc support, these flags aren't recognized by zig yet
<andrewrk> mikdusan, if you pass `-target x86_64-foo-bar` it will be baseline though
<dirkson> As usual with Zig, I am Fairly Impressed by the build system and C compilation.
<mq32> the whole project is amazing :)
<mq32> thumbs up for andrewrk! \o/
<dirkson> Agreed
rappet has quit [Ping timeout: 246 seconds]
<dirkson> Do we have any ideas about what priority the package manager project has? I think that's the last major feature I'd really want out of a build system.
<andrewrk> I think there's a good chance we'll have some kind of working version in the next release cycle
<andrewrk> be warned I said the same thing when 0.5.0 was released 6 months ago
<dirkson> (My current solution to this is just a bash script that downloads all the dependencies and sticks them where the build system expects them. This is not exactly portable or elegant or hard to break)
<andrewrk> I just built llvm with CXX=`zig c++ -target aarch64-linux-musl`
<dirkson> Well that sounds impressive
<mq32> this is crazy! :D
<fengb> So we are self-hosted? 🙃
<pixelherodev> Not quite
<andrewrk> not so fast, still have to build clang and lld
<andrewrk> but https://github.com/ziglang/zig/issues/853 is quickly becoming a reality
<pixelherodev> It's self-hosted as a C++ environment, not yet as a Zig one
rappet has joined #zig
<mq32> pixelherodev: still something!
<pixelherodev> True
<dirkson> The mere fact that you're within spitting distance of some version of self hosting is impressive in and of itself
<mq32> this means you can download a precompiled tarball, the sources and start hacking zig
<fengb> I'm mostly joking :P
<mq32> no need for complicated cross-envs anymore :)
<pixelherodev> How long before either upstream Clang or someone else duplicates this work as a standalone C++ compiler?
<fengb> If they wanted to... they'd just make Clang work
<dirkson> Thanks for all the help everyone. I'm definitely coming down on the side of trying to switch a project or two to the zig build system.
<mq32> do it! :)
<mq32> i did for LoLa and it worked just the same as before
<TheLemonMan> let's scrap Zig as a programming language, people are so much enthusiast of it as a build system (and C/C++ frontend)
<dirkson> mq32: ... I may have a use case for LoLa
<mq32> TheLemonMan: I'm just enthusiast because joining zig code and cpp code will work great soon
<mq32> and i can port more parts of my code to zig! <
<mq32> *<3
<mq32> dirkson: tell me!
<fengb> We could call it giz
<fengb> ... nevermind
<TheLemonMan> how do you pronounce that? jizz?
<fengb> Hard G, duh
<ky0ko> being able to mix zig and c++ code will make it a fair bit more likely that i could get some folks at work to try zig out ...
<dirkson> mq32: Well, I'm coding a space game. One of the things I always wanted to provide the users was a scripting language to control the terminals. I considered lua, and also considered just Not Doing It, but this sounds like a neat third option
<ky0ko> us low-level embedded devs all work on c projects, but the app devs are all c++ fanatics
<fengb> You don't call it zij
<mq32> dirkson: that's exactly my use case
<TheLemonMan> mixing C/Zig was already possible, you only have to link all the objects together
<TheLemonMan> don't tell me how to pronounce zij >:
<andrewrk> TheLemonMan, don't worry, this has been the evil plan since the beginning. get c/c++ people hooked on a build system / package manager, and then oh? what's that? you already have the zig language as a dependency? might as well use it!
<dirkson> mq32: Hey, pm me, won't you?
<fengb> Embrace, extend, extinguish
<andrewrk> embrace, extend, extinguish. right out of microsoft's playbook
<ky0ko> yeah, i know c code was possible - i've been working on porting the quake 2 engine to zig as a sort of POC. but not c++
<dirkson> andrewrk: I mean, I was already interested to start with. Making the switch process easier is a bonus :)
<fengb> But this time, for good not evil™. Right??
<andrewrk> chaotic neutral
<pixelherodev> best alignment.
<pixelherodev> All that's needed is to reduce the startup times for `zig build` and I'll use it for C projects :P
<andrewrk> yeah that's a necessary ingredient
<mikdusan> watzon: opened issue: https://github.com/ziglang/zig/issues/4830
<mikdusan> heh
<fengb> Actually, I should make one of programming languages
<mq32> fengb: do you know the matrix "programmers of X seen by programmers of Y"?
<fengb> Yeah my favorite is Lisp
<fengb> Er, one of my favorites >_>
<fengb> There's a whole bucket load of them
<mq32> this one in particular
<mq32> someone has printed it and hung it in our hackerspace :D
<fengb> lol, why is Palin on the list?
<fengb> As usual, Lisp doesn't fail to disappoint :P
<mq32> no idea :D
<TheLemonMan> spreadsheet memes, nice
<fengb> I need to fill out 2 squares then put in real pictures
<fengb> But I also should be doing my day jobs
ifreund has quit [Quit: WeeChat 2.7.1]
<mq32> Lawful Evil = Ada. true as fuck
<mq32> Lawful good haskell?
<mq32> or something like prolog?
<fengb> Was targeting just low level systems languages
<mq32> ah
<fengb> Wanted to keep the domain simple or else it’s too hard to choose
* shakesoda added tinyfx to zig community projects now that it's got a wrapper in the repo
<mq32> neat!
<mq32> have to test it one day :)
<shakesoda> I think it's pretty nice, but I need to put more time into explaining how it works + examples
marijnfs1 has joined #zig
<shakesoda> perhaps some zig examples coming Soon(tm)
<mq32> yeah examples are always good :)
<shakesoda> building the zig wrapper has put some API bugs on my radar, too, mostly related to some of the types in the header being sketchy/used in sketchy ways
<shakesoda> need an allocator api, too!
marijnfs has quit [Ping timeout: 264 seconds]
<watzon> Thanks mikdusan
<watzon> I was gonna do that when I got the chance
<mikdusan> oh another question, which OS are you on?
_Vi has quit [Ping timeout: 260 seconds]
<watzon> Fedora
<watzon> Though I have debian and arch boxes as well
Kingsquee has joined #zig
* watzon uploaded a video: Screencast from 03-27-2020 12:24:37 PM.webm (152KB) < https://matrix.org/_matrix/media/r0/download/matrix.org/cJCLiSUljhpjfOIslRgumpAg >
<watzon> This is actually pretty cool
<Kingsquee> snarky compile error messages are an underrated life experience
<mikdusan> TheLemonMan: do you think we're running into an issue here with different aarch64 cpu features?
dermetfan has quit [Quit: WeeChat 2.7.1]
<Kingsquee> so in rust I use a macro to define struct-of-arrays, is there a way to do the same thing in zig using comptime?
ifreund has joined #zig
<TheLemonMan> mikdusan, no, I'm pretty sure it's a problem with the LLVM optimizer
<mikdusan> maybe relevent: "std::bad_alloc" presents for me when doing Debug build too
<TheLemonMan> that's expected, we compile compiler_rt in release mode even for debug build
<TheLemonMan> (s)
Barabas has joined #zig
<Barabas> Hello
<Barabas> I have an issue with `@cImport(@cInclude("Folder/my_file.c"))`. It says it can't find the file, but if I do `@import("Folder/my_file.c")` it can find it (it just complains that it has tabs :P)
<jaredmm> Barabas: difference between includeDir and mainPkgPath?
<Barabas> Hmm... maybe... I didn't set any includeDir or mainPkgPath and the zig file from which I'm trying to import is in my top level folder next to my build.zig
<shakesoda> i wish when i got errors like "index out of bounds" it'd tell me what the index and bounds were
<shakesoda> it... clearly knows
<TheLemonMan> yeah but formatting the error message is hard
<Barabas> Oh I had fun today, it was complaining about return types. It took me a while to figure out I was doing `try` in a function which didn't allow returning errors.
<jaredmm> Barabas: I'm assuming that @import will go based on the default root path and that @cImport doesn't do that. I've not looked into it, though.
<mikdusan> TheLemonMan: cool, I just hacked stage1 to not force release-mode on compiler_rt and the "std::bad_alloc" vanished
<shakesoda> TheLemonMan: it would just make my life a lot easier :(
<fengb> Barabas: yeah I’ve spent an hour staring at the try return mismatch before
<Barabas> I added `.addIncludeDir(".");` to my build and now it works. :)
<Barabas> Thanks guys.
<TheLemonMan> shakesoda, open a ticket (if there isn't already one), I have a feeling it may not be that hard to implement
<Barabas> fengb yeah it'd be so much better if it just said: "Can't use try in this function." or something.
<Barabas> Ah man... `@cImport` doesn't understand arrays with an undefined length. I mean this: `const unsigned data = {1, 2, 3, 4};` :(
<Barabas> oh
<Barabas> Ah man... `@cImport` doesn't understand arrays with an undefined length. I mean this: `const unsigned data[] = {1, 2, 3, 4};` :(
<fengb> Hmm that can be translated to `const data = [_]c_uint{..}`
<jaredmm> I'm pretty sure that should get translated.
<jaredmm> [4]c_uint
<Barabas> it thinks data is `[*c] const c_uint` and it says it found `[4]c_uint`
<jaredmm> Hm.
<Barabas> Didn't expect it to fail on that. :D
marijnfs has joined #zig
<TheLemonMan> andrewrk, mikdusan, I found (and fixed) the problem!
<fengb> !!
<Barabas> Or maybe I'm doing something wrong. :|
<TheLemonMan> the good news is that I'm not the one who introduced this problem :P
<jaredmm> You can initialize it with the size and it should work, but I'm not sure if this is a file you wrote or someone else wrote.
<Barabas> Someone else (some program I don't control)
<andrewrk> TheLemonMan, wow, what was it?
<fengb> Zig is doing it wrong: `pub export const data: [*c]const c_uint = [4]c_uint{`
<fengb> It thinks the variable is a pointer, not the actual array
<Barabas> ok
<Barabas> I'm making an issue :)
<fengb> Oh... it's probably reusing function syntax, where foo[] is really just a pointer
<Barabas> Function syntax? It doesn't look like a function and it understand that the array is a certain size.
<fengb> I mean in function definitions, foo(char bar[]) is translated to [*c]c_char. Zig is just mistakenly using that in this context
<fengb> Basically, I'm making excuses for why Zig isn't doing the right thing >_>
<mikdusan> TheLemonMan: awesome
<andrewrk> fengb, the code for `export` on non functions needs some attention
mq32 is now known as ikskuh
<TheLemonMan> yay, I've just finished running the test suite on the AArch64 box! it werks!
<andrewrk> wow
<andrewrk> can't wait to see this diff
<ikskuh> TheLemonMan: +1
<TheLemonMan> andrewrk, sent a PR already ;)
<TheLemonMan> speak like yoda, I must
<andrewrk> oh wow
<andrewrk> typo in the ABI definition, R.I.P.
marijnfs has quit [Read error: Connection reset by peer]
<fengb> Oh oof
marijnfs has joined #zig
idxu_ has joined #zig
r4pr0n has quit [Ping timeout: 240 seconds]
nrdmn has quit [Ping timeout: 265 seconds]
idxu has quit [Ping timeout: 265 seconds]
Sahnvour has quit [Ping timeout: 265 seconds]
r4pr0n has joined #zig
idxu_ is now known as idxu
notjones has quit [Ping timeout: 265 seconds]
dwdv has joined #zig
Sahnvour has joined #zig
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<pixelherodev> Might maintain a Zig overlay for Gentoo
<pixelherodev> Or, better yet, just patch Zig to be able to link against the distribution's LLVM and Clang packages :P
<Sahnvour> andrewrk: toying with zig c++ atm, very excited about this, could it also work as a frontend for lld ?
<pixelherodev> On the bright side, I was able to tweak the distro packages to support Zig's current configuration :)
<pixelherodev> `/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/llvm/10/lib/libclangFrontendTool.so: error adding symbols: file in wrong format` NOOOOOO
<pixelherodev> I was *so close*
<pixelherodev> Ah, that's 32-bit
<pixelherodev> Okay, next hack: move files around from where they're supposed to be :P
<andrewrk> Sahnvour, yes it is a frontend for lld
<Snektron> zig can compile c++ now?
<Snektron> Nice ork
<Snektron> work
<Sahnvour> okay, I'm trying to build a barebones sample with meson and zig as my CXX on windows, and having some linker errors
<tane> is this C++ compilation ability a required feature for any compliant zig compiler?
<andrewrk> tane, no, it's just something that this zig compiler provides since it links against clang anyway for @cImport
<tane> ok, I'm relieved :P
<andrewrk> Sahnvour, details?
<Snektron> clang should soon no longer be needed for @cImport right?
<Snektron> considering the self-hosted C parser
<andrewrk> clang does semantic analysis as well
layneson has joined #zig
<Snektron> ah right, of course
<andrewrk> the self-hosted parser is for macros
<Sahnvour> andrewrk: https://gist.github.com/Sahnvour/21c82bdd8e6ededec1c28c0375ad9999 this is with meson (mesonbuild.com)
layneson has quit [Client Quit]
dwdv has left #zig ["leave"]
<Snektron> Didn';t zig parse arguments manually?
<andrewrk> Sahnvour, "@zigcpp@exe/zigcpp.cpp.obj.rsp" what is this argument? I don't know what that is supposed to do
<Snektron> I think meson passes quotes around arguments occasionally
<Sahnvour> andrewrk: ah, that's a windowsism I guess to workaround enormous command lines, to put arguments in a file
<andrewrk> I think it's not showing the full command line that zig sees
<andrewrk> need more info to look into this
<Sahnvour> yes, gist updated
<andrewrk> ok I know what's happening
<andrewrk> zig needs to gain understanding of this @ syntax to look at command lines. because it doesn't understand it, and it's a positional argument, so it thinks its a linker object
<andrewrk> so it sends @zigcpp@exe/zigcpp.cpp.obj.rsp to the linker, but those args are for the compiler
<Sahnvour> aha
<andrewrk> mind filing an issue?
<Sahnvour> not at all
<andrewrk> the good news is I believe this can be solved entirely in the self-hosted side of things
<Sahnvour> I think it just needs to detect arguments beginning with an @ and forward them to clang, correct ? supposedly it already knows how to deal with them to get its full command line
<Sahnvour> ah but maybe zig wants to act on some of those arguments
<andrewrk> since we have to act on positional arguments, we have to know about all special positional arguments
<andrewrk> unknown stuff is already forwarded
<Sahnvour> okay
kenaryn has joined #zig
<kenaryn> fengb: Lawfull good: Erlang? Chaotic good: D ? (lot of asymmetries and frictions to make the job at all costs).
ur5us has joined #zig
<Sahnvour> also zig targets looks broken on my windows box, anyone else can try on theirs ?
<pixelherodev> Found the problem
<pixelherodev> `on my windows box` <-
<pixelherodev> /s
<BaroqueLarouche> Sahnvour: same issue on my side
r4pr0n has quit [Ping timeout: 240 seconds]
<BaroqueLarouche> ❯ zig targets
<BaroqueLarouche> unable to list targets: BadPathName
<andrewrk> hmmmm
<Sahnvour> yup
jjido_ has joined #zig
jjido_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
<fengb> kenaryn: developed at Bell Labs so not good. Dynamic type so not lawful :P
<squeek502> andrewrk, for the zig cc 'passing args to the linker' flags, do you want to pass them indiscriminately or were you thinking of parsing lld's options.td like clangs and validating the passed args?
<waleee-cl> fengb: erlang? Joe Armstrong worked at Ericsson when developing it
<fengb> Err... why did I think Bell Labs. Still... a corporate sellout 🙃
<andrewrk> squeek502, I'm thinking about handling all these manually, because I'm pretty serious about implementing an incremental linker, for compilation speed purposes
<squeek502> ah ok
<andrewrk> however for now, it's ok to handle them pretty simply, if a bit boilerplate-y. * detection in main.cpp * add field to CodeGen * add to cache hash * add to each of the 3 linker command lines in link.cpp
<andrewrk> it's a bit of boilerplate but it makes it easy to swap that component out later
<andrewrk> Sahnvour, I'm confused about the double @ in your rsp example. I actually ran into the same issue when messing with something else, but there's only 1 `@`
<Sahnvour> andrewrk: the second @ is contained in a directory name, sorry I meant to clarify this but forgot to
kenaryn has left #zig ["WeeChat 2.3"]
<andrewrk> ok thanks that clears it up
<andrewrk> I'm going to try to solve this right now because it's required for another task I'm experimenting with
<Sahnvour> great!
r4pr0n has joined #zig
Akuli has quit [Quit: Leaving]
drvirgilio has joined #zig
ur5us has quit [Ping timeout: 256 seconds]
<mikdusan> when using std api like `std.fs.cwd().readFileAlloc(...)` must the path match platform? ie. on windows backslashes?
<andrewrk> the answer to that question is not stable yet. currently I believe you'll get an error for using forward slashes
<mikdusan> on windows `zig targets` --> unable to list targets: BadPathName
<andrewrk> there are a few things that need to be improved for windows path handling. another one is allowing invalid unicode
<watzon> Thinking about doing a stream today or this weekend @and
<watzon> * Thinking about doing a stream today or this weekend
<watzon> ??
<mikdusan> nogo on windows :(
<andrewrk> mikdusan, oops
<watzon> I thought windows allowed both? Paths with forward and back slashes.
<mikdusan> in this case it's .zig code checking path
<andrewrk> well anyway there's an easy fix there; using std.fs.path.sep_str and ++
<andrewrk> that will be correct regardless of whatever ends up happening to std lib fs
<mikdusan> if my grep-fu was correct, we don't have any other things like that in src-self-hosted/*.zig so I'll make up a quick patch.
<andrewrk> thanks. and my bad, I definitely wrote all that code and the code that doesn't allow forward slashes
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<shakesoda> i don't know who needs this but have an in-place merge sort https://hastebin.com/ukabubeqeq.zig
<shakesoda> i was asked for this in zig specifically by someone elsewhere
<andrewrk> shakesoda, we have in-place sort already with std.sort
<shakesoda> andrewrk: which sort is it
<andrewrk> your implementation looks nice and small though
<shakesoda> andrewrk: this wasn't implemented to address a need, fwiw, it was just done for an example of what zig looks like
<shakesoda> one I actually need to find/implement is a radix sort, though :)
tane has quit [Quit: Leaving]
qbradley has quit [Quit: WeeChat 2.6]
<Sahnvour> mikdusan: thanks for the fix :)
<mikdusan> I'm just trying to come up with a slick test for zig targets
marijnfs has quit [Quit: leaving]
r4pr0n has quit [Quit: r4pr0n]
marijnfs has joined #zig
marijnfs1 has quit [Ping timeout: 250 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
dingenskirchen1 is now known as dingenskirchen
ifreund has quit [Ping timeout: 256 seconds]