Why, when I compile a pure C++ project with zig build (setting zig_lib_dir=null in build options), is the executable bigger than just compiling with clang?
Might be because of static linking. What does the output of
ldd say for both binaries?
Also, Zig has different defaults than Clang/GCC, (they always compile with nothing unless asked to, whereas Zig, will always compile by default in debug, which means with debug symbol, and probably some flags/sanitizer too. It could also be static linking).
We always link libcxx and libcxxabi statically, correct. If you want to reduce the size, you could try setting
exe.link_gc_sections = true. This is the default for release modes, so it will only potentially have any effect on debug mode. Additionally, you can strip debug info with
exe.strip = true. This one is the default only for release-small.