3 ms·
I'm unsure what you're referring to here -- Zig doesn't have any runtime, it doesn't even depend on libc. The only thing I can think of that you might be refer
by mlugg 2y ago
I'm unsure what you're referring to here -- Zig doesn't have any runtime, it doesn't even depend on libc.
The only thing I can think of that you might be referring to is compiler-rt: if so, this is a thing in C too! It's just a small collection of implementations for operations the code generator wants to call into (e.g. memset, arithmetic for integers larger than CPU word size). Clang uses compiler-rt when compiling C code, and GCC's equivalent is libgcc. Nonetheless, Zig lets you disable it using `-fno-compiler-rt`, in which case you'll need to provide the relevant symbols yourself somehow.
- sylware 2y agoThis is not what I understood, there is some kind of flags required for pointers or something, which requires a data section for basic primitive types.
- mlugg 2y agoI'm afraid I'm not sure what you're referring to. For instance, I can build a simple Hello World in Zig using `zig build-exe`, and get a static executable, on which I can use `nm` to confirm that there aren't symbols from any kind of runtime. I can even trivially build the actual Zig compiler to a static binary. (For context, by the way, I'm on the Zig "core team"; I'm a notable contributor to the project.)
- sylware 2y agommmmh... basically, generates machine code which only requires a stack (which could be used by code paths not written in zig), contained in memory pages with execute and read permission only. Ofc this machine code would interact with the other machine code (written in other languages) via the architecture calling convention (the ABI/C one).
- accelbred 2y agoThats what Zig does. It compiles down to the same stuff as C. It does not have a runtime.
- butterisgood 2y agoIt also has been very much trying to get rid of things like "undefined behavior".