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/
frmdstryr has quit [Remote host closed the connection]
vegecode has joined #zig
<vegecode> Hello everyone, question on a good way to do something I do in C a lot.
<vegecode> I often build tables and index into them using enums. I use designated initializers to place the correct item at the correct index.
<vegecode> With this method it is very easy to do code inspections and makes the table resilient to future code changes as the position of an item in the array will automatically be corrected.
<vegecode> Is it possible to do something like this in Zig? I looked through the documentation at the array sections but didn't see anything like designated initializers.
<vegecode> Of course you can use functions to initialize an array.
<vegecode> My example array is:
<vegecode> uint8_t the_table[MAX_ENUM_VAL+1] = {[FIRST_ENUM] = 8432, [SECOND_ENUM] = 96123, [MAX_ENUM_VAL] = 0};
<vegecode> This may be an XY type of question, to be sure.
<vegecode> The real thing I'm trying to replace is something that uses the preprocessor...
<andrewrk> you can do this with `const the_table = block: { ...; break :block value; };`
<vegecode> Ahh, I actually have to go unfortunately and can't stick around to hear any responses. I will check the logs though! Thanks in advance anyone for the help, and thank you Andrew and LemonBoy in particular for being so responsive to my other issues I have filed! LemonBoy is the man (boy?)!
<vegecode> I'm not understanding what I'm looking at there, particularly the implied part behind the ellipses. Maybe this will be enough of a hint for me to figure it out though. Thanks!
vegecode has left #zig [#zig]
ifreund has quit [Ping timeout: 250 seconds]
adamkowalski has joined #zig
<traviss> vegecode i believe zig best practices would say that this is misusing enums. however it is very common and powerful in c for the reasons you stated. here are some related ideas. maybe this gets you close to what you want. https://clbin.com/96VDZ
<traviss> or without the intermediate struct https://clbin.com/4DZa9
<andrewrk> idk why you would say it's misusing enums
<andrewrk> misusing enums is using them for flags that are meant to be OR'd together
<traviss> oic nevermind then. my mistake.
<traviss> i think this last example maybe closer to your example: https://clbin.com/mefv0
<traviss> with an array rather than tuples
adamkowalski has quit [Ping timeout: 256 seconds]
adamkowalski has joined #zig
Bekwnn has joined #zig
adamkowalski has quit [Ping timeout: 256 seconds]
<Bekwnn> haven't really done much besides look around a bit at other people's code as far as zig metaprogramming goes. Was wondering if anyone can think of a good way to make this automatically populate from the one colorsRGB8 version: https://i.imgur.com/pmC0FHS.png
<Bekwnn> ie if I add an 'Orange' color to RGB8, it would automatically show up without me needing to edit RGBA, RGBA8, or RGB
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 250 seconds]
<traviss> Bekwnn, maybe store all those colors under `const AllColors = @import("Colors.zig").AllColors` in an struct as consts.
<traviss> Then you can `inline for (std.meta.declarations(AllColors) |color, i| {...}` and create the new colors.
<traviss> but this way you'd lost the ability to declare the individual identifiers and need to create an array to store them
<fengb> Can you upload the text into a pastebin?
adamkowalski has joined #zig
<Bekwnn> https://github.com/Bekwnn/Eden/tree/master/src/math top 5 files, with RGB8 being the source one for the majority of colors (but I may want to add something like "Transparent" to the RGBA8 one or other semi-transparent constants, idk
<Bekwnn> that would be more of a nice-to-have I guess
<fengb> I’d personally just define one set somewhere and probably have methods to transform them
<fengb> Feels like comptime is overkill
adamkowalski has quit [Quit: Lost terminal]
<fengb> LLVM would in-line any operations on constants anyway if you’re worried about performance
adamkowalski has joined #zig
<BaroqueLarouche> I’ll post my Colors definition it should give you some inspiration: https://github.com/mlarouche/zigimg/blob/master/src/color.zig
adamkowalski has quit [Quit: Lost terminal]
waleee-cl has quit [Quit: Connection closed for inactivity]
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
_whitelogger has joined #zig
adamkowalski has joined #zig
<adamkowalski> is there any documentation about the debug allcoator
_whitelogger has joined #zig
ur5us has quit [Ping timeout: 246 seconds]
_Vi has joined #zig
adamkowalski has quit [Ping timeout: 250 seconds]
Bekwnn has quit [Ping timeout: 240 seconds]
_Vi has quit [Ping timeout: 246 seconds]
dddddd has quit [Remote host closed the connection]
<squeek502> andrewrk, you might want to re-test zig cc with luajit, i noticed in your stream VOD that for the successful compilation you forgot to specify CC=$CC (you just ran make by itself, which used gcc and ignored $CC); not sure if itd fail with zig cc, but worth re-testing to make sure
<squeek502> direct link to the bare `make` in the vod: https://youtu.be/5S2YArCx6vU?t=9276
TheLemonMan has joined #zig
<TheLemonMan> thank you for the kind words vegecode, a smooth zig on bare metal experience is my goal :)
marijnfs_ has joined #zig
FireFox317 has joined #zig
jasom has quit [Ping timeout: 272 seconds]
jasom has joined #zig
<daurnimator> mq32: I just saw your question above: that is what I've been trying to get at with my idea of "stackable event loops"
<mq32> hey daurnimator
<mq32> good morning everybody :D
<Snektron> morning mq32
ifreund has joined #zig
_Vi has joined #zig
<FireFox317> afternoon, peeps
<ifreund> o7
mahmudov has quit [Ping timeout: 264 seconds]
<redj> problem linking zig here. compiled llvm and clang from source. zig0 won't link. probably because I don't know where CLANG_LIBRARIES and LLD_LIBRARIES should point? what am I doing wrong? -- https://gist.githubusercontent.com/redj/b298824119487db8db226320e6e58bae/raw/26e9ca4bc41e44e49230a5eee0369fa13d972d95/zig-compile.txt
dermetfan has joined #zig
<ifreund> redj: all I had to do was `CMAKE ..`, did you try that?
<redj> ifreund: I did, and then it complained about CLANG_INCLUDE_DIRS and LLD_INCLUDE_DIRS not being set... set those successfully... and then it complained about CLANG_LIBRARIES and LLD_LIBRARIES
dddddd has joined #zig
<redj> ah, I used -DCMAKE_INSTALL_PREFIX=$HOME/local -DCMAKE_PREFIX_PATH=$HOME/local for compiling llvm 10... using the same for compiling zig allows it to find the include/libs...
<redj> now, it seems I'm missing lld... it said on the wiki to compile llvm and clang but no mention of lld
<redj> lol, I guess it says in the url
<redj> just not in the posix section
<redj> it even says to add the CMAKE_PREFIX_PATH
<redj> just missing the (same) commands for lld
<redj> Built target zig0 :)
<ifreund> all I did was install clang and llvm with pacman and things worked flawlessly
<ifreund> glad you got it working
FireFox317 has quit [Ping timeout: 256 seconds]
rappet has quit [Ping timeout: 246 seconds]
rappet has joined #zig
<Snektron> I usually cheat by looking how its built in the docker files
mahmudov has joined #zig
<redj> normal build of zig is working and installs properly but I tried to build a fully static zig and it failed. did I do something wrong? -- https://gist.githubusercontent.com/redj/b298824119487db8db226320e6e58bae/raw/dbb0a70ddbc900753ff5dd43dcb21a4a8a73106f/zig-compile.txt
<redj> (94f7c5600 2020-03-22 2020-03-22 <Andrew Kelley> (HEAD -> llvm10, up/llvm10) riscv: add -mrelax arg for C to work around upstream issue)
<redj> zig build crashed :(
redj has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
redj has joined #zig
waleee-cl has joined #zig
return0e_ has joined #zig
return0e has quit [Ping timeout: 264 seconds]
layneson has joined #zig
FireFox317 has joined #zig
Snetry- has quit [Quit: left Freenode]
Snetry has joined #zig
<andrewrk> squeek502, thanks for the heads up! I did end up trying it again later and fixing a couple more problems
<andrewrk> master branch now requires llvm 10
FireFox317 has quit [Ping timeout: 250 seconds]
<andrewrk> TheLemonMan, do you think rebasing #4795 on master (with llvm 10) will solve the windows test failure?
<andrewrk> it looks like that f128 issue that is now fixed
<mq32> andrewrk: you said something about a blog post? is it released yet?
<andrewrk> mq32, give it a couple hours for the CI to make available a master branch build based on llvm 10
<mq32> okay! i'm just curious
<andrewrk> yeah I'm going to try to coincide the blog post so that it gets in the tech news right next to the llvm 10 announcement :)
<ifreund> > released 18 minutes ago < pretty on top of things lol
<andrewrk> yeah well now I get to close like 8 bugs \o/
<mq32> andrewrk: smart!
<ifreund> hah, that's the first time i've won the race to flag the arch package as out of date
<andrewrk> now I'm just waiting for the CI to make an llvm10-based master branch build on the download page, and for llvm 10 release announcement to make its way into tech news sites, then I'll publish the blog post
<andrewrk> it could potentially be an exciting day today for the zig community
<ifreund> can't wait to read the blog post, I think i'm not quite in the loop as to what llvm 10 means for zig
<andrewrk> not much, really. just a few bug fixes. I'm capitalizing on llvm/clang's popularity to get some spotlight on the zig project
<ifreund> smart move, zig definitely deserves more attention
<fengb> Oh, llvm10 has been released?
<TheLemonMan> andrewrk, let me check
<scientes> fengb, soon
<ifreund> i mean, it was tagged an hour ago https://github.com/llvm/llvm-project/releases
<fengb> mmm
<scientes> yes, I have the release e-mail too
<scientes> oh, its the github e-mail
<scientes> not the mailing list
<scientes> cause I have commit access
<andrewrk> llvm 10 tagged today and it's already 6641 commits behind master
<scientes> it didn't branch today
<andrewrk> yeah
<andrewrk> just sayin
<scientes> you are in #llvm on oftc
<scientes> you see all the action
<andrewrk> yep
<companion_cube> 6.6k commits… 😲
<TheLemonMan> and we're sitting at a measly 2k commits :(
<mq32> TheLemonMan: i think the LLVM project is a bit bigger than Zig atm :D
<companion_cube> which is a good thing
<companion_cube> that Zig isn't a behemoth
<scientes> its kinda like Linux too---where the development is on enterprise network file systems
<TheLemonMan> wonderful, today apt.llvm.org is awfully slow for me
<fengb> Throw more bodies at the problem!
<andrewrk> TheLemonMan, if you need the same workaround as the CI, here it is: https://github.com/ziglang/zig/blob/03013e517689575e6050c5c950f6d19847302b85/ci/azure/linux_script#L21-L35
<andrewrk> maybe they fixed it though. Sylvestre responded to my llvm-dev mail pointing out the problem
<TheLemonMan> I hope they fix that before the point release
<andrewrk> it's fixable without a release - it's only a problem with the apt package
<TheLemonMan> oh well, it's still waiting to be fixed
<andrewrk> I've essentially given up on depending on llvm as a package for development purposes. spent the entire weekend compiling llvm for every target
<andrewrk> if you want something done right you gotta do it yourself
* mikdusan has been building local llvm for zig forever
<TheLemonMan> that's quite disrespectful, package mantainers do a lot of (hard) work
<andrewrk> you're right
<andrewrk> that was disrespectful and I apologise
<TheLemonMan> well fuck everything, my whole internet connection is slow as fuck today
<TheLemonMan> punching the router may fix that
<andrewrk> llvm release day is an unfortunate day for slow internet connections
<andrewrk> damn we beat the release announcement email
jcharbon has quit [Quit: Connection closed for inactivity]
FireFox317 has joined #zig
<FireFox317> so andrewrk, it will be clear why you added the __clear_cache compiler-rt when you publish your blog?
<andrewrk> FireFox317, probably not, since adding that actually allowed me to delete a section from the blog post :)
<andrewrk> __clear_cache is part of compiler-rt. it would have been added before zig 1.0 anyway
<andrewrk> __clear_cache was the only addition needed to compiler-rt to successfully cross compile LuaJIT for aarch64-linux-gnu
<companion_cube> reading your tweets, andrewrk: in deflate, maybe there's len + nlen just for redundancy reasons?
<FireFox317> andrewrk, hahah ahh nice :)
<BaroqueLarouche> Checking that the block is ok for a non-compressed block
<companion_cube> this LiteralLengthTable could be comptime generated, couldn't it? :
<companion_cube> :p
<companion_cube> waiiit no
<BaroqueLarouche> it is
<BaroqueLarouche> there's no rule for that table
<BaroqueLarouche> there's no rule for that table
<BaroqueLarouche> but for the fixed huffman coding I do generate the table in comptime
<companion_cube> yeah at first I thought it was a table of primes, my bad
<andrewrk> companion_cube, yeah, old school compression stuff often had these. I think it was a mistake to put integrity checks in-bound. that's a job for an out-of-bound system. but people didn't understand this back then, I guess
<BaroqueLarouche> btw the RFC for DEFLATE is so useless, that article about Zip file was so helpful
adamkowalski has joined #zig
<andrewrk> the one by Hans Wennborg right? that's the release manager for llvm btw
<BaroqueLarouche> Yup
<andrewrk> yeah that article is fantastic. it took me a week to read it
<andrewrk> this content is excellent
<scientes> huffman?
<scientes> JPEG uses huffman too
<scientes> zstd is more interesting
<fengb> You've implemented deflate? Upstream that! :)
<Snektron> thats a long post
<BaroqueLarouche> @fengb: that’s the plan!
<scientes> but in terms of pre-zstd there is also 7zip/lzma/xz
<BaroqueLarouche> Waiting to have the encoder to submit it in the std lib
<fengb> 👍
<BaroqueLarouche> I hope JPEG will be fun to implement
<scientes> what do we gain by implementing these things in zig?
<TheLemonMan> good timing, do you also have an inflate implementation?
<scientes> it seems to me it would just increase maintinance
<fengb> andrewrk: is it possible to import variables in wasm? I couldn't figure out how to get lld to ignore extern variables
<scientes> over just using the C
<BaroqueLarouche> TheLemonMan: only inflate for now
<TheLemonMan> scientes, dogfooding
<scientes> something that would be cooler would be to implement these things with a RPC over shared memory
<scientes> so as to protect for security problems
<TheLemonMan> BaroqueLarouche, cool, I was about to port Zlib's puff.c to Zig
<companion_cube> scientes: or in a sandbox, like wasm ;)
<scientes> more like seccomp mode 1
<scientes> wasm is just slow-box
<scientes> not a sandbox but a slow-as-sand-box
<companion_cube> I didn't know seccomp, it looks like capabilities?
<scientes> companion_cube, it limits system calls
<scientes> so you set it up, and then you turn off system calls except for futex()
<andrewrk> fengb, I'd be happy to take a look at this with you if you can help me understand the situation
adamkowalski has quit [Ping timeout: 256 seconds]
<andrewrk> scientes, I'm pretty sure we'll want inflate at least in the std lib because of package manager. the current plan is that the package manager's base set of "download plugins" will depend only on std lib
<scientes> well yeah I get inflate
<scientes> but more difficult stuff like libjpeg, I just don't see why
<andrewrk> yeah, a lot of stuff from std lib will get deleted before 1.0, the only purpose is dogfooding as TheLemonMan said
<scientes> ah ok
<andrewrk> "deleted" meaning, anyone is free of course to take over maintenance and make it a third party package
<BaroqueLarouche> yeah image support doesn't belong in std
<scientes> BaroqueLarouche, well i'm talking about the algorithmic complexity
<TheLemonMan> a-we-some, LLVM10 doesn't fix the other vector-related problems in #4737
<andrewrk> damn
adamkowalski has joined #zig
<fengb> andrewrk: ^ trying to import a global value
<andrewrk> let me fiddle with it
<fengb> Also I just realized we can't import memory like this. Probably need to expose lld's `--import-memory`
adamkowalski has quit [Ping timeout: 240 seconds]
<andrewrk> for what it's worth, wasm is generally still experimental, meaning if you submit pull requests and tell me that it's an improvement, I'll believe you and merge it without vetting it too much
<fengb> I think we need a few more users to test these things out :P
mmx870 has quit [*.net *.split]
SimonN has quit [*.net *.split]
SimonN has joined #zig
mmx870 has joined #zig
<companion_cube> scientes: but seccomp is linux only though, isn't it?
<companion_cube> the stdlib should at least have json and deflate, yeah, otherwise how do you do the package manager? :D
<andrewrk> PSA: if you want your zig project listed in the "Active Open-Source Projects Using Zig" section of the 0.6.0 release notes, make sure https://github.com/ziglang/zig/wiki/Community-Projects is updated to include your project by the end of next week
marijnfs1 has joined #zig
<ifreund> hmm, I hope I'll have something worth listing by then
<mq32> really looking forward on the thing with libc++, then i can remove more dependencies in my pet language
<shakesoda> there's a good chance I'll have my tinyfx wrapper public by then
<mq32> nice!
<shakesoda> for all, i dunno, one (including myself) people interested in gl4+zig lol
<TheLemonMan> many vector-related errors are linked to Zig generating weird-ass layouts (eg. v4xi5)
<mq32> shakesoda: tinyfx is an OpenGL 4 loader?
<shakesoda> no, it's a declarative style mid-level rendering library, so you can focus on the graphics techniques you are implementing instead of the dark arts needed to make opengl do the work for you
<mq32> ah
<shakesoda> similar idea to bgfx and very similar api, but much smaller in scope
<mq32> then i'm a dark magician
<mq32> really dark magic
<mq32> i have a nice terrain demo with a lot of grass
<shakesoda> I won't claim it is thoroughly battle tested, but my games have been using it for a while and it really makes wrangling the GPU a lot easier
<mq32> and a friend asked me: "how do you store the vertex data" :D
<shakesoda> mq32: did you answer "I don't"?
<mq32> yep ^^
<shakesoda> that's the spirit
<mq32> why _store_ vertex data when you can _generate_ vertex data
<mq32> the thing runs blazingly fast on my iGPU
<TheLemonMan> "I download if from the cloud every frame"
<TheLemonMan> that's the right answer
<shakesoda> we're going to get along well, it seems
<mq32> can you link the source, shakesoda? would still take a look
<shakesoda> there's a lot of ways to improve it, and in the future I want to make a vulkan (or webgpu) port
<shakesoda> the zig wrapper is largely done and i've been using it in my sandbox, makes the c api (which is usually decent feeling) feel very clunky
<mq32> btw, that's my terrain stuff :D
<shakesoda> you're blowing way too much of your frame budget on that grass ;)
<mq32> i know :D
<shakesoda> i've got some of these, what approach did you end up taking?
<shakesoda> these kinds of demos are really fun
<mq32> approach: "no LOD, tons of geometry shader code, fancy terrain sampling"
<companion_cube> a remake of total annihiliation in zig? 🙃
<companion_cube> oh, a imgui overlay
<BaroqueLarouche> mq32: Nice!
<shakesoda> GS, the frame time burner
<mq32> companion_cube: nah the screenshots are C++
<companion_cube> arf
<mq32> shakesoda: yep, but using compute+buffers would be slower on iGPUs
<companion_cube> it looks good though
<shakesoda> mq32: it's not though
<companion_cube> I'd love to see a minecraft remake in Zig
<shakesoda> source: did it
<shakesoda> although, ymmv
<shakesoda> my general experience with igpus is that all my compute techniques seem to run unnaturally fast compared to my expectations
<shakesoda> GS does happen to perform well on intel though
<shakesoda> https://twitter.com/shakesoda/status/884821108532273152 this one is still my favorite, this doesn't show the full grass range, but this whole implementation was a ridiculous amount of brute force
<fengb> If I add wazm, I might be motivated to make it do something
<shakesoda> the grass scattering was completely on the cpu in lua(jit), rendered with love, heh
<fengb> Or be a big disappointment to the community :P
<shakesoda> for how amazingly dumb it was, it worked really well
<mq32> shakesoda: yeah, i was trying to do a full-shader-approach
<mq32> the cool thing is: the grass is always scattered around the camera
<mq32> fixed-position though
<shakesoda> mq32: i just wanted to mock my stupid idea for grass in the least appropriate tool possible
<mq32> heh :D
<mq32> how do you render it?
layneson has quit [Ping timeout: 260 seconds]
<shakesoda> a billion draw calls, give or take
<mq32> ah
<mq32> the scene you see above is 4
<shakesoda> later I moved it to all instancing
<mq32> or actually, 3 draw calls
<shakesoda> so it went from something like 10000 draw calls of the clumps to one
<mq32> :)
<shakesoda> it's on my near term weekend plans to do a new impl of grass that's actually decent by generating the draws/instance data in compute
<mq32> i watched a talk on nvidia mesh shaders these days
<mq32> this is the awesome new tech i want to have on my iGPU :D
<shakesoda> after that screenshot all the way back in 2017 i didn't actually need grass for a long time
<mq32> i have to learn how to use compute actually :D
<shakesoda> yes, do!
<shakesoda> compute is *wonderful*
<mq32> so, properly use compute for rendering, not for computing :D
<shakesoda> I use it for all kinds of things, but my favorites are the realtime spherical harmonics updates from the cubemap probes and the skeletal animation
<shakesoda> the latter because doing it in compute means i was able to remove all knowledge that it's even happening from the rest of the pipeline
<mq32> that sounds nice
<shakesoda> big simplification, deduplicated the work when things happened in several passes, and just plain faster and easier to understand
<mq32> i have an engine protoype lying around that is modelled after Gamestudio A8/Acknex A8
<shakesoda> it cost some memory, but not in practice a meaningful amount
<mq32> provides a lot of modern APIs through a simple C API
<mq32> and i learned a lot about how to actually code an engine :D
<mq32> afk
adamkowalski has joined #zig
<shakesoda> oh, if you're getting into compute, definitely look into doing tiled lighting with it (i.e. tiled/clustered forward or deferred rendering - whichever is appropriate for you)
<shakesoda> tiled forward rendering is a *lot* more practical than deferred anything on igpus
<ifreund> andrewrk: by the way, it looks like I do need c pointers here https://paste.rs/OMg
<ifreund> would that be considered a bug?
<ifreund> for reference i'm assigning the function to .notify of this struct https://gitlab.freedesktop.org/wayland/wayland/-/blob/master/src/wayland-server-core.h#L397
<TheLemonMan> just make the first fn argument nullable
<ifreund> ok yeah that works, idk what I expected
<ifreund> I guess I can't tell the compiler that the C library guarentees that it won't be null
<TheLemonMan> yeah, translate-c cannot (yet) read the documentation :P
<andrewrk> but there is an idea for that! https://github.com/ziglang/zig/issues/2457
<ifreund> neat, it seems there's alreay an issue for everything :D
<andrewrk> ideas are cheap
<companion_cube> https://frama-c.com/acsl.html <-- an existing annotation language for C, btw :)
<companion_cube> far too overkill for c-translate, but anyway
marijnfs1 has quit [Ping timeout: 250 seconds]
adamkowalski has quit [Ping timeout: 246 seconds]
blueberrypie has quit [Quit: leaving]
marijnfs1 has joined #zig
blueberrypie has joined #zig
<scientes> companion_cube, doesn't clang do many of the same things?
<scientes> (which we use)
<companion_cube> idk
<companion_cube> it certainly doesn't do formal proofs, but I don't know if it has its own annotation language
<scientes> it also is good enough for a compiler
<scientes> that people use
<companion_cube> I mean, a compiler for a cursed language :)
<scientes> what is better than C?
<companion_cube> zig, so far
<companion_cube> (and, to my taste, almost every existing language)
<scientes> even C++?
* scientes likes C
<scientes> it gives you freedom
<andrewrk> assembler gives you even more
<scientes> which every other language takes away for some silly reason or another
<scientes> but you can just put inline assembly into C
<scientes> including asm goto now
<companion_cube> clearly i'd prefer C++ to C
<scientes> which lets you patch in a goto into your running code
<companion_cube> I mean, I don't need that, but if you do I get that C is your jam
<scientes> C is really great as a easy-mode assembler, and I've even used it that way
<scientes> as then you don't have to assign registers
<companion_cube> I mean yeah, if your choice is between C and asm, sure
<scientes> you get to use the register allocator
<companion_cube> if it's between high level languages and C…
<scientes> yeah, if you are just putting together a web site, C is horrible
<scientes> but if you have some idea for an algorithm, then often I'll try some language only to realize it is IMPOSSIBLE
<scientes> I mean, I can do the algorithm, but not get the assembly to look anything like it should
adamkowalski has joined #zig
<scientes> (that said, there are a few cases of this in C)
<companion_cube> assuming your algorithm is small enough that you care to look at its full asm, yeah
<scientes> mostly having to do with function pointers, a problem that zig does not have
<scientes> companion_cube, even without looking at it---like some data structures you can't do
<scientes> like @fieldParentPtr doesn't work in many languages
<companion_cube> right, yeah
<companion_cube> and some other structures are terrible to write in C 🤷
<scientes> (although @fieldParentPtr() remains to have some performance issues and foot-gun problems in zig)
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<scientes> companion_cube, I've only seen virtual machines done in C
<scientes> although those are always hard to read
adamkowalski has quit [Client Quit]
zfoo has quit [Read error: Connection reset by peer]
<companion_cube> yeah, I'd say it's among the acceptable use cases for C :)
ur5us has joined #zig
frmdstryr has joined #zig
<marijnfs1> what do i need to compile from llvm 10?
<marijnfs1> clang;clang-tools-extra?
<andrewrk> it's documented in the readme
<andrewrk> and the wiki
<BaroqueLarouche> lld
mahmudov has quit [Ping timeout: 240 seconds]
<marijnfs1> yeah the readme points to the wiki
<marijnfs1> but it doesn't use the llvm-project repo right
<marijnfs1> lld got it
<scientes> including the lld development headers
<FireFox317> 🎉
<mq32> 🎉🎉
<FireFox317> That's a party popper emoji ^^
<BaroqueLarouche> 🎤⬇
<andrewrk> it would be sweet if this made it onto hacker news and reddit
<andrewrk> now I just have to figure out wtf is going on with drone CI before I get caught for saying it works with musl and the download tarball isn't caught up to master
<jwh> heh, in the process of trying to ditch drone
<andrewrk> it's not drone's fault, I was able to reproduce the problem
<andrewrk> nice, it's on lobste.rs
* companion_cube pleads guilty
<fengb> andrewrk: where do you learn to write well?
<andrewrk> aww thanks for the compliment
adamkowalski has joined #zig
mikdusan has quit [Quit: WeeChat 2.6]
<companion_cube> no one put it on HN yet?
marijnfs1 has quit [Read error: Connection reset by peer]
<jaredmm> If I have a cimport file that needs to reference a compiler_rt builtin...how would I do that?
<mq32> andrewrk: > print(3 + 4)
<mq32> i feel honoured :D
<andrewrk> hahah yes thanks for that
<andrewrk> damn I forgot to give shout outs to people who helped me when I was streaming
<squeek502> return 3 + 4 would have also worked btw
<jaredmm> Generate an extern function and that's all?
<andrewrk> good to know
mahmudov has joined #zig
<andrewrk> alright, it's hit critical mass. enjoy the media day, everyone :)
<companion_cube> is 0.6 for today then?
<andrewrk> no that's april 13
<andrewrk> I'm not sure I understand your question
<companion_cube> heh I thought you were trying to have 0.6 coincide with llvm 10, sorry
<andrewrk> we need a couple weeks to fix bugs and work out the kinks
<andrewrk> it would be a little risky to release immediately
<via> man, you're at the top of hn, congrats
<andrewrk> thanks to zig contributors! this work is just a little layer, revealing to the world what we've been slowly building up over time
<Cadey> andrewrk: shitty idea: could you use `zig cc` as a drop-in replacement for the system compiler on something like Gentoo or NixOS?
<ifreund> can llvm compile the linux kernel yet?
<ifreund> well i'm pretty sure it has, but idk if it's as painless as doing it with gcc
<andrewrk> Cadey, yes
<andrewrk> I mean there are some follow-up issues to solve first, but the idea is fundamentally sound
<andrewrk> the nixos clang package requires nix-specific patches, however zig cc does not need such patches on nixos
<daurnimator> ooo, I open HN this morning and I see zig :)
<andrewrk> media day today! enjoy
<fengb> Good morning!
<daurnimator> also I see we updated to llvm 10..... I need to figure out how to actually get that working :(
mikdusan has joined #zig
<daurnimator> I've never managed to compile my own LLVM and get it working with zig
<FireFox317> daurnimator, for me that has been a really easy task
<FireFox317> on arch linux btw
<fengb> How do you know if someone is running Arch? 🙃
<daurnimator> FireFox317: cool; got instructions?
<shakesoda> fengb: easy, they will tell you
<shakesoda> fengb: easy, they will tell you
<FireFox317> daurnimator, well basically cloning `llvm-project` checking out release/10.x then building llvm, clang and lld by going into the dirs, making a build dir, from the dir run `cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/dev/zig/local -DCMAKE_PREFIX_PATH=$HOME/dev/zig/local -DCMAKE_BUILD_TYPE=Release` and `make install -j(nproc)`. To build llvm you also need `-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="AVR" -DLLVM_ENABLE_LIBXML2=OFF`. When all that is
<FireFox317> build (takes some time), you can build zig using `cmake .. -DCMAKE_PREFIX_PATH=$HOME/dev/zig/local`
<FireFox317> maybe a pastebin would have been better here, but really just following `https://github.com/ziglang/zig/wiki/How-to-build-LLVM,-libclang,-and-liblld-from-source#posix` works perfectly fine
<mq32> andrewrk: blog entry is well written!
<ifreund> alright, I think I've done my job evangelizing in the HN comments
<fengb> The Zig post now has more HN points than LLVM
<andrewrk> thanks mq32
<andrewrk> ifreund, yeah be careful doing that too much. your comments are nice tho
<andrewrk> we don't want to be accused of being an evangelism strike force
<mq32> hey that article is top-item on hackernews :D
<ifreund> andrewrk: It's certainly a fine line to walk, I'll make sure to keep it in check, was mostly joking about the evangelism part
<frmdstryr> https://godbolt.org/z/CvdDEY I think this could use a better error
<marijnfs_> lets write some reddit bots in zig
<mikdusan> daurnimator: script for archlinux to build llvm10: https://gist.github.com/mikdusan/04ac65f51473c9f29c722a86e93cef2c
<mikdusan> needs git/cmake/ninja-build installed
<mikdusan> adjust vars for your preferred locations: __PROJECT, __LLVM_INSTALL_ROOT, __LLVM_PRODUCT
<FireFox317> mikdusan, ha thanks, thats why easier than my explanation xd
adamkowalski has quit [Quit: Lost terminal]
marijnfs_ has quit [Quit: Lost terminal]
FireFox317 has quit [Ping timeout: 240 seconds]
<pmwhite> I may be wrong, but I had the impression eventual independence from LLVM was desirable, but it looks like with all the `zig cc` stuff, that's not true. How do any eventual plans with zasm fit in? Maybe that's just another option that could be used (if zasm ends up being faster, for example).
<Snektron> hm
<mq32> pmwhite, to my understanding, zig cc is required for bootstrapping the compiler
<mq32> but the long-term plan is to get rid of LLVM as a compiler infrastructure and make the code generation self-hosted as well
<fengb> LLVM will not be a part of the language spec but it’ll probably remain a part of the reference implementation
<Snektron> `zig asm` to replace nasm when
<andrewrk> pmwhite, my plan is for llvm+clang+lld an optional set of dependencies (either all 3 or none), which will provide things such as `zig translate-c`, `zig cc`, `@cImport`, etc. It will also be possible to build the self-hosted zig compiler without these dependencies, and it will be compliant with the zig specification, but it will have fewer backends available and the toolchain will be missing some commands
<andrewrk> the toolchain is not part of the zig language specification. for example you don't have to implement `zig cc` to implement the zig language according to spec. it's just a nice feature that this particular zig compiler exposes
<fengb> What's with people in general confusing language syntax with semantics? :/
<Snektron> Trying to use zig cc to compile my os for fun
<mq32> fengb: But "var i : i32 = 0;" is just not "int32_t i = 0;" !
<Snektron> interesting, as clang itself was not able to
<andrewrk> damn, I cannot reproduce the "bad alloc" from the drone ci failure outside docker
<companion_cube> I think zig will have serious street cred as a "C replacement" the day there's also a gcc based implementation :s
<mq32> companion_cube: which version do you mean?
<mq32> arm-none-eabi-zig?
<mq32> x86_64-linux-gnu-zig
<mq32> ?
<mq32> *grin*
<companion_cube> the second one
<companion_cube> well, the *-*-gnu-zig family I guess
<Snektron> hm, i just found an issue in clang
<Snektron> Apparently inline assembly doesn't track whether its intel syntax or not
<Snektron> Sad
dermetfan has quit [Ping timeout: 272 seconds]