Skip to content
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

aarch64-apple-ios cannot be cross-compiled from Linux and causes cargo doc failures #76584

Closed
bbqsrc opened this issue Sep 10, 2020 · 5 comments · Fixed by #77202
Closed

aarch64-apple-ios cannot be cross-compiled from Linux and causes cargo doc failures #76584

bbqsrc opened this issue Sep 10, 2020 · 5 comments · Fixed by #77202
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. O-ios Operating system: iOS

Comments

@bbqsrc
Copy link

bbqsrc commented Sep 10, 2020

All up there seems to two issues:

  • Docs cannot be generated for iOS from non-macOS hosts because of a dependency on a binary for generating linker flags that only exists on macOS
  • Errors are not being propagated from this part of the build process to rustbuild, leaving for a headscratcher

I added an aarch64-apple-ios requirement to the docs.rs metadata in one of my crates, which caused a build failure on docs.rs. rust-lang/docs.rs#1040

Upon trying to reproduce this issue and find a fix, I hit the issue while trying to build rustc with the target aarch64-apple-ios from an x86_64 Linux host.

$ ./x.py build --target aarch64-apple-ios
Updating only changed submodules
Submodules updated in 0.02 seconds
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s


error occurred: No such file or directory (os error 2)


failed to run: /.../rust/build/bootstrap/debug/bootstrap build --target aarch64-apple-ios
Build completed unsuccessfully in 0:00:00

Not ideal output. 😛

The reason this happens is quite straightforward: ios and tvos targets use the apple_sdk_base module to resolve the pre_link_args field, and it is fallable.

The logic in the get_sdk_root function seems a little faulty, as it does a simple check for existence of a directory from the environment variable SDKROOT, then if that fails, it tries to run the xcrun binary which only exists on macOS hosts. That xcrun failure is a hard failure.

As stated in rust-lang/docs.rs#1040, a workaround for at least generating documentation is to provide SDKROOT with a path to an empty directory to iPhoneOS.platform.

No such issue occurs on *-apple-darwin because an entirely different codepath is taken.

I am not sure of the right course of action to fix this:

  1. Change ios and tvos targets to not require pre_link_flags to be set, like macOS, and let build failures occur after printing a warning so the user can at least fix the issue
  2. Add a hack for doc so that at least docs.rs can generate documentation for ios
  3. Don't change this behaviour at all, but fix the error message so that cross-compiling devs won't just stare blindly at their screen asking "why me"

My preference is for the first option, and I'm quite happy to contribute a fix for it, though I would need assistance in successfully cross-compiling rustc for macOS from Linux. 😄


It is probable that this is the same issue: #42084.

@bbqsrc bbqsrc added the C-bug Category: This is a bug. label Sep 10, 2020
@jyn514 jyn514 added A-cross Area: Cross compilation O-ios Operating system: iOS labels Sep 10, 2020
@jyn514
Copy link
Member

jyn514 commented Sep 10, 2020

My preference is for the first option, and I'm quite happy to contribute a fix for it, though I would need assistance in successfully cross-compiling rustc for macOS from Linux. 😄

You shouldn't need to cross-compile rustc, if you can build stage1 on linux and then try using stage1 to cross-compile to iOS that should be enough to make sure it's fixed. Note that cross-compiling rustc itself is different from cross-compiling using the rustc you've built for the host target.

@bbqsrc
Copy link
Author

bbqsrc commented Sep 10, 2020

and then try using stage1 to cross-compile to iOS

How do I go about doing that? I've read the rustc dev guide a couple of times and I'm still not certain.

@jyn514
Copy link
Member

jyn514 commented Sep 10, 2020

Follow the instructions in https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html?highlight=toolchain#creating-a-rustup-toolchain, then run cargo +stage1 doc --target aarch64-apple-ios like you normally would.

@jyn514
Copy link
Member

jyn514 commented Sep 20, 2020

@bbqsrc let me know if you need help working on this :)

@bbqsrc
Copy link
Author

bbqsrc commented Sep 20, 2020

Ah, been side tracked by life. I intend to look into this next weekend at this stage. Will definitely ping if I need anything, most likely on Zulip. 😄 thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. O-ios Operating system: iOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants