Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue linking with --target=wasm32-wasip2-component #483

Closed
KennanHunter opened this issue Aug 28, 2024 · 2 comments
Closed

Issue linking with --target=wasm32-wasip2-component #483

KennanHunter opened this issue Aug 28, 2024 · 2 comments

Comments

@KennanHunter
Copy link

I'm trying to use --target=wasm32-wasip2-component as partially described in #426 to compile an empty C file with wasi-sdk 24.0 to a Wasi component, but it seems that it is having troubles finding the libraries for linking.

This is all the c file is:

int main()
{
    return 0;
}

These are the results of running clang on it:

$ /opt/wasi-sdk/bin/clang ./component/main.c  -o app.wasm --target=wasm32-wasip2-component -v
clang version 18.1.2-wasi-sdk (https://github.com/llvm/llvm-project 26a1d6601d727a96f4301d0d8647b5a42760ae0c)
Target: wasm32-unknown-wasip2-component
Thread model: posix
InstalledDir: /opt/wasi-sdk/bin
 "/opt/wasi-sdk/bin/clang-18" -cc1 -triple wasm32-unknown-wasip2-component -emit-obj -mrelax-all -dumpdir app.wasm- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.c -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -fvisibility=hidden -debugger-tuning=gdb -fdebug-compilation-dir=/home/kennan/programming/workbench-c -v -fcoverage-compilation-dir=/home/kennan/programming/workbench-c -resource-dir /opt/wasi-sdk/lib/clang/18 -isysroot /opt/wasi-sdk/bin/../share/wasi-sysroot -internal-isystem /opt/wasi-sdk/lib/clang/18/include -internal-isystem /opt/wasi-sdk/bin/../share/wasi-sysroot/include/wasm32-wasip2-component -internal-isystem /opt/wasi-sdk/bin/../share/wasi-sysroot/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -o /tmp/main-c7559e.o -x c ./component/main.c
clang -cc1 version 18.1.2-wasi-sdk based upon LLVM 18.1.2-wasi-sdk default target wasm32-wasi
ignoring nonexistent directory "/opt/wasi-sdk/bin/../share/wasi-sysroot/include/wasm32-wasip2-component"
#include "..." search starts here:
#include <...> search starts here:
 /opt/wasi-sdk/lib/clang/18/include
 /opt/wasi-sdk/bin/../share/wasi-sysroot/include
End of search list.
 "/opt/wasi-sdk/bin/wasm-component-ld" -m wasm32 --wasm-ld-path /opt/wasi-sdk/bin/wasm-ld -L/opt/wasi-sdk/bin/../share/wasi-sysroot/lib/wasm32-wasip2-component crt1.o /tmp/main-c7559e.o -lc /opt/wasi-sdk/lib/clang/18/lib/wasip2/libclang_rt.builtins-wasm32.a -o app.wasm
wasm-ld: error: cannot open crt1.o: No such file or directory
wasm-ld: error: unable to find library -lc
error: failed to invoke LLD: exit status: 1
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Final goal is to compile a C file to component mode and import the Wasi clock and stdio dependencies, any help or direction would be greatly appreciated.

@alexcrichton
Copy link
Collaborator

Ah the target names of wasm32-wasip2-component and wasm32-wasip2-module are hypothetical names, not actual implemented names. This target is called wasm32-wasip2 (no suffix after that). This target emits a component at this time. Emitting a core wasm module, like the hypothetical wasm32-wasip2-module target, is not implemented at this time.

@KennanHunter
Copy link
Author

Thank you! wasm32-wasip2 works perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants