a_chou has quit [Remote host closed the connection]
nephele_ has joined #zig
<mkchan>
let's say i have a List generic type with size and i've instantiated 2 derived types: List(i32, 5), List(u64, 6). Now obviously the size 5 and 6 respectively are known at compile but if i create pub consts to store them, i can't access them as members. i don't want to store them as data members
nephele has quit [Ping timeout: 272 seconds]
nephele_ is now known as nephele
<mkchan>
storing them as data members does work, however. so these are values tied to the derived type not the objects. equivalent would be c++'s template class static constexpr members
<mkchan>
do i have to do reflection hackery to get them?
<andrewrk>
you're sorta asking about how to do stuff in terms of types but it might be more valuable to think in terms of data
<andrewrk>
I read your question but I don't know how to help, I don't really understand what you're trying to do
<mkchan>
let me give an example: https://godbolt.org/z/PWffdn look at line 8. If i change that to a data member, the program works
<mkchan>
but i never need that information at runtime, so i would rather it be tied to the type
<andrewrk>
I see
<andrewrk>
oh I think you just want [@TypeOf(self.layers[layer_index]).layer_size]
ur5us has quit [Remote host closed the connection]
ur5us has joined #zig
<andrewrk>
at least it compiles if I do that on line 39
<mkchan>
yes, that compiles. Great
<mkchan>
ok that's not even inconvenient! thanks a lot
<andrewrk>
looking back at the question, now it makes sense. sometimes these simple concepts can be hard to explain, heh
<andrewrk>
fyi we call that "declaration" vs "field"
<andrewrk>
e.g. @hasDecl and @hasField
<mkchan>
yeah, i suppose i'm not familiar with the jargon so i try to explain my concept
<andrewrk>
fair enough :)
<mkchan>
https://github.com/ziglang/zig/issues/4960 - i'm hoping my code gets reduced to this eventually and can take the benefit of matrix mult optimizations. the LLVM builtin matrix type
<andrewrk>
hmm do some processors have matrix instructions?
<andrewrk>
ah SpexGuy has a detailed writeup on this
<mkchan>
at least GPUs do
<andrewrk>
that's relevant; it's at least planned to have a SPIR-V backend for zig
nvmd has quit [Quit: Later nerds.]
xd1le has quit [Read error: Connection reset by peer]
gazler_ has joined #zig
xd1le has joined #zig
gazler has quit [Ping timeout: 264 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
xd1le has quit [Read error: Connection reset by peer]
keegans has joined #zig
xd1le has joined #zig
xd1le has quit [Remote host closed the connection]
xd1le has joined #zig
<keegans>
andrewrk: back with some sanitizer support that I think will be more useful than the last time around: https://github.com/ziglang/zig/pull/6362. will be here if you want to discuss informally
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
ifreund has quit [Ping timeout: 256 seconds]
ifreund has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
fgenesis has joined #zig
* ikskuh
waves fgenesis
<fgenesis>
hOI
Akuli has joined #zig
factormystic0 has joined #zig
factormystic has quit [Ping timeout: 244 seconds]
factormystic0 is now known as factormystic
oxymoron93 has quit [Quit: Connection closed]
mokafolio has quit [Quit: Bye Bye!]
xd1le has quit [Ping timeout: 240 seconds]
mokafolio has joined #zig
xackus has joined #zig
xd1le has joined #zig
llamalord9 has joined #zig
llamalord9 has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
cole-h has joined #zig
xackus has quit [Ping timeout: 272 seconds]
xd1le has quit [Read error: Connection reset by peer]
xd1le has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
cren has quit [Quit: WeeChat 2.9]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
waleee-cl has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
wootehfoot has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
xackus has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
<marler8997>
pixelherodev, coincidentally, that bug I created is actually helping me experiement with a feature where we don't use an ELF interpreter
<marler8997>
if you come up with a fix, how would I get back to the current behavior? I tried removing the .interp section after the fact but that doesn't seem to work
<marler8997>
I wonder if we would need an option to explicitly disable the interpreter?
<pixelherodev>
Probably
<pixelherodev>
For what you want, we can just have addSharedLibrary set dynamic = true - or even just error out if it's false
<marler8997>
is_dynamic seems to only apply to libraries, not exes
<andrewrk>
it does apply to exes but there is some logic
<andrewrk>
which actually is getting reworked a bit in #6250
<andrewrk>
in summary: we try to make things as static as possible, unless -dynamic is selected
<marler8997>
andrewk, since your here, after thinking on it the solution I've thought of is just to move Zig's "find linker logic" into the runtime executable
<marler8997>
then reinvoke yourself with that linker
<nikki93>
is it possible to reuse zig's comptime evaluation code for ... runtime evaluation of zig within my program
<nikki93>
like as a way of scripting or such
<nikki93>
or does that not make sense
<bfredl>
why not?
<bfredl>
std.zig will be the entire compiler right, when stage2 is "ready"
<pixelherodev>
Not quite.
<pixelherodev>
stage2 isn't part of stdlib.
<andrewrk>
marler8997, interesting! I like where this is going
<andrewrk>
that's a really cool idea
<marler8997>
it's really simple once you think about it, just find the linker at runtime instead of link time...
<nikki93>
is the zig comptime evaluator component for the released versions of zig written in zig or in c++
<andrewrk>
that would even do the appropriate libc startup right? I think you may have just solved static binaries for linux video games
<pixelherodev>
I wouldn't be so sure
<marler8997>
so long as our logic to find the linker doesn't use libc :)
<pixelherodev>
Finding the linker is only one of the issues there
<marler8997>
which I think it does currently, so that would need to be fixed
<marler8997>
basically, each exe functionally acts as its own dyanmic linker, of course, they aren't full blown linkers, they just find the real linker and call execve again
<pixelherodev>
LibExeObjStep.make passes `-dynamic` if is_dynamic is set, so it just sets that on anything which is linked against a dynamic library
<andrewrk>
nikki93, c++
<pixelherodev>
The other thing it should probably check is what's linking against a shared library
<pixelherodev>
If it's a static library, it should probably panic
<andrewrk>
bfredl, std.zig only has some stuff; most self-hosted compiler code will not be shipped in std
<nikki93>
oh got it. do you think in the first body of work toward self-hosting you'll make some amt of zig eval easily available for programs to use at runtime?
<andrewrk>
no that's out of scope
<pixelherodev>
and I'm not convinced zig would be a good scripting lang anyways.
<nikki93>
hehe yeah
<andrewrk>
marler8997, if you do a proof of concept that does an opengl triangle window and provide a static linux binary that works on Ubuntu, Alpine, and NixOS, that would be big news
<marler8997>
pixelherodev, no dice
* bfredl
is gonna use zig as a scripting lang in neovim anyway
<andrewrk>
opengl hello world triangle (or vulkan, whatever)
<pixelherodev>
... I should probably test it locally but I'm technically kinda busy now but I couldn't resist tweaking ZBS some more :P
<marler8997>
exe still doesn't have an interpreter
<andrewrk>
marler8997, I'm excited about this, feel free to ping me with updates :)
<marler8997>
cool, I've been thinking about this problem for years...will be cool if we actually come up with something
<andrewrk>
hell yeah
<andrewrk>
I think the /usr/bin/env trick is quite reliable
<andrewrk>
it's basically a symlink to the real system dynamic linker
<marler8997>
yeah that was clever
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
codemessiah has joined #zig
zippoh has quit [Remote host closed the connection]
wootehfoot has quit [Read error: Connection reset by peer]
zippoh has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
a_chou has joined #zig
marnix has quit [Ping timeout: 265 seconds]
a_chou has quit [Remote host closed the connection]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
xackus has quit [Ping timeout: 246 seconds]
mokafolio has quit [Client Quit]
xackus has joined #zig
mokafolio has joined #zig
codemessiah has quit [Quit: Leaving]
Akuli has quit [Quit: Leaving]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
ur5us has joined #zig
reductum has joined #zig
CodeSpelunker has joined #zig
<jjsullivan>
andrewrk, I'm trying to get the zig toolchain cross-compiled in void linux's repos. I think your bootstrap script had most of the info needed to do it, but I'm running into some linker trouble. Do you think you'd know something about this? https://github.com/void-linux/void-packages/issues/24959
<jjsullivan>
also, does the host `zig` compile stage0 in your script as well? For now I could only get it to work with cross-gcc, cmake complained zig didn't know about a `-march=armv8a` option
<andrewrk>
looks like it's missing some linker args like -ldl and it's missing the cmake option to disable libxml
<andrewrk>
hmm I think zig cc doesn't recognize -march yet?
<andrewrk>
it's redundant with -target and -mcpu
<andrewrk>
(should be done though, that's a missing feature)
<jjsullivan>
ah okay, I'll give changing the linker/llvm opts a try. Idk if I can disable the XML stuff though, not sure if other packages depend on that. Can it be turned off from zig's cmake?
<jjsullivan>
also cmake did report supported `-march` options, idk if that was a bug or not
<andrewrk>
zig has no dependency on the xml stuff and really nothing to do with it
<andrewrk>
I think if you run `llvm-config --system-libs` or something like that it might spit out all the missing libs
<andrewrk>
for me it prints `-lz -lrt -ldl -lpthread -lm` for your config it will probably include -lxml
<jjsullivan>
yeah, I think void's packing llvm10 in it's entirety, I get a blank line on my box
<andrewrk>
anyway point being that dependency comes from LLVM so it's kind of a question for the llvm project how to properly link in their dependency
<jjsullivan>
it seems unlikely that anyone depends on llvm's libxml specifically, but you never know :^)
<andrewrk>
it sounds like a packaging mishap if `llvm-config --system-libs` doesn't resolve this for you
<andrewrk>
I'm not super pleased at how much weird dependencies llvm has
<andrewrk>
IMO compiler backends should strive for no dependencies
<jjsullivan>
yeah, this will make the review more complicated by defauly
<andrewrk>
even c++ is a pretty heavy weight dependency :-/
<jjsullivan>
**default
<jjsullivan>
but at least we know what's causing the problem
mokafolio has quit [Quit: Bye Bye!]
<jjsullivan>
time to build llvm10 for the 5th time :^)
mokafolio has joined #zig
<andrewrk>
godspeed
<andrewrk>
and then you'll get to figure it out all over again with llvm11 coming out in a few days!
nephele has quit [Ping timeout: 260 seconds]
<mkchan>
Is there a feature in zig where I give the compiler a program that's sort of metaprogrammed with inline whiles and such and it spits out the "unrolled" code
msingle has joined #zig
<mkchan>
Unrolled zig code that is, not llvm ir or asm
<jjsullivan>
andrewrk idontfeelsogood
<andrewrk>
mkchan, that feature does not exist
<andrewrk>
you could look at the output LLVM IR or machine code
<andrewrk>
or zig ir
<andrewrk>
it's done at the zig ir level though, it's not done at the source level
<mkchan>
I was thinking it might help debugging
mokafolio has quit [Quit: Bye Bye!]
<mkchan>
But thanks, I usually stick some comptime asserts though like you had suggested earlier
<andrewrk>
nikki93, the API is pretty nice, I don't think there is anything tricky about it. If I had to guess I'd say they are trying to avoid binary bloat
<andrewrk>
squeek502, ah, thanks for the followup!
<nikki93>
@andrewrk binary bloat due to different codegen per value type?
<nikki93>
(just clarifying)
<andrewrk>
right, that would be my guess without looking too closely
<nikki93>
i see
<andrewrk>
that's potentially something the hash map impl could do itself
<andrewrk>
or maybe even the compiler 🤔
<nikki93>
that'd be cool. i guess the impl could just shell out to another impl that just uses the size of the elems right?
<andrewrk>
auto bloat reduction from generic instantiations is something I want to look into
<andrewrk>
right
squeek502 has quit [Quit: Leaving]
squeek502 has joined #zig
CodeSpelunker has quit [Quit: CodeSpelunker]
xd1le has quit [Read error: Connection reset by peer]
squeek502 has quit [Client Quit]
squeek502 has joined #zig
xd1le has joined #zig
layneson has quit [Ping timeout: 260 seconds]
xd1le has quit [Read error: Connection reset by peer]