Skip to content

Commit

Permalink
Fix linking stdc++ on wasi
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Sep 24, 2024
1 parent 22ceada commit 3ab3533
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.llvm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ sysconfdir = "etc"
[target.'wasm32-wasip1-threads']
wasi-root = "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"]

Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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", builder.wasi_libdir(target).unwrap().join("libstdc++.a"));
} else if builder.config.llvm_static_stdcpp
&& !target.contains("freebsd")
&& !target.is_msvc()
&& !target.contains("apple")
Expand Down

0 comments on commit 3ab3533

Please sign in to comment.