Skip to content

Commit 19f8b13

Browse files
authored
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 <[email protected]>
1 parent a85d18b commit 19f8b13

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

src/lib.rs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub struct Artifacts {
2525
bin_dir: PathBuf,
2626
libs: Vec<String>,
2727
target: String,
28-
shared: bool,
2928
}
3029

3130
impl Build {
@@ -98,6 +97,7 @@ impl Build {
9897
configure
9998
// No shared objects, we just want static libraries
10099
.arg("no-dso")
100+
.arg("no-shared")
101101
// Should be off by default on OpenSSL 1.1.0, but let's be extra sure
102102
.arg("no-ssl3")
103103
// No need to build tests, we won't run them anyway
@@ -146,23 +146,11 @@ impl Build {
146146
configure.arg("no-stdio");
147147
}
148148

149-
let shared = if target.contains("msvc") {
149+
if target.contains("msvc") {
150150
// On MSVC we need nasm.exe to compile the assembly files, but let's
151151
// just pessimistically assume for now that's not available.
152152
configure.arg("no-asm");
153-
154-
let features = env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or(String::new());
155-
if features.contains("crt-static") {
156-
configure.arg("no-shared");
157-
false
158-
} else {
159-
true
160-
}
161-
} else {
162-
// Never shared on non-MSVC
163-
configure.arg("no-shared");
164-
false
165-
};
153+
}
166154

167155
let os = match target {
168156
"aarch64-apple-darwin" => "darwin64-arm64-cc",
@@ -417,7 +405,6 @@ impl Build {
417405
include_dir: install_dir.join("include"),
418406
libs: libs,
419407
target: target.to_string(),
420-
shared,
421408
}
422409
}
423410

@@ -521,20 +508,12 @@ impl Artifacts {
521508
pub fn print_cargo_metadata(&self) {
522509
println!("cargo:rustc-link-search=native={}", self.lib_dir.display());
523510
for lib in self.libs.iter() {
524-
if self.shared {
525-
println!("cargo:rustc-link-lib={}", lib);
526-
} else {
527-
println!("cargo:rustc-link-lib=static={}", lib);
528-
}
511+
println!("cargo:rustc-link-lib=static={}", lib);
529512
}
530513
println!("cargo:include={}", self.include_dir.display());
531514
println!("cargo:lib={}", self.lib_dir.display());
532515
if self.target.contains("msvc") {
533-
if self.shared {
534-
println!("cargo:rustc-link-search=native={}", self.bin_dir.display());
535-
} else {
536-
println!("cargo:rustc-link-lib=user32");
537-
}
516+
println!("cargo:rustc-link-lib=user32");
538517
}
539518
}
540519
}

0 commit comments

Comments
 (0)