mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
53852ee4eb
Only the android libunwind detection remains in the build script * Reduces dependence on build scripts for building the standard library * Reduces dependence on exact target names in favor of using semantic cfg(target_*) usage. * Keeps almost all code related to linking of the unwinder in one file
26 lines
851 B
Rust
26 lines
851 B
Rust
use std::env;
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-env-changed=CARGO_CFG_MIRI");
|
|
|
|
if env::var_os("CARGO_CFG_MIRI").is_some() {
|
|
// Miri doesn't need the linker flags or a libunwind build.
|
|
return;
|
|
}
|
|
|
|
let target = env::var("TARGET").expect("TARGET was not set");
|
|
if target.contains("android") {
|
|
let build = cc::Build::new();
|
|
|
|
// Since ndk r23 beta 3 `libgcc` was replaced with `libunwind` thus
|
|
// check if we have `libunwind` available and if so use it. Otherwise
|
|
// fall back to `libgcc` to support older ndk versions.
|
|
let has_unwind = build.is_flag_supported("-lunwind").expect("Unable to invoke compiler");
|
|
|
|
if has_unwind {
|
|
println!("cargo:rustc-cfg=feature=\"system-llvm-libunwind\"");
|
|
}
|
|
}
|
|
}
|