Use cargo-ndk as a _LINKER wrapper to pass --target to Clang #108
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Okey, yet another iteration on figuring out how to handle this. This is my last idea for now ;-p
This is an alternative workaround for #92 that's similar to the solution used in ndk-build except that the
--target=<triple><api-level>
argument for Clang is injected by using cargo-ndk as a linker wrapper instead of trying to modify CARGO_ENCODED_RUSTFLAGS.It turned out to be practically impossible to be able to reliably set CARGO_ENCODED_RUSTFLAGS without risking trampling over rustflags that might be configured via Cargo (for example
target.<cfg>.rustflags
are especially difficult to read outside of cargo itself)This approach avoids hitting the command line length limitations of the current workaround and avoids needing temporary hard links or copying the cargo-ndk binary to the target/ directory.
Even though we've only seen quoting issues with the Windows
.cmd
wrappers this change to avoid using the wrapper scripts is being applied consistently for all platforms. E.g. considering the upstream recommendation to avoid the wrapper scripts if possible:https://android-review.googlesource.com/c/platform/ndk/+/2134712
Fixes: #92
Fixes: #104
Addresses: android/ndk#1856
--
With this approach we're again able to build our project at Embark which currently fails to compile due to the
command line is to long
errors mentioned in #104. This solution is also compatible with the way that we configure rustflags via.cargo/config.toml
.Compared to #105 it seems better to be side stepping the Clang wrappers entirely and then not needing to patch them.
Compared to #107 this ends up being very similar to but simpler than wrapping rustc and is more targeted for this issue.
Cc: @MarijnS95