-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix sysroot on macOS when cross-compiling and SDKROOT is set #64254
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Thank you for bearing with me as I rework this. I've gotten rid of the The reason I went with |
@@ -51,3 +51,19 @@ pub fn macos_llvm_target(arch: &str) -> String { | |||
let (major, minor) = macos_deployment_target(); | |||
format!("{}-apple-macosx{}.{}.0", arch, major, minor) | |||
} | |||
|
|||
pub fn macos_link_env() -> Vec<(String, String)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit of an odd interface since it actually only returns env vars which should be cleared out, not env vars which should be set. Do we know what the various tools will behave right when set to blank values which effectively disables them? The alternative would be to extend link_env
with the ability to delete env vars as well (e.g. env_remove
).
Additionally, it seems like this would also want to encompass the ios targets perhaps? For example if you set SDKROOT
for osx or MACOSX_DEPLOYMENT_TARGET
, should those values be automatically cleared out for ios compliation in addition to macos compilation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit of an odd interface since it actually only returns env vars which should be cleared out, not env vars which should be set. Do we know what the various tools will behave right when set to blank values which effectively disables them? The alternative would be to extend
link_env
with the ability to delete env vars as well (e.g.env_remove
).
If the variable is set to an empty string, the linker behaves as if the environment variable wasn't set. We can rework this to remove environment variables instead if that feels better.
Additionally, it seems like this would also want to encompass the ios targets perhaps? For example if you set
SDKROOT
for osx orMACOSX_DEPLOYMENT_TARGET
, should those values be automatically cleared out for ios compliation in addition to macos compilation?
Yes, this makes sense. We should clear SDKROOT
if it's set to the wrong platform when targeting iOS. The value of MACOSX_DEPLOYMENT_TARGET
doesn't appear to be meaningful in the same way that IPHONEOS_DEPLOYMENT_TARGET
is (i.e. it doesn't appear to be used by the linker to infer the target platform), so perhaps we don't need to clear this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scratch that last bit actually—MACOSX_DEPLOYMENT_TARGET
is used, but it doesn't manifest until you actually try running the executable on the simulator, which will fail with dyld: program was built for a platform that is not supported by this runtime
if the environment variable was set.
Looks great to me, thanks @aleksijuvani! @bors: r+ |
📌 Commit fe6d626 has been approved by |
⌛ Testing commit fe6d626 with merge dad4c3ff1d431facee86453612fe6a4a0d96bfc1... |
💥 Test timed out |
@bors retry |
Fix sysroot on macOS when cross-compiling and SDKROOT is set Fixes rust-lang/cargo#7283 Closes rust-lang/cargo#7284 r? @alexcrichton
☀️ Test successful - checks-azure |
Fixes rust-lang/cargo#7283
Closes rust-lang/cargo#7284
r? @alexcrichton