Closed tyuuni closed 8 months ago
Unable to compile this simple file.
#include <stdio.h> #include <dirent.h> int main() { printf("%d\n", DTTOIF(1)); }
Log:
./bin/clang++ --sysroot=./share/wasi-sysroot /tmp/a.cpp -v clang version 17.0.6 Target: wasm32-unknown-wasi Thread model: posix InstalledDir: /home/x/Applications/wasi-sdk-21.0/./bin "/home/x/Applications/wasi-sdk-21.0/bin/clang-17" -cc1 -triple wasm32-unknown-wasi -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name a.cpp -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -fvisibility=hidden -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/x/Applications/wasi-sdk-21.0 -resource-dir /home/x/Applications/wasi-sdk-21.0/lib/clang/17 -isysroot ./share/wasi-sysroot -internal-isystem ./share/wasi-sysroot/include/wasm32-wasi/c++/v1 -internal-isystem ./share/wasi-sysroot/include/c++/v1 -internal-isystem /home/x/Applications/wasi-sdk-21.0/lib/clang/17/include -internal-isystem ./share/wasi-sysroot/include/wasm32-wasi -internal-isystem ./share/wasi-sysroot/include -fdeprecated-macro -fdebug-compilation-dir=/home/x/Applications/wasi-sdk-21.0 -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -o /tmp/a-8d1f5f.o -x c++ /tmp/a.cpp clang -cc1 version 17.0.6 based upon LLVM 17.0.6 default target wasm32-wasi ignoring nonexistent directory "./share/wasi-sysroot/include/wasm32-wasi/c++/v1" ignoring nonexistent directory "./share/wasi-sysroot/include/wasm32-wasi" #include "..." search starts here: #include <...> search starts here: ./share/wasi-sysroot/include/c++/v1 /home/x/Applications/wasi-sdk-21.0/lib/clang/17/include ./share/wasi-sysroot/include End of search list. "/home/x/Applications/wasi-sdk-21.0/./bin/wasm-ld" -m wasm32 -L./share/wasi-sysroot/lib/wasm32-wasi ./share/wasi-sysroot/lib/wasm32-wasi/crt1-command.o /tmp/a-8d1f5f.o -lc++ -lc++abi -lc /home/x/Applications/wasi-sdk-21.0/lib/clang/17/lib/wasi/libclang_rt.builtins-wasm32.a -o a.out wasm-ld: error: /tmp/a-8d1f5f.o: undefined symbol: __wasilibc_dttoif(int) clang++: error: linker command failed with exit code 1 (use -v to see invocation)
It seems there is a symbol, and wasm-ld has -lc
-lc
./bin/llvm-nm share/wasi-sysroot/lib/wasm32-wasi-threads/libc.a | grep dttoif 00000018 d .Lswitch.table.__wasilibc_dttoif 00000036 T __wasilibc_dttoif
works with manual linking:
./bin/clang -c /tmp/a.cpp -emit-llvm -o /tmp/a.o ./bin/wasm-ld -L ./share/wasi-sysroot/lib/wasm32-wasi-threads/ -lc /tmp/a.o -o /tmp/a.wasm
Unable to compile this simple file.
Log:
It seems there is a symbol, and wasm-ld has
-lc