Skip to content

Commit 3ab0d8e

Browse files
committed
Remove libclang_rt.osx.a link workaround
This was fixing alexcrichton#279. All current usage of __builtin_available(...) in curl detects for APIs older than macOS 10.12, which is Rust's currently minimum supported version. This means that they are no-ops, and thus no longer emit a symbol that we need to link. Additionally, Rust's `std` has recently introduced these symbols in its standard library, see rust-lang/rust#138944. This means that even if curl _were_ to start using __builtin_available with a check for a newer macOS version, it would still successfully link (at least when using Rust 1.91.0 or newer). Finally, curl has supported the cfg option HAVE_BUILTIN_AVAILABLE for a while now, so if there ever does come a point where this starts having problems again, we can just disable that define.
1 parent 8b34786 commit 3ab0d8e

File tree

2 files changed

+13
-40
lines changed

2 files changed

+13
-40
lines changed

ci/run.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
set -ex
44

5+
# On macOS, test with the deployment target set to Rust's minimum:
6+
# https://doc.rust-lang.org/rustc/platform-support/apple-darwin.html#os-version
7+
if [ "$TARGET" = "x86_64-apple-darwin" ]; then
8+
export MACOSX_DEPLOYMENT_TARGET=10.12
9+
fi
10+
if [ "$TARGET" = "aarch64-apple-darwin" ]; then
11+
export MACOSX_DEPLOYMENT_TARGET=11.0
12+
fi
13+
514
# For musl on CI always use openssl-src dependency and build from there.
615
if [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then
716
features="--features static-ssl"

curl-sys/build.rs

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ fn main() {
5151
.status();
5252
}
5353

54-
if target.contains("apple") {
55-
// On (older) OSX we need to link against the clang runtime,
56-
// which is hidden in some non-default path.
57-
//
58-
// More details at https://github.com/alexcrichton/curl-rust/issues/279.
59-
if let Some(path) = macos_link_search_path() {
60-
println!("cargo:rustc-link-lib=clang_rt.osx");
61-
println!("cargo:rustc-link-search={}", path);
62-
}
63-
}
64-
6554
let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap());
6655
let include = dst.join("include");
6756
let build = dst.join("build");
@@ -408,7 +397,10 @@ fn main() {
408397

409398
if target.contains("-apple-") {
410399
cfg.define("__APPLE__", None)
411-
.define("HAVE_MACH_ABSOLUTE_TIME", None);
400+
.define("HAVE_MACH_ABSOLUTE_TIME", None)
401+
// Rust's `std` provides the necessary symbols since:
402+
// https://github.com/rust-lang/rust/pull/138944
403+
.define("HAVE_BUILTIN_AVAILABLE", None);
412404
} else {
413405
cfg.define("HAVE_CLOCK_GETTIME_MONOTONIC", None)
414406
.define("HAVE_GETTIMEOFDAY", None)
@@ -576,31 +568,3 @@ fn curl_config_reports_http2() -> bool {
576568

577569
true
578570
}
579-
580-
fn macos_link_search_path() -> Option<String> {
581-
let output = cc::Build::new()
582-
.get_compiler()
583-
.to_command()
584-
.arg("--print-search-dirs")
585-
.output()
586-
.ok()?;
587-
if !output.status.success() {
588-
println!(
589-
"failed to run 'clang --print-search-dirs', continuing without a link search path"
590-
);
591-
return None;
592-
}
593-
594-
let stdout = String::from_utf8_lossy(&output.stdout);
595-
for line in stdout.lines() {
596-
if line.contains("libraries: =") {
597-
let path = line.split('=').nth(1)?;
598-
if !path.is_empty() {
599-
return Some(format!("{}/lib/darwin", path));
600-
}
601-
}
602-
}
603-
604-
println!("failed to determine link search path, continuing without it");
605-
None
606-
}

0 commit comments

Comments
 (0)