-
Notifications
You must be signed in to change notification settings - Fork 475
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
Use SDKROOT when set. #661
Conversation
Is there existing precedent for using an environment variable like this? If so is there documentation or precedent that this could link to? (I know nothing of this environment variable myself) |
well, I don't think there is much precedent for cross compiling ios applications from non macos systems without xcode installed, even though it is certainly possible. xcode sets the SDKROOT for the target platform and both clang and rust pick it up from there. alternative the sdk root can be provided with |
There's a fair bit of handling of |
well, worst case something doesn't compile. since apple believes everyone runs a mac, sdkroot should always be the target sdk and not the host sdk. this means that rust needs to remove the sdk root when compiling a build script or proc macro. without this change I can't cross compile any crate that uses cc-rs, like for example the objc-exception crate. |
Sorry but I've decided that the current development trajectory of |
I [for one] find all this environment variable chasing tedious and even counterproductive, so I what you would think of #664. |
This PR is explicitly about avoiding xcrun. I understand that that is fine for mac users, but this PR is explicitly about enabling linux users to build ios binaries. This by itself does not make developing ios applications possible from linux, but in conjunction with other efforts like the ones listed below would indeed make linux a suitable host environment for ios developers.
|
Currently xcrun is used to find sdk path and suggestion is to instead use xcrun to fire cc without having to bother with sdk path specifics in cc-rs. As for possible-future non-apple developments, why not aim for xcrun replacement there? I'd say it would be of great benefit for all projects... |
Tangentially related to this, I've implemented Apple SDK discovery in pure Rust in https://github.com/indygreg/PyOxidizer/blob/ae848c9083c9c8563d5890f5d39a8e04a1d71832/tugger-apple/src/sdk.rs. This includes parsing the This code probably isn't suitable for inclusion in this crate as-is. But if you want me to extract it to its own crate or incorporate it into cc-rs somehow, let's talk (in another issue presumably). As for this PR, externally specifying |
cc @thomcc. I see you're the only one watching this crate from the crate maintainers team [0]. So I guess you're the maintainer of this crate now? |
Sure, |
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 looks fine to me -- SDKROOT is a well known environment variable for configuring this (see https://github.com/swift-server/vscode-swift/blob/03f916559c98548ad932a989923a5b264124c8c2/src/toolchain/toolchain.ts#L295 as an example).
I think we'll need to sort out the situation with regards to other env vars (we special case IOS_DEPLOYMENT_TARGET and not others) and bitcode (which doesn't work on catalyst and won't work on watchOS soon), but that can be handled separately.
Apparently I don't have the ability to merge yet, though 😩. |
Can you rebase in order to remove the merge commit? I think we want a linear history like we do in the other repos. |
done |
Hi, I suspect that picking The bump that triggers the problem: rust-lang/rust#111701 |
when targeting ios you should set the SDKROOT to the ios sdk and not the host sdk. if you don't set the SDKROOT it should pick it up automatically. |
I think the |
So set it correctly or don't... |
I guess we can check if the sdk root is set correctly and if it isn't ignore it. Seems like the apple toolchain doesn't care? |
I looked deeper into the ci workflow and found that FYI the code filtering irrational env was originally introduced in commit rust-lang/rust@fe6d626 |
fyi, I found something here: rust-lang/cargo#7283 resolved by rust-lang/rust#64254
That's exactly what btw, shall we print some warning if the |
No, it shouldn't be wrong when compiling for the target. All the links you mention are saying that when compiling native parts, target env variables weren't sanitized correctly. Do build scripts compile in debug mode when passing the debug flag and release mode when passing the release flag? The point is that it doesn't really matter how build scripts are built, just needs to run on the machine it's built on. |
I haven't looked into the issues revealed after landing this deeply, but I think we should probably filter out irrational SDKROOTs. They'll be wrong when running We already do this for some environment variables. |
The main issue is that this PR breaks the cross build CI of |
This fixes #650