Skip to content

Commit

Permalink
Some preparation for once LLVM can compile for wasm32-wasip1 without …
Browse files Browse the repository at this point in the history
…threads
  • Loading branch information
bjorn3 committed Sep 25, 2024
1 parent 34b540e commit b049100
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion config.llvm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ experimental-targets = ""
docs = false
extended = false
tools = []
host = ["wasm32-wasip1-threads"]
host = ["wasm32-wasip1"]
target = ["x86_64-unknown-linux-gnu", "wasm32-wasip1-threads"]
cargo-native-static = true

[install]
prefix = "dist"
sysconfdir = "etc"

[target.'wasm32-wasip1']
wasi-root = "wasi-sdk-24.0-x86_64-linux/share/wasi-sysroot"
linker = "wasi-sdk-24.0-x86_64-linux/bin/clang"
codegen-backends = ["llvm"]

[target.'wasm32-wasip1-threads']
wasi-root = "wasi-sdk-24.0-x86_64-linux/share/wasi-sysroot"
linker = "wasi-sdk-24.0-x86_64-linux/bin/clang"
Expand Down
14 changes: 11 additions & 3 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,11 @@ impl Step for Llvm {
let wasi_cflags = String::from("");
let wasi_ldflags = String::from("");
let wasi_target_llvm = target.triple.to_string();
let wasi_cflags_llvm = format!("{wasi_cflags} -pthread");
let wasi_cflags_llvm = if target.contains("threads") {
format!("{wasi_cflags} -pthread")
} else {
wasi_cflags.clone()
};
let wasi_ldflags_llvm = wasi_ldflags;
// LLVM has some (unreachable in our configuration) calls to mmap.
let wasi_cflags_llvm = format!("{wasi_cflags_llvm} -D_WASI_EMULATED_MMAN");
Expand Down Expand Up @@ -559,8 +563,6 @@ impl Step for Llvm {
.define("LLVM_BUILD_SHARED_LIBS", "OFF")
.define("LLVM_ENABLE_PIC", "OFF")
.define("LLVM_BUILD_STATIC", "ON")
// .define("LLVM_ENABLE_THREADS", "OFF")
.define("LLVM_ENABLE_THREADS", "ON")
.define("LLVM_BUILD_RUNTIME", "OFF")
.define("LLVM_BUILD_TOOLS", "OFF")
.define("LLVM_INCLUDE_UTILS", "OFF")
Expand Down Expand Up @@ -678,6 +680,12 @@ impl Step for Llvm {
.define("LLD_BUILD_TOOLS", "OFF")
.define("CMAKE_BUILD_TYPE", "MinSizeRel")
.define("HAVE_DLOPEN", "");

if target.contains("threads") {
cfg.define("LLVM_ENABLE_THREADS", "ON");
} else {
cfg.define("LLVM_ENABLE_THREADS", "OFF");
}
} else {
cfg.define("LLVM_TOOL_LLVM_CONFIG_BUILD", "ON")
.define("LLVM_BUILD_TOOLS", "ON");
Expand Down

0 comments on commit b049100

Please sign in to comment.