Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/fiber/build.rs
1690 views
1
use std::env;
2
use wasmtime_versioned_export_macros::versioned_suffix;
3
4
fn main() {
5
let mut build = cc::Build::new();
6
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
7
let os = env::var("CARGO_CFG_TARGET_OS").unwrap();
8
9
// NB: Technically `cfg(sanitize = "address")` is not stable and requires a
10
// `#![feature]` but sort of abuse the fact that cfgs are "leaked" through
11
// into Cargo ungated via `--print cfg`. Translate that to `cfg(asan)` for
12
// us to write down in the code.
13
println!("cargo:rustc-check-cfg=cfg(asan)");
14
match env::var("CARGO_CFG_SANITIZE") {
15
Ok(s) if s == "address" => {
16
println!("cargo:rustc-cfg=asan");
17
}
18
_ => {}
19
}
20
21
if os == "windows" {
22
println!("cargo:rerun-if-changed=src/windows.c");
23
build.file("src/windows.c");
24
build.define("VERSIONED_SUFFIX", Some(versioned_suffix!()));
25
} else if arch == "s390x" {
26
println!("cargo:rerun-if-changed=src/stackswitch/s390x.S");
27
build.file("src/stackswitch/s390x.S");
28
build.define("VERSIONED_SUFFIX", Some(versioned_suffix!()));
29
} else {
30
// assume that this is included via inline assembly in the crate itself,
31
// and the crate will otherwise have a `compile_error!` for unsupported
32
// platforms.
33
println!("cargo:rerun-if-changed=build.rs");
34
return;
35
}
36
build.define(&format!("CFG_TARGET_OS_{os}"), None);
37
build.define(&format!("CFG_TARGET_ARCH_{arch}"), None);
38
build.compile("wasmtime-fiber");
39
}
40
41