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

ignore "target-cpu=native" when cross compiling with "target" #15024

Open
KonradHoeffner opened this issue Jan 7, 2025 · 2 comments
Open

ignore "target-cpu=native" when cross compiling with "target" #15024

KonradHoeffner opened this issue Jan 7, 2025 · 2 comments
Labels
A-rustflags Area: rustflags C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@KonradHoeffner
Copy link

KonradHoeffner commented Jan 7, 2025

Problem

-Ctarget-cpu=native in rustflags displays a huge amount of warnings when also using the "target" parameter for cross compilation.

Proposed Solution

Ignore the target-cpu=native parameter when the target parameter is also set (i.e. when cross compiling) and write a single warning message instead of multiple pages, like:

'target-cpu=native' is not compatible with target platform of 'aarch64-unknown-linux-gnu' (ignoring features) 

Notes

Please correct me if this is working as intended, here are my assumptions and the use case:

  1. Rust programs should be as fast as possible and I'm never giving executables built on my machine to others (there are GitHub actions that create release binaries and Docker images for that) so it seems reasonable to include rustflags = ["-Ctarget-cpu=native"] under the [build] section of ~/.cargo/config.toml.
  2. I want to add the ARM (aarch64) platform to a specific Rust application but the development machine runs on the amd64 platform, so to confirm that cargo check works before adding the new platform to the GitHub action, I'm using cargo check --target aarch64-unknown-linux-gnu. However this will output several pages of warnings like this:
'+adx' is not a recognized feature for this target (ignoring feature)
'+avx2' is not a recognized feature for this target (ignoring feature)
'-hreset' is not a recognized feature for this target (ignoring feature)
'+movdiri' is not a recognized feature for this target (ignoring feature)
'-serialize' is not a recognized feature for this target (ignoring feature)
'-sha512' is not a recognized feature for this target (ignoring feature)
'+vpclmulqdq' is not a recognized feature for this target (ignoring feature)
'+avx512vl' is not a recognized feature for this target (ignoring feature)
'-uintr' is not a recognized feature for this target (ignoring feature)
'-cf' is not a recognized feature for this target (ignoring feature)
@KonradHoeffner KonradHoeffner added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Jan 7, 2025
@epage epage added the A-rustflags Area: rustflags label Jan 7, 2025
@epage
Copy link
Contributor

epage commented Jan 7, 2025

RUSTFLAGS is opaque to cargo so we cannot filter out values dependent on the context.

#12739 is tracking finding cargo-native forms for different RUSTFLAGS which could allow smarter behavior.

@epage
Copy link
Contributor

epage commented Jan 7, 2025

I could see rustc having a consolidated warning or error when native isn't related to --target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustflags Area: rustflags C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants