WebAssembly / wasi-sdk

WASI-enabled WebAssembly C/C++ toolchain
Apache License 2.0
1.27k stars 190 forks source link

Don't modify the host compiler's sysroot #445

Closed alexcrichton closed 3 months ago

alexcrichton commented 3 months ago

This commit updates the building of the wasi-sdk sysroot to leverage the -resource-dir argument from Clang to avoid modifying the host compiler's sysroot with compiler-rt things. This should help improve the experience of building a standalone sysroot with whatever host Clang is on the system.

Closes #444

abrown commented 3 months ago

cc: @whitequark, does this help towards resolving the discussion you were having over in https://github.com/WebAssembly/wasi-sdk/pull/443#issuecomment-2229049509? I'm thinking of merging this but wanted to hear whether you had any additional feedback here.

yamt commented 3 months ago

have you ever tested if this change actually "avoid modifying the host compiler's sysroot with compiler-rt things"? i don't think it works w/o https://github.com/WebAssembly/wasi-libc/pull/517. i suspect we need a bit more CI coverage.

alexcrichton commented 3 months ago

Yes I tested this doesn't modify the host compiler's sysroot. No there is no test of using the host toolchain in CI. Yes it would be great to add tests.

yamt commented 3 months ago

Yes I tested this doesn't modify the host compiler's sysroot.

did your "host compiler" already happen to have wasi compiler-rt? otherwise, i don't understand why you didn't need https://github.com/WebAssembly/wasi-libc/pull/517. for me, gmake tried to create the directory for wasi compiler-rt in the host compiler's resource dir.

alexcrichton commented 3 months ago

On Ubuntu 24.04 I ran:

$ cmake -G Ninja -B build -S . -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_NM=llvm-nm-18
$ ninja -C build dist

and everything compiled ok. No the host compiler does not have a compiler-rt for wasm.

yamt commented 3 months ago

On Ubuntu 24.04 I ran:

$ cmake -G Ninja -B build -S . -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_NM=llvm-nm-18
$ ninja -C build dist

and everything compiled ok. No the host compiler does not have a compiler-rt for wasm.

where did clang/clang++/llvm-nm-18 come from? ubuntu package?

which compiler-rt does it link for wasi-libc without https://github.com/WebAssembly/wasi-libc/pull/517?

alexcrichton commented 3 months ago

The clang package owns clang/clang++ and llvm-18 owns llvm-nm. Yes, they're from ubuntu packages.

As to what links compiler-rt is linked, I'm not sure.