Re:T1: A Modern Programming Language for Constrained Environ...
by mwcampbell on Saturday January 11, 2020 @12:08PM
(#22020935)
AFAIK Zig doesn't have a way to calculate maximum stack usage at build time. But perhaps this could be done in a language-independent way, in LLVM. That would probably be better anyway, since to really do it well, you'd have to do whole-program analysis, including calls between Zig and C.
[ Parent
| on HN ]
Re:T1: A Modern Programming Language for Constrained Environ...
by AndyKelley on Saturday January 11, 2020 @04:10PM
(#22022332)
it's been planned since the beginning:
https://github.com/ziglang/zig/issues/157
https://github.com/ziglang/zig/issues/1639
also I figured out how to have safe recursion, taking advantage of the stackless coroutines: https://github.com/ziglang/zig/issues/1006
this is relatively straightforward to solve in a non-llvm backend. The LLVM abstraction gets leaky fast when you try to tackle this problem.
Re:T1: A Modern Programming Language for Constrained Environ...
by snops on Saturday January 11, 2020 @12:24PM
(#22021036)
Interesting, GCC has '-fstack-usage' to output the stack usage of each function into .su files, I didn't realise LLVM was lacking this feature.
There is a tool in rust[1] I just found that makes LLVM emit this information for rust code, but it stores it within[2] the .stack_sizes section in the emitted .elf instead. Possibly a similar trick could be added to Zig
[1] https://github.com/japaric/stack-sizes [2] https://llvm.org/docs/CodeGenerator.html#emitting-function-s...
Re:T1: A Modern Programming Language for Constrained Environ...
by mwcampbell on Saturday January 11, 2020 @12:36PM
(#22021118)
I was referring to T1's ability to guarantee a particular stack size for the whole program (if I understand correctly), not individual functions.