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

[macOS] Following the README file, fails to compile #363

Open
skhaz opened this issue Dec 8, 2023 · 1 comment
Open

[macOS] Following the README file, fails to compile #363

skhaz opened this issue Dec 8, 2023 · 1 comment

Comments

@skhaz
Copy link

skhaz commented Dec 8, 2023

I am following the README file, however for macOS it fails to link, step by step below.

export WASI_VERSION=20
export WASI_VERSION_FULL=${WASI_VERSION}.0
wget "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz"
tar xvf "wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz"

The error.

/opt/workspace/personal/wasm/wasi-sdk-20.0/bin/clang --sysroot=/opt/workspace/personal/wasm/wasi-sdk-20.0/share/wasi-sysroot --target=wasm32 -Wl,--export-all -Wl,--no-entry -v main.c
clang version 16.0.0 (https://github.com/llvm/llvm-project 08d094a0e457360ad8b94b017d2dc277e697ca76)
Target: wasm32
Thread model: posix
InstalledDir: /opt/workspace/personal/wasm/wasi-sdk-20.0/bin
 "/opt/workspace/personal/wasm/wasi-sdk-20.0/bin/clang-16" -cc1 -triple wasm32 -emit-obj -mrelax-all -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 -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -target-linker-version 820.1 -v -fcoverage-compilation-dir=/opt/workspace/personal/wasm -resource-dir /opt/workspace/personal/wasm/wasi-sdk-20.0/lib/clang/16 -isysroot /opt/workspace/personal/wasm/wasi-sdk-20.0/share/wasi-sysroot -internal-isystem /opt/workspace/personal/wasm/wasi-sdk-20.0/lib/clang/16/include -internal-isystem /opt/workspace/personal/wasm/wasi-sdk-20.0/share/wasi-sysroot/include -fdebug-compilation-dir=/opt/workspace/personal/wasm -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -o /var/folders/35/9gkth5r11k77jyphrcjv7l9c0000gn/T/main-6b0364.o -x c main.c
clang -cc1 version 16.0.0 based upon LLVM 16.0.0 default target wasm32-wasi
#include "..." search starts here:
#include <...> search starts here:
 /opt/workspace/personal/wasm/wasi-sdk-20.0/lib/clang/16/include
 /opt/workspace/personal/wasm/wasi-sdk-20.0/share/wasi-sysroot/include
End of search list.
 "/opt/workspace/personal/wasm/wasi-sdk-20.0/bin/wasm-ld" -m wasm32 -L/opt/workspace/personal/wasm/wasi-sdk-20.0/share/wasi-sysroot/lib crt1.o --export-all --no-entry /var/folders/35/9gkth5r11k77jyphrcjv7l9c0000gn/T/main-6b0364.o -lc /opt/workspace/personal/wasm/wasi-sdk-20.0/lib/clang/16/lib/libclang_rt.builtins-wasm32.a -o a.out
wasm-ld: error: cannot open crt1.o: No such file or directory
wasm-ld: error: unable to find library -lc
wasm-ld: error: cannot open /opt/workspace/personal/wasm/wasi-sdk-20.0/lib/clang/16/lib/libclang_rt.builtins-wasm32.a: No such file or directory
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

The error occurs because the path is incorrect, below is the correction.

.../lib/libclang_rt.builtins-wasm32.a

Should be.

.../lib/wasi/libclang_rt.builtins-wasm32.a

After copying it to a directory above, I get this error.

wasm-ld: error: cannot open crt1.o: No such file or directory
wasm-ld: error: unable to find library -lc

PS.: Please put the commands with variables in double quotes, as ZSH escapes them when pasting and an error occurs.

@yamt
Copy link
Contributor

yamt commented Dec 14, 2023

you should use wasm32-wasi target instead.

you don't need to specify sysroot or target as they are the default.

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