From ed82c6651179718b23a7982c9ccc8e017b649257 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:59:33 +0200 Subject: [PATCH] Fix linking libc++ on wasi --- config.llvm.toml | 4 +++- src/bootstrap/src/core/build_steps/compile.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config.llvm.toml b/config.llvm.toml index b8d5239e0fee0..7b5081f1a9075 100644 --- a/config.llvm.toml +++ b/config.llvm.toml @@ -33,8 +33,10 @@ prefix = "dist" sysconfdir = "etc" [target.'wasm32-wasip1-threads'] -wasi-root = "wasi-sdk-24.0-x86_64-linux/share/wasi-sysroot" +wasi-root = "/home/bjorn/Projects/rust/wasi-sdk-24.0-x86_64-linux/share/wasi-sysroot" # codegen-backends = ["cranelift"] +cc = "/home/bjorn/Projects/rust/wasi-sdk-24.0-x86_64-linux/bin/clang" +cxx = "/home/bjorn/Projects/rust/wasi-sdk-24.0-x86_64-linux/bin/clang" linker = "wasi-sdk-24.0-x86_64-linux/bin/clang" codegen-backends = ["llvm"] diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index ad7a7f3d03933..778939d8df282 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1253,7 +1253,9 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect // Building with a static libstdc++ is only supported on linux right now, // not for MSVC or macOS - if builder.config.llvm_static_stdcpp + if target.contains("wasi") { + cargo.env("LLVM_STATIC_STDCPP", dbg!(builder.wasi_libdir(target).unwrap().join("libc++.a"))); + } else if builder.config.llvm_static_stdcpp && !target.contains("freebsd") && !target.is_msvc() && !target.contains("apple")