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

Use of environment variables can make use of .cargo/config impossible #463

Closed
jonas-schievink opened this issue Oct 5, 2020 · 4 comments
Labels
A-config Area: cross-toml config enhancement

Comments

@jonas-schievink
Copy link
Contributor

The Docker containers used by cross set various environment variables that cannot be overridden in any way. This causes various issues, because this makes Cargo silently ignore the configuration from .cargo/config.

  • On x86_64-unknown-linux-musl, cross sets CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER. This makes it impossible to use a custom linker wrapper by setting the linker key. Instead, I had to use the rustflags key to pass -Clinker.

  • On aarch64-unknown-linux-musl, cross sets CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER as well as RUSTFLAGS (!), which makes it impossible to use a custom linker without replacing rustc with a custom wrapper (which can be made to work by setting the RUSTC env var, but is a lot of work and a pretty gross hack).

@jonas-schievink
Copy link
Contributor Author

Ah I should note that most of this is only a problem due to rust-lang/cargo#5376

bors bot added a commit that referenced this issue Oct 23, 2020
464: aarch64-unknown-linux-musl: do not set RUSTFLAGS r=reitermarkus a=jonas-schievink

rust-lang/rust#46651 has been fixed, and this helps with #463

Co-authored-by: Jonas Schievink <[email protected]>
Co-authored-by: Jonas Schievink <[email protected]>
bors bot added a commit that referenced this issue Oct 24, 2020
464: aarch64-unknown-linux-musl: do not set RUSTFLAGS r=reitermarkus a=jonas-schievink

rust-lang/rust#46651 has been fixed, and this helps with #463

Co-authored-by: Jonas Schievink <[email protected]>
Co-authored-by: Jonas Schievink <[email protected]>
@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented May 28, 2022

This is fixable by using the environment variable passthrough, or by extending the Docker image (less than ideal). It might be a good idea to allow overrides of these variables in Cross.toml. For example, overriding CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER should be possible by adding it to [target.(...).env.passthrough].

We currently allow overriding the runner (sort of), but it might be good to also add keywords to override the linker and rustflags.

cross/src/cross_toml.rs

Lines 29 to 35 in c8df353

pub struct CrossTargetConfig {
xargo: Option<bool>,
image: Option<String>,
runner: Option<String>,
#[serde(default)]
env: CrossEnvConfig,
}

@Alexhuszagh Alexhuszagh added enhancement A-config Area: cross-toml config labels May 28, 2022
@Emilgardis
Copy link
Member

#682 would help for this

@Alexhuszagh
Copy link
Contributor

This has been fixed as of #869 and it is documented on the wiki now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-config Area: cross-toml config enhancement
Projects
None yet
Development

No branches or pull requests

3 participants