Skip to content

Commit ee85060

Browse files
committed
Fix linking libc++ on wasi
1 parent 22ceada commit ee85060

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

compiler/rustc_llvm/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ fn main() {
377377
|| target.contains("freebsd")
378378
|| target.contains("windows-gnullvm")
379379
|| target.contains("aix")
380+
|| target.contains("wasi")
380381
{
381382
"c++"
382383
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {

config.llvm.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ prefix = "dist"
3333
sysconfdir = "etc"
3434

3535
[target.'wasm32-wasip1-threads']
36-
wasi-root = "wasi-sdk-24.0-x86_64-linux/share/wasi-sysroot"
36+
wasi-root = "/home/bjorn/Projects/rust/wasi-sdk-24.0-x86_64-linux/share/wasi-sysroot"
3737
# codegen-backends = ["cranelift"]
38+
cc = "/home/bjorn/Projects/rust/wasi-sdk-24.0-x86_64-linux/bin/clang"
39+
cxx = "/home/bjorn/Projects/rust/wasi-sdk-24.0-x86_64-linux/bin/clang"
3840
linker = "wasi-sdk-24.0-x86_64-linux/bin/clang"
3941
codegen-backends = ["llvm"]
4042

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,9 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
12531253

12541254
// Building with a static libstdc++ is only supported on linux right now,
12551255
// not for MSVC or macOS
1256-
if builder.config.llvm_static_stdcpp
1256+
if target.contains("wasi") {
1257+
cargo.env("LLVM_STATIC_STDCPP", dbg!(builder.wasi_libdir(target).unwrap().join("libc++.a")));
1258+
} else if builder.config.llvm_static_stdcpp
12571259
&& !target.contains("freebsd")
12581260
&& !target.is_msvc()
12591261
&& !target.contains("apple")

0 commit comments

Comments
 (0)