summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/build.rs')
-rw-r--r--vendor/rustix/build.rs39
1 files changed, 21 insertions, 18 deletions
diff --git a/vendor/rustix/build.rs b/vendor/rustix/build.rs
index 8b5c55a9d..26f306e58 100644
--- a/vendor/rustix/build.rs
+++ b/vendor/rustix/build.rs
@@ -6,6 +6,9 @@ use std::io::Write;
/// The directory for out-of-line (“outline”) libraries.
const OUTLINE_PATH: &str = "src/backend/linux_raw/arch/outline";
+/// The directory for inline asm.
+const INLINE_PATH: &str = "src/backend/linux_raw/arch/inline";
+
fn main() {
// Don't rerun this on changes other than build.rs, as we only depend on
// the rustc version.
@@ -24,9 +27,9 @@ fn main() {
// Gather target information.
let arch = var("CARGO_CFG_TARGET_ARCH").unwrap();
- let vendor = var("CARGO_CFG_TARGET_VENDOR").unwrap();
- let asm_name = format!("{}/{}.s", OUTLINE_PATH, arch);
- let asm_name_present = std::fs::metadata(&asm_name).is_ok();
+ let outline_asm_name = format!("{}/{}.s", OUTLINE_PATH, arch);
+ let inline_asm_name = format!("{}/{}.rs", INLINE_PATH, arch);
+ let inline_asm_name_present = std::fs::metadata(inline_asm_name).is_ok();
let target_os = var("CARGO_CFG_TARGET_OS").unwrap();
let pointer_width = var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap();
let endian = var("CARGO_CFG_TARGET_ENDIAN").unwrap();
@@ -43,12 +46,6 @@ fn main() {
// libc backend.
let feature_use_libc = var("CARGO_FEATURE_USE_LIBC").is_ok();
- // Check for `--features=rustc-dep-of-std`. This is used when rustix is
- // being used to build std, in which case `can_compile` doesn't work
- // because `core` isn't available yet, but also, we can assume we have a
- // recent compiler.
- let feature_rustc_dep_of_std = var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
-
// Check for `RUSTFLAGS=--cfg=rustix_use_libc`. This allows end users to
// enable the libc backend even if rustix is depended on transitively.
let cfg_use_libc = var("CARGO_CFG_RUSTIX_USE_LIBC").is_ok();
@@ -71,7 +68,7 @@ fn main() {
if feature_use_libc
|| cfg_use_libc
|| target_os != "linux"
- || !asm_name_present
+ || !inline_asm_name_present
|| is_unsupported_abi
|| miri
{
@@ -82,11 +79,11 @@ fn main() {
use_feature("linux_raw");
use_feature_or_nothing("core_intrinsics");
- // Use inline asm if we have it, or outline asm otherwise. On PowerPC
- // and MIPS, Rust's inline asm is considered experimental, so only use
- // it if `--cfg=rustix_use_experimental_asm` is given.
- if (feature_rustc_dep_of_std || vendor == "mustang" || can_compile("use std::arch::asm;"))
- && (arch != "x86" || has_feature("naked_functions"))
+ // Use inline asm if we have it, or outline asm otherwise. On 32-bit
+ // x86 our asm support requires naked functions. On PowerPC and MIPS,
+ // Rust's inline asm is considered experimental, so only use it if
+ // `--cfg=rustix_use_experimental_asm` is given.
+ if (arch != "x86" || has_feature("naked_functions"))
&& ((arch != "powerpc64" && arch != "mips" && arch != "mips64")
|| rustix_use_experimental_asm)
{
@@ -98,7 +95,7 @@ fn main() {
use_feature("asm_experimental_arch");
}
} else {
- link_in_librustix_outline(&arch, &asm_name);
+ link_in_librustix_outline(&arch, &outline_asm_name);
}
}
@@ -139,6 +136,12 @@ fn main() {
{
use_feature("bsd");
}
+
+ // Add some additional common target combinations.
+ if target_os == "android" || target_os == "linux" {
+ use_feature("linux_kernel");
+ }
+
if target_os == "wasi" {
use_feature_or_nothing("wasi_ext");
}
@@ -175,8 +178,8 @@ fn link_in_librustix_outline(arch: &str, asm_name: &str) {
{
let out_dir = var("OUT_DIR").unwrap();
// Add `-gdwarf-3` so that we always get the same output, regardless of
- // the Rust version we're using. DWARF3 is the version used in
- // Rust 1.48 and is entirely adequate for our simple needs here.
+ // the Rust version we're using. DWARF3 is entirely adequate for our
+ // simple needs here.
let mut build = Build::new();
if profile == "debug" {
build.flag("-gdwarf-3");