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

cargo-apk: Reimplement NDK r23 -lgcc workaround using RUSTFLAGS #270

Merged
merged 1 commit into from
May 12, 2022

Conversation

MarijnS95
Copy link
Member

Fixes #265, CC @Mercesa

Any flags passed directly to cargo rustc will only be passed to the final compiler invocation. However cdylib library targets in transitive (dependency) crates will still be built (despite not being used in the final binary, that's what rlibs are for), but our NDK r23 workaround flags will not reach these compiler invocations rendering b912a6b ("cargo-apk: Work around missing libgcc on NDK r23 with linker script (#189)") ineffective.

The same page that documents this discrepancy suggests to resort to RUSTFLAGS if arguments are intended for all compiler invocations, which is our intended use-case and unblocks builds with transitive cdylib dependencies such as hyper in #265.

@dvc94ch
Copy link
Contributor

dvc94ch commented May 11, 2022

Lgtm. Believe it was solved via the library search path in xbuild too

@MarijnS95
Copy link
Member Author

Lgtm. Believe it was solved via the library search path in xbuild too

You seem to have solved this there by emitting the libgcc.a linker script in the repackaged NDK directly, next to the other libraries 😁

@MarijnS95
Copy link
Member Author

MarijnS95 commented May 11, 2022

And yes, all arguments are chained into a rust_flags string and finally end up in RUSTFLAGS.

EDIT: It seems xbuild uses -Clink-arg=-L{} though, instead of a plain -L. It works here...

@Mercesa
Copy link

Mercesa commented May 11, 2022

It works on my machine, tested it locally. Solves the problems we were having with cdylibs breaking the android build steps.

cargo-apk/CHANGELOG.md Outdated Show resolved Hide resolved
Any flags passed directly to `cargo rustc` will only be passed _to the
final compiler invocation_.  However `cdylib` library targets in
transitive (dependency) crates will still be built (despite not being
used in the final binary, that's what `rlib`s are for), but our NDK r23
workaround flags will not reach these compiler invocations rendering
b912a6b ("cargo-apk: Work around missing libgcc on NDK r23 with linker
script (#189)") ineffective.

[The same page] that documents this discrepancy suggests to resort to
`RUSTFLAGS` if arguments are intended for all compiler invocations,
which is our intended use-case and unblocks builds with transitive
`cdylib` dependencies such as `hyper` in [#265].

[The same page]: https://doc.rust-lang.org/cargo/commands/cargo-rustc.html#description
[#265]: #265
@MarijnS95 MarijnS95 merged commit b3b9a95 into master May 12, 2022
@MarijnS95 MarijnS95 deleted the global-lgcc-workaround branch May 12, 2022 09:50
@MarijnS95 MarijnS95 added the type: api Design and usability label Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: api Design and usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot find libgcc.a in the cargo-apk-temp-extra-link-libraries
4 participants