From 19f8b1367729d2d0c1cf12b3b72f67003d67ea76 Mon Sep 17 00:00:00 2001 From: Alex Malgaroli Date: Thu, 7 Jan 2021 16:45:12 +0000 Subject: [PATCH] Moved "no-shared" so that also windows statically link to the libraries (#83) * Moved "no-shared" so that windows statically link to the libraries * try reapplying changes * removed shared as it's always false. Co-authored-by: molleafauss --- src/lib.rs | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 98c84039..5d2a34f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,6 @@ pub struct Artifacts { bin_dir: PathBuf, libs: Vec, target: String, - shared: bool, } impl Build { @@ -98,6 +97,7 @@ impl Build { configure // No shared objects, we just want static libraries .arg("no-dso") + .arg("no-shared") // Should be off by default on OpenSSL 1.1.0, but let's be extra sure .arg("no-ssl3") // No need to build tests, we won't run them anyway @@ -146,23 +146,11 @@ impl Build { configure.arg("no-stdio"); } - let shared = if target.contains("msvc") { + if target.contains("msvc") { // On MSVC we need nasm.exe to compile the assembly files, but let's // just pessimistically assume for now that's not available. configure.arg("no-asm"); - - let features = env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or(String::new()); - if features.contains("crt-static") { - configure.arg("no-shared"); - false - } else { - true - } - } else { - // Never shared on non-MSVC - configure.arg("no-shared"); - false - }; + } let os = match target { "aarch64-apple-darwin" => "darwin64-arm64-cc", @@ -417,7 +405,6 @@ impl Build { include_dir: install_dir.join("include"), libs: libs, target: target.to_string(), - shared, } } @@ -521,20 +508,12 @@ impl Artifacts { pub fn print_cargo_metadata(&self) { println!("cargo:rustc-link-search=native={}", self.lib_dir.display()); for lib in self.libs.iter() { - if self.shared { - println!("cargo:rustc-link-lib={}", lib); - } else { - println!("cargo:rustc-link-lib=static={}", lib); - } + println!("cargo:rustc-link-lib=static={}", lib); } println!("cargo:include={}", self.include_dir.display()); println!("cargo:lib={}", self.lib_dir.display()); if self.target.contains("msvc") { - if self.shared { - println!("cargo:rustc-link-search=native={}", self.bin_dir.display()); - } else { - println!("cargo:rustc-link-lib=user32"); - } + println!("cargo:rustc-link-lib=user32"); } } }