-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fails to link curl::init()
's call to INIT_CTOR
on macOS 12.0 (Monterey)
#417
Comments
I think any of the solutions you proposed would likely work fine, the goal of this is to basically automatically initialize and the other various details are just implementation oddities that are fine to change. |
Also yes your assessments are correct that the weird indirection in this code is a workaround for rust-lang/rust#47384, where
Nope, the initializer only needs to run if the curl crate is actually used. Even then, it isn't strictly required to be run in order to use curl since we lazily invoke |
I meant do all three of the things, in order for not calling the static to be okay. But if there are indeed other circumstances where its module is referenced but the static is still optimised out, then even doing all three won't guarantee it. I had one other silly idea: set // Workaround for https://github.com/alexcrichton/curl-rust/issues/417
if cfg!(target_os = "macos") && env::var("MACOSX_DEPLOYMENT_TARGET").is_err() {
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.7");
} I tried it. It compiles with no error, with |
Would setting |
The curl crate. Not that the reference actually says this, but yes. I'd be more worried about linking 10.7 intermediates with dependent crates and others. I can see that the tests/examples in this repo aren't actually a good enough test of this behaviour. In a way I think it would be more obviously fine if it could set an env var for the entire program being compiled. |
Some playground utilities use cargo which uses curl. I ran into this problem. As a workaround that doesn't involve updating any of my dependencies, I can make use of the
This allows me to hobble on until it's properly fixed by y'all wonderful people. Which I now see was mentioned in the upstream issue 🤦 Hopefully this will save someone else from making the same mistake |
Compilation currently fails for curl on macOS Monterey due to upstream rustc issue rust-lang/rust#90342. To make this problem hurt users less, we can work around this by avoiding the specific issue that this bug causes. To avoid the rustc issue, we cannot directly reference any symbol that is configured to be in a constructor linker section, which we were previously doing intentionally to work around a different rustc issue rust-lang/rust#47384. We should be able to avoid both bugs by defining our constructor symbol as a public item in the root module, though not directly referencing it in other code. Since the root module is always used (`init` is called on-demand in key places in the code) it should not be removed by optimization. Also add a quick unit test to make sure the constructor is still working for the platforms we have CI for. Fixes #417.
Compilation currently fails for curl on macOS Monterey due to upstream rustc issue rust-lang/rust#90342. To make this problem hurt users less, we can work around this by avoiding the specific issue that this bug causes. To avoid the rustc issue, we cannot directly reference any symbol that is configured to be in a constructor linker section, which we were previously doing intentionally to work around a different rustc issue rust-lang/rust#47384. We should be able to avoid both bugs by defining our constructor symbol as a public item in the root module, though not directly referencing it in other code. Since the root module is always used (`init` is called on-demand in key places in the code) it should not be removed by optimization. Also add a quick unit test to make sure the constructor is still working for the platforms we have CI for. Fixes #417.
Can someone running macOS Monterey verify that the latest |
|
Nice! We'll get this fix out to Crates.io soon. |
The fix for this is now available in curl 0.4.41. |
…rt, r=Mark-Simulacrum Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking This reverts commit b376f56, which is the main part of rust-lang#90499, because it turns out that this causes a good amount of breakage in crates relying on the old behavior. In particular `winit`, `coreaudio` and crates that depend on them are affected. Fixes rust-lang#91372. Background: Before rust-lang#90499 the behavior was the following: If MACOSX_DEPLOYMENT_TARGET is not set, we pass the minimum supported OS version to LLVM but not to the linker. The linker default depends on the Xcode version and the version of the OS it is running on. That caused one known problem in libcurl with the most recent Xcode versions. rust-lang#90499 passed the minumum supported version (10.7 for Macos x86-64) to the linker instead. This has shown to be problematic because some crates such as winit, coreaudio implicitly expect a newer minimum OS version. The libcurl issue has been fixed independently (see alexcrichton/curl-rust#417), so a revert should not really be problematic. Eventually we should probably mimic clang's behavior and fall back to the default of the currently configured Macos SDK for both the LLVM min os target version and MACOSX_DEPLOYMENT_TARGET for linking. That would entail looking at the `Version` property of the `SDKSettings.json` in the currently configured SDK.
…rt, r=Mark-Simulacrum Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking This reverts commit b376f56, which is the main part of rust-lang#90499, because it turns out that this causes a good amount of breakage in crates relying on the old behavior. In particular `winit`, `coreaudio` and crates that depend on them are affected. Fixes rust-lang#91372. Background: Before rust-lang#90499 the behavior was the following: If MACOSX_DEPLOYMENT_TARGET is not set, we pass the minimum supported OS version to LLVM but not to the linker. The linker default depends on the Xcode version and the version of the OS it is running on. That caused one known problem in libcurl with the most recent Xcode versions. rust-lang#90499 passed the minumum supported version (10.7 for Macos x86-64) to the linker instead. This has shown to be problematic because some crates such as winit, coreaudio implicitly expect a newer minimum OS version. The libcurl issue has been fixed independently (see alexcrichton/curl-rust#417), so a revert should not really be problematic. Eventually we should probably mimic clang's behavior and fall back to the default of the currently configured Macos SDK for both the LLVM min os target version and MACOSX_DEPLOYMENT_TARGET for linking. That would entail looking at the `Version` property of the `SDKSettings.json` in the currently configured SDK.
…rt, r=Mark-Simulacrum Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking This reverts commit b376f56, which is the main part of rust-lang#90499, because it turns out that this causes a good amount of breakage in crates relying on the old behavior. In particular `winit`, `coreaudio` and crates that depend on them are affected. Fixes rust-lang#91372. Background: Before rust-lang#90499 the behavior was the following: If MACOSX_DEPLOYMENT_TARGET is not set, we pass the minimum supported OS version to LLVM but not to the linker. The linker default depends on the Xcode version and the version of the OS it is running on. That caused one known problem in libcurl with the most recent Xcode versions. rust-lang#90499 passed the minumum supported version (10.7 for Macos x86-64) to the linker instead. This has shown to be problematic because some crates such as winit, coreaudio implicitly expect a newer minimum OS version. The libcurl issue has been fixed independently (see alexcrichton/curl-rust#417), so a revert should not really be problematic. Eventually we should probably mimic clang's behavior and fall back to the default of the currently configured Macos SDK for both the LLVM min os target version and MACOSX_DEPLOYMENT_TARGET for linking. That would entail looking at the `Version` property of the `SDKSettings.json` in the currently configured SDK.
…rt, r=Mark-Simulacrum Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking This reverts commit b376f56, which is the main part of rust-lang#90499, because it turns out that this causes a good amount of breakage in crates relying on the old behavior. In particular `winit`, `coreaudio` and crates that depend on them are affected. Fixes rust-lang#91372. Background: Before rust-lang#90499 the behavior was the following: If MACOSX_DEPLOYMENT_TARGET is not set, we pass the minimum supported OS version to LLVM but not to the linker. The linker default depends on the Xcode version and the version of the OS it is running on. That caused one known problem in libcurl with the most recent Xcode versions. rust-lang#90499 passed the minumum supported version (10.7 for Macos x86-64) to the linker instead. This has shown to be problematic because some crates such as winit, coreaudio implicitly expect a newer minimum OS version. The libcurl issue has been fixed independently (see alexcrichton/curl-rust#417), so a revert should not really be problematic. Eventually we should probably mimic clang's behavior and fall back to the default of the currently configured Macos SDK for both the LLVM min os target version and MACOSX_DEPLOYMENT_TARGET for linking. That would entail looking at the `Version` property of the `SDKSettings.json` in the currently configured SDK.
Summary
Only on macOS. May occur on macOS earlier than 12 using Xcode 13, I'm not sure. Underlying issue is rust-lang/rust#90342
You get a linker error, there is a workaround for end users of the crate (see the rust issue; set the env var). I think curl-rust specifically can avoid this problem.
Repro:
cargo test
in the curl-rust repo (currently at df64ee4).This is using either system libcurl or with
--features static-curl
. Makes no difference.Possible solutions, other than waiting for the rust issue
The relevant symbol is defined at:
curl-rust/src/lib.rs
Lines 93 to 101 in df64ee4
I think the actual bug is due to the the workaround for rust-lang/rust#47384 referenced further down, in which the
init
function callsINIT_CTOR();
.I think you can solve it by:
#[used]
toINIT_CTOR
(any MSRV issue? not sure)INIT_CTOR
outside theinit
functionpub fn init() { INIT_CTOR(); }
topub fn init() { init_inner(); }
It works on macOS 12, at least. But I think it would be good enough, because:
INIT_CTOR
, despite that rust-lang/rust issue 47384 where not using any code from the module means it won't get linked at allThe text was updated successfully, but these errors were encountered: