cross-rs/cross

Incorrect warning about invalid CARGO_TARGET_arch_RUSTFLAGS being unused

Wilfred opened this issue · 2 comments

Checklist

Describe your issue

When configuring RUSTFLAGS with cross, I get a warning about the flag being ignored, but it does seem to be respected.

$ CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGs='-C link-arg=-s' cross build --release --target x86_64-unknown-linux-musl
warning: Environment variables are expected to use uppercase letters and underscores, the variable `CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGs` will be ignored and have no effect

I believe this is the correct flag according to https://github.com/cross-rs/cross/wiki/Configuration#cargo-configuration, and I do seem to be getting a binary with static linking.

What target(s) are you cross-compiling for?

No response

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5

Example

$ cargo init --bin helloworld
$ cd helloworld

$ CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGs='-C link-arg=-s' cross build --release --target x86_64-unknown-linux-musl
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
warning: Environment variables are expected to use uppercase letters and underscores, the variable `CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGs` will be ignored and have no effect
warning: Environment variables are expected to use uppercase letters and underscores, the variable `CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGs` will be ignored and have no effect
warning: Environment variables are expected to use uppercase letters and underscores, the variable `CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGs` will be ignored and have no effect
    Finished release [optimized] target(s) in 0.08s

$ ldd target/x86_64-unknown-linux-musl/release/helloworld
	statically linked

Additional information / notes

No response

CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGs

The problem is the last s is not upper case. You have to use CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS.

I do seem to be getting a binary with static linking.

x86_64-unknown-linux-musl uses static linking by default.

User error, thanks for the pointers!