From 0b1461261e140c892d6154b12db26a345c051484 Mon Sep 17 00:00:00 2001 From: Julius Michaelis Date: Fri, 19 Jul 2024 13:29:29 +0900 Subject: [PATCH] wasi32: fix linking with clang invoked from rustc --- pkgs/build-support/bintools-wrapper/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index b64e97345ab5c..17ecae2b635a7 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -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;