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

Support of cdylib crate types on iOS in Rust 1.46 breaks usual build workflows #79373

Closed
vimmerru opened this issue Nov 24, 2020 · 3 comments
Closed
Labels
O-ios Operating system: iOS

Comments

@vimmerru
Copy link

vimmerru commented Nov 24, 2020

PR #73516 added support of cdylib crate types on iOS. This new feature in Rust 1.46 added a lot of headache for iOS builds with cdylib targets. cdylib target is near impossible to build on iOS if you are using any crate with native dependencies (ex. openssl, libsodium, zmq). You can't just find .so files for all architectures to perform correct linking and any vendored build paths don't support iOS properly. Usual workflow is the following:

  1. You build staticlib and rely that native dependencies will be linked as frameworks later
  2. You setup right cocoapods in ObjectiveC/Swift wrapper.

As cargo doesn't support platform-dependent crate types rust-lang/cargo#4881 as a result a lot of projects that require iOS support are now broken on Rust 1.46.

Also seems usual iOS tools like cargo lipo don't support crate type overrides for the moment.

It works on 1.45 well because cargo just skips unsupported crate types on iOS and Android.

@jonas-schievink
Copy link
Contributor

That PR has been reverted in #77716 since other people ran into problems as well. It will be fixed in Rust 1.49 (currently in beta).

You can help detect these regressions earlier by testing against the nightly Rust channel in addition to stable.

@cutsoy
Copy link
Contributor

cutsoy commented Dec 3, 2020

I filed a PR in Cargo that makes it easier to switch crate-types at any step of your workflow: rust-lang/cargo#8789. This allows running cargo build --crate-type staticlib to override the crate type of the "final" product (not necessarily its dependencies), which is what most of us want. Would that be helpful in your situation?

@jonas-schievink
Copy link
Contributor

Closing this, as the PR has already been reverted and approved for stable-backport. Whether a stable patch release happens is still unclear though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-ios Operating system: iOS
Projects
None yet
Development

No branches or pull requests

3 participants