Skip to content

Commit

Permalink
wasi32: fix linking with clang invoked from rustc
Browse files Browse the repository at this point in the history
  • Loading branch information
jcaesar committed Oct 10, 2024
1 parent c9c9419 commit 0b14612
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkgs/build-support/bintools-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ stdenvNoCC.mkDerivation {
basename=$(basename "$variant")
wrap $basename ${./ld-wrapper.sh} $variant
done
'' + optionalString targetPlatform.isWasi ''
wrap ${targetPrefix}wasm-ld ${./ld-wrapper.sh} $ldPath/${targetPrefix}wasm-ld
# clang doesn't properly normalize the target triple[1] before using it as a search path,
# and rustc passes wasm32-wasi as `-target`, which gets used as is. Work around.
# [1] https://github.com/llvm/llvm-project/blob/ad7aeb0ff58ebd29f68adb85c64e8010639e2a76/clang/lib/Driver/Driver.cpp#L6187
ln -s $out/bin/${targetPrefix}wasm-ld $out/bin/wasm32-wasi-wasm-ld
'';

strictDeps = true;
Expand Down

0 comments on commit 0b14612

Please sign in to comment.