Skip to content

Commit

Permalink
Use cargo-ndk as a _LINKER wrapper to pass --target to Clang
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rib authored and bbqsrc committed May 22, 2023
1 parent 49a2ef3 commit d6cdbf4
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 295 deletions.
148 changes: 12 additions & 136 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,3 @@ pathos = "0.3.0"
serde = { version = "1.0.152", features = ["derive"] }
toml = "0.5.10"
version_check = "0.9.4"

[target.'cfg(windows)'.dependencies]
tempfile = "3.5.0"
wargs = "0.1.0"
Loading

0 comments on commit d6cdbf4

Please sign in to comment.