Skip to content

Commit

Permalink
Remove deprecated Cargo environment variables
Browse files Browse the repository at this point in the history
Setting AR and CC via Cargo is not supported. AR is still documented but marked deprecated here:
https://doc.rust-lang.org/nightly/cargo/reference/config.html#targettriplear
https://doc.rust-lang.org/rustc/codegen-options/index.html#ar

Setting CC via config is not documented at all now, and searching for cc
in Cargo source code also comes up empty. It's also missing from the
`rustc` codegen options link above.

I also removed a comment reference to RUSTFLAGS which doesn't appear to be
accurate (we don't set or modify RUSTFLAGS anywhere in this library)
  • Loading branch information
dcsommer committed Aug 2, 2021
1 parent 67fb933 commit 1cdb6ea
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions plugin/src/main/kotlin/com/nishtahir/CargoBuildTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,6 @@ open class CargoBuildTask : DefaultTask() {
} else {
cargoExtension.toolchainDirectory
}
// Be aware that RUSTFLAGS can have problems with embedded
// spaces, but that shouldn't be a problem here.
val cc = File(toolchainDirectory, "${toolchain.cc(apiLevel)}").path;
val cxx = File(toolchainDirectory, "${toolchain.cxx(apiLevel)}").path;
val ar = File(toolchainDirectory, "${toolchain.ar(apiLevel)}").path;

// For cargo: like "CARGO_TARGET_I686_LINUX_ANDROID_CC". This is really weakly
// documented; see https://github.com/rust-lang/cargo/issues/5690 and follow
// links from there.
environment("CARGO_TARGET_${toolchain_target}_CC", cc)
environment("CARGO_TARGET_${toolchain_target}_AR", ar)

val linker_wrapper =
if (System.getProperty("os.name").startsWith("Windows")) {
Expand All @@ -187,6 +176,10 @@ open class CargoBuildTask : DefaultTask() {
}
environment("CARGO_TARGET_${toolchain_target}_LINKER", linker_wrapper.path)

val cc = File(toolchainDirectory, "${toolchain.cc(apiLevel)}").path;
val cxx = File(toolchainDirectory, "${toolchain.cxx(apiLevel)}").path;
val ar = File(toolchainDirectory, "${toolchain.ar(apiLevel)}").path;

// For build.rs in `cc` consumers: like "CC_i686-linux-android". See
// https://github.com/alexcrichton/cc-rs#external-configuration-via-environment-variables.
environment("CC_${toolchain.target}", cc)
Expand Down

0 comments on commit 1cdb6ea

Please sign in to comment.