<vegecode>
Can someone please help me. I've tried everything I can think of to make this work.
<vegecode>
I can't find any examples of something similar in the standard lib
<vegecode>
Holy shit I think I just got it finally. It's literally been days.
<vegecode>
Jesus. Got it finally.
<emekankurumeh[m]>
I was planning on working on an inflate/deflate implementation but then zig broke on my system and upgraded to llvm8
<vegecode>
I'm working off the static-base:llvm8-1 docker image. You can override the entry point and mount a volume in the container to access the files. That seems to be easier then trying to get all the dependencies working on your own laptop.
<scientes>
It does not include functions, variables, or constants.
<scientes>
ahh
Ichorio has joined #zig
<scientes>
it seems that the imported file really is an empty struct, without anything in it ?????
<andrewrk>
what are you trying to do?
<scientes>
call a function only if it exists
<andrewrk>
why?
<scientes>
Well that is a differn't issue, but here it goes....
<scientes>
Linux process initialization includes a bunch of stuff, including environment variables, above the stack. If you use a beforeMain() to get what you want from this, you could re-use all this, instead of wasting all this space (about 2 pages on my Ubuntu machine, and a long file name would make that 4, because argv[0] is in there twice)
<scientes>
actually, I just realized such a feature would go against one of the zig rules: no hidden control flow
darithorn has quit [Read error: Connection reset by peer]
<scientes>
a simpler thing would just be to call memunmap() on the memory, instead of jumping the stack backwards
darithorn has joined #zig
<scientes>
Linux will _eventually_ swap it, but it takes a while
<andrewrk>
it's planned to be able to access the root source file with @import("root") or something like that. and then I think also planned is something like @hasField, which would exist because scanning over @typeInfo is O(N). combining these features pub fn panic can move to become a userland concept, and userland could introduce other things like this
<andrewrk>
does that fit your use case?
<scientes>
yes
darithorn_ has joined #zig
<scientes>
I'm revamping the startup code cause it could be leaner, but doing this beforeMain() thing would make it quite a bit leaner
<scientes>
but maybe it would be rejected, because it is a second "special" function in root, and kinda goes against the hidden control flow rule
<scientes>
but yeah, the @import("root") would allow it in user-space, instead of only in special/bootstrap.zig
<andrewrk>
you can always provide the _start symbol yourself and bypass main. I believe this even works with build-exe
darithorn has quit [Ping timeout: 250 seconds]
<scientes>
it could easily be done after main()
<andrewrk>
how is it leaner? it unmaps memory?
<andrewrk>
so leaner in terms of resident memory, is that what you're talking about?
<scientes>
yes
<scientes>
It puts the stack on top of the environment variables (safely, except for the /proc/self/environ, but a prctl() can fix that)
<scientes>
so you get another 8K or so of stack space, and because stack is allocated on demand, it frees memory
<andrewrk>
allocating stack on demand goes against one of the main planned features of zig which is determining the stack upper bound at compile time and making sure the entire stack is reserved before beginning execution
<scientes>
no, it doesn't change the stack size, i'm just talking about the way linux Virtual Memory works
<scientes>
it doesn't allocate memory until it is touched
<scientes>
but either way, it gives you "free" stack space
<andrewrk>
right I'm saying that the default behavior will be to mlock the entire stack
<scientes>
because the environment can take up up to 128KB of memory
<scientes>
and after Linux 2.6.23, the environment can be up to 1/4 the size of the stack
<scientes>
*allowed stack, as set in RLIMITS
<scientes>
so even bigger
wootehfoot has joined #zig
darithorn_ is now known as darithorn
Akuli has joined #zig
scientes has quit [Ping timeout: 246 seconds]
dewf has joined #zig
wilsonk has quit [Ping timeout: 246 seconds]
jjido has joined #zig
wilsonk has joined #zig
xentec has joined #zig
Akuli has quit [Quit: Leaving]
xentec has quit [Ping timeout: 250 seconds]
xentec has joined #zig
oats is now known as oa
develonepi3 has quit [Remote host closed the connection]
darithorn_ has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
darithorn has quit [Ping timeout: 250 seconds]
jjido has joined #zig
hg has quit [Quit: WeeChat 2.4]
hryx has quit []
hryx has joined #zig
scientes has joined #zig
Ichorio has quit [Ping timeout: 246 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
Protty has joined #zig
Protty has quit [Client Quit]
Flaminator has joined #zig
develonepi3 has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
darithorn__ has joined #zig
darithorn_ has quit [Read error: Connection reset by peer]