From 51e99ea9c0b9f03f258e1bb4663b6f352dbe8fef Mon Sep 17 00:00:00 2001 From: ilammy Date: Thu, 30 Dec 2021 19:52:39 +0900 Subject: [PATCH] boring-sys: Configure "rustc-cdylib-link-arg" only for macOS targets cfg!() is evaluated for the host OS executing build.rs script. What we need here is to look whether we are building *for* macOS. Otherwise, for example, builds for iOS on macOS will try to add this flag, causing warnings since rustc does not build cdylibs on iOS. --- boring-sys/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boring-sys/build.rs b/boring-sys/build.rs index 55dae86d..07d5bd35 100644 --- a/boring-sys/build.rs +++ b/boring-sys/build.rs @@ -355,7 +355,8 @@ fn main() { println!("cargo:rustc-link-lib=static=ssl"); // MacOS: Allow cdylib to link with undefined symbols - if cfg!(target_os = "macos") { + let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); + if target_os == "macos" { println!("cargo:rustc-cdylib-link-arg=-Wl,-undefined,dynamic_lookup"); }