diff --git a/ci/run.sh b/ci/run.sh index 3d9e931cb..103b0cf5d 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -2,6 +2,15 @@ set -ex +# On macOS, test with the deployment target set to Rust's minimum: +# https://doc.rust-lang.org/rustc/platform-support/apple-darwin.html#os-version +if [ "$TARGET" = "x86_64-apple-darwin" ]; then + export MACOSX_DEPLOYMENT_TARGET=10.12 +fi +if [ "$TARGET" = "aarch64-apple-darwin" ]; then + export MACOSX_DEPLOYMENT_TARGET=11.0 +fi + # For musl on CI always use openssl-src dependency and build from there. if [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then features="--features static-ssl" diff --git a/curl-sys/build.rs b/curl-sys/build.rs index 433a6c519..e9a26564c 100644 --- a/curl-sys/build.rs +++ b/curl-sys/build.rs @@ -51,17 +51,6 @@ fn main() { .status(); } - if target.contains("apple") { - // On (older) OSX we need to link against the clang runtime, - // which is hidden in some non-default path. - // - // More details at https://github.com/alexcrichton/curl-rust/issues/279. - if let Some(path) = macos_link_search_path() { - println!("cargo:rustc-link-lib=clang_rt.osx"); - println!("cargo:rustc-link-search={}", path); - } - } - let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); let include = dst.join("include"); let build = dst.join("build"); @@ -408,7 +397,10 @@ fn main() { if target.contains("-apple-") { cfg.define("__APPLE__", None) - .define("HAVE_MACH_ABSOLUTE_TIME", None); + .define("HAVE_MACH_ABSOLUTE_TIME", None) + // Rust's `std` provides the necessary symbols since: + // https://github.com/rust-lang/rust/pull/138944 + .define("HAVE_BUILTIN_AVAILABLE", None); } else { cfg.define("HAVE_CLOCK_GETTIME_MONOTONIC", None) .define("HAVE_GETTIMEOFDAY", None) @@ -576,31 +568,3 @@ fn curl_config_reports_http2() -> bool { true } - -fn macos_link_search_path() -> Option { - let output = cc::Build::new() - .get_compiler() - .to_command() - .arg("--print-search-dirs") - .output() - .ok()?; - if !output.status.success() { - println!( - "failed to run 'clang --print-search-dirs', continuing without a link search path" - ); - return None; - } - - let stdout = String::from_utf8_lossy(&output.stdout); - for line in stdout.lines() { - if line.contains("libraries: =") { - let path = line.split('=').nth(1)?; - if !path.is_empty() { - return Some(format!("{}/lib/darwin", path)); - } - } - } - - println!("failed to determine link search path, continuing without it"); - None -}