-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix wrong SDK being used for the host on macOS #7284
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (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. |
I had to set up a Linux virtual machine to figure out why the tests weren't passing, and rewrite this a couple of times in order to wrap my head around it, but I'm confident that it's correct now. Should be good to review! |
Thanks for the PR! Unfortunately though Cargo in general we try to keep out of the target-specific build logic like this. Is there perhaps another way to solve this problem that doesn't involve changing Cargo? |
It should be noted that |
This may be a case for compiler rather than cargo changes. This is similar to how msvc works where if you configure global env vars then it makes cross compilation difficult, so the easiest thing to do is to edit rustc so it doesn't need env vars (and use crates like cc to fix it for C code as well) |
If |
There may be a case in which the user would want to explicitly specify the SDK path with the |
The |
I'm not sure what that would look like. I'm not confident it's possible to solve this problem given these parameters. I understand the desire to avoid target-specific logic in cargo, but I can't see an alternative in this case—unless in rustc we always specify |
We could add logic to |
I had the same thought earlier, but I'm usually a bit vary about adding heuristics such as these, since it has the potential to be confusing and unexpected for the user. Perhaps it's not an issue in this case, as building with the wrong SDK is almost certainly a mistake and will cause the build to fail anyway. Maybe we should notify the user when we do this, by outputting a warning or some such? |
☔ The latest upstream changes (presumably #7216) made this pull request unmergeable. Please resolve the merge conflicts. |
Well the heuristic seems like it needs to be somewhere at this point. It's either in Cargo or rustc, and the logic is already in rustc and there's no logic at all in Cargo for this so it seems like this should go in rustc, not Cargo. |
This is making progress at rust-lang/rust#64254, so I'm going to close this in favor of that. |
Fix sysroot on macOS when cross-compiling and SDKROOT is set Fixes rust-lang/cargo#7283 Closes rust-lang/cargo#7284 r? @alexcrichton
I've been working on refactoring rustc's Apple OS target code (to support more OSes and generally be more orthogonal), and while rebasing on master I noticed the rustc change corresponding to this. I really don't think it's the right solution. Semantically, it makes a lot more sense to me that when Cargo decides to switch targets from the one the user specified, Cargo should handle correcting target settings for the new target. It shouldn't be rustc's job to guess when the target settings it's been given are wrong. Practical reasons it would be better to do it in Cargo:
|
Going back to the previous discussion:
If it's in Cargo, there's no need for a heuristic. The logic would be simply "drop the user's target settings when building for host instead of the user-specified target". In fact, that's exactly what this closed PR does. The rustc solution that was adopted instead is* a heuristic, because rustc doesn't have a concept of "building for host instead of the user-specified target", so it has to guess based on whether the SDK looks like it's compatible with the current build machine (i.e. macOS). |
@comex this is following the precedent set by MSVC and selecting visual studio and |
Closes #7283