From 939406285b517ea2e61a62040a85c2676e786476 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Tue, 4 Apr 2023 15:56:58 +0200 Subject: [PATCH] Unconditionally compile C / Assembly code from source --- build.rs | 51 ++------------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/build.rs b/build.rs index 1ccf0cc..ce34090 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "cc")] use cc::Build; use std::env::var; use std::io::Write; @@ -156,55 +155,9 @@ fn main() { /// outline assembly code for making syscalls. fn link_in_librustix_outline(arch: &str, asm_name: &str) { let name = format!("rustix_outline_{}", arch); - let profile = var("PROFILE").unwrap(); - let to = format!("{}/{}/lib{}.a", OUTLINE_PATH, profile, name); - println!("cargo:rerun-if-changed={}", to); - // If "cc" is not enabled, use a pre-built library. - #[cfg(not(feature = "cc"))] - { - let _ = asm_name; - println!("cargo:rustc-link-search={}/{}", OUTLINE_PATH, profile); - println!("cargo:rustc-link-lib=static={}", name); - } - - // If "cc" is enabled, build the library from source, update the pre-built - // version, and assert that the pre-built version is checked in. - #[cfg(feature = "cc")] - { - 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. - let mut build = Build::new(); - if profile == "debug" { - build.flag("-gdwarf-3"); - } - build.file(&asm_name); - build.compile(&name); - println!("cargo:rerun-if-changed={}", asm_name); - if std::fs::metadata(".git").is_ok() { - let from = format!("{}/lib{}.a", out_dir, name); - let prev_metadata = std::fs::metadata(&to); - std::fs::copy(&from, &to).unwrap(); - assert!( - prev_metadata.is_ok(), - "{} didn't previously exist; please inspect the new file and `git add` it", - to - ); - assert!( - std::process::Command::new("git") - .arg("diff") - .arg("--quiet") - .arg(&to) - .status() - .unwrap() - .success(), - "{} changed; please inspect the change and `git commit` it", - to - ); - } - } + let out_dir = var("OUT_DIR").unwrap(); + Build::new().file(&asm_name).compile(&name); } fn use_thumb_mode() -> bool { -- 2.40.0