I tried using zig c++
to build v8’s hello world demo app.
The output message shows that the linker treat the input static library files as TBD
file, and the -v
verbose message displays the underlying command is zig ld -dynamic
.
How is it happen? And how could I enforce static linking?
❯ zig c++ -static -I. -Iinclude -o v8_hello -fno-rtti -lv8_monolith \
-lv8_libbase -lv8_libplatform -ldl -Lout/arm64.release/obj -pthread \
-std=c++20 -DV8_COMPRESS_POINTERS \
-DV8_ENABLE_SANDBOX samples/hello-world.cc -v
zig ld -dynamic -platform_version macos 14.5.0 14.5 -syslibroot \
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk \
-rpath out/arm64.release/obj \
-rpath /nix/store/gd2wv2206pw1n6ddi2siy4y6vdrq2b6g-libcxx-11.1.0/lib \
-rpath /nix/store/alpyb4jjlfmajljzv567p31xa309axb6-libcxxabi-11.1.0/lib \
-rpath /nix/store/9krx1rq92zy5x5xr0dc17sydimkqicqw-compiler-rt-libc-11.1.0/lib \
-rpath /nix/store/cyz92bd5vaws21yj01vw0k695xkc58h7-libobjc-11.0.0/lib \
-rpath /nix/store/53z0h638fikqkij4916m2sjzpd1091bq-libcxx-18.1.8/lib \
-rpath /nix/store/kdycpy1zw6q0v28f2c3rwrfa7hl6gxx4-compiler-rt-libc-18.1.8/lib \
-rpath /nix/store/gd2wv2206pw1n6ddi2siy4y6vdrq2b6g-libcxx-11.1.0/lib \
-rpath /nix/store/alpyb4jjlfmajljzv567p31xa309axb6-libcxxabi-11.1.0/lib \
-rpath /nix/store/9krx1rq92zy5x5xr0dc17sydimkqicqw-compiler-rt-libc-11.1.0/lib \
-rpath /nix/store/cyz92bd5vaws21yj01vw0k695xkc58h7-libobjc-11.0.0/lib \
-rpath /nix/store/53z0h638fikqkij4916m2sjzpd1091bq-libcxx-18.1.8/lib \
-rpath /nix/store/kdycpy1zw6q0v28f2c3rwrfa7hl6gxx4-compiler-rt-libc-18.1.8/lib \
-e _main -o v8_hello \
out/arm64.release/obj/libv8_monolith.a \
out/arm64.release/obj/libv8_libbase.a out/arm64.release/obj/libv8_libplatform.a \
/Users/parents/.cache/zig/o/ff2597aca0da85e855ebb169e56b933e/hello-world.o \
-Lout/arm64.release/obj -L/nix/store/gd2wv2206pw1n6ddi2siy4y6vdrq2b6g-libcxx-11.1.0/lib \
-L/nix/store/alpyb4jjlfmajljzv567p31xa309axb6-libcxxabi-11.1.0/lib \
-L/nix/store/9krx1rq92zy5x5xr0dc17sydimkqicqw-compiler-rt-libc-11.1.0/lib \
-L/nix/store/cyz92bd5vaws21yj01vw0k695xkc58h7-libobjc-11.0.0/lib \
-L/nix/store/53z0h638fikqkij4916m2sjzpd1091bq-libcxx-18.1.8/lib \
-L/nix/store/kdycpy1zw6q0v28f2c3rwrfa7hl6gxx4-compiler-rt-libc-18.1.8/lib \
-L/nix/store/gd2wv2206pw1n6ddi2siy4y6vdrq2b6g-libcxx-11.1.0/lib \
-L/nix/store/alpyb4jjlfmajljzv567p31xa309axb6-libcxxabi-11.1.0/lib \
-L/nix/store/9krx1rq92zy5x5xr0dc17sydimkqicqw-compiler-rt-libc-11.1.0/lib \
-L/nix/store/cyz92bd5vaws21yj01vw0k695xkc58h7-libobjc-11.0.0/lib \
-L/nix/store/53z0h638fikqkij4916m2sjzpd1091bq-libcxx-18.1.8/lib \
-L/nix/store/kdycpy1zw6q0v28f2c3rwrfa7hl6gxx4-compiler-rt-libc-18.1.8/lib \
-F/nix/store/bd2l2sf1wh63cbc4g0ma30ryq0026kxz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks \
-F /nix/store/bd2l2sf1wh63cbc4g0ma30ryq0026kxz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks \
/Users/parents/.cache/zig/o/068df5d0c2d34e5357b4b7d1193e8068/libc++abi.a \
/Users/parents/.cache/zig/o/66eb39b1c33ce356f97460f5f1faa34d/libc++.a -lSystem \
/Users/parents/.cache/zig/o/21d8b40e342a8f3238bf92282522ec0f/libcompiler_rt.a \
error: failed to parse TBD file: UnexpectedToken
note: while parsing out/arm64.release/obj/libv8_libplatform.a
error: failed to parse TBD file: UnexpectedToken
note: while parsing out/arm64.release/obj/libv8_libbase.a