Skip to content

Don't add empty target features for target-cpu=native on macOS#153763

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nikic:target-cpu-native-fix
Mar 12, 2026
Merged

Don't add empty target features for target-cpu=native on macOS#153763
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nikic:target-cpu-native-fix

Conversation

@nikic
Copy link
Contributor

@nikic nikic commented Mar 12, 2026

LLVM does not support host feature detection (only host cpu detection) on apple platforms. As such, the returned feature string will be empty. Adding this empty string to the target-features attribute results in a verifier error on LLVM 22.

Fix this by not adding the empty string to the target features. The reason why this was not caught by the target-cpu-native test is that it requires a function that adds some target features, otherwise the attribute is omitted entirely. We achieve this with a somewhat peculiar construction that enables neon if it's already enabled. (This is to avoid enabling it on softfloat targets.)

Fixes #153397.

LLVM does not support host feature detection (only host cpu
detection) on apple platforms. As such, the returned feature
string will be empty. Adding this empty string to the target-features
attribute results in a verifier error on LLVM 22.

Fix this by not adding the empty string to the target features.
The reason why this was not caught by the target-cpu-native test
is that it requires a function that adds *some* target features,
otherwise the attribute is omitted entirely. We achieve this with
a somewhat peculiar construction that enables `neon` if it's
already enabled. (This is to avoid enabling it on softfloat targets.)
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 12, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 12, 2026

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 16 candidates

@theemathas theemathas added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Mar 12, 2026
@lqd
Copy link
Member

lqd commented Mar 12, 2026

Thanks for the super quick fix!

r? me and r=me when green

@rustbot rustbot assigned lqd and unassigned davidtwco Mar 12, 2026
@nikic
Copy link
Contributor Author

nikic commented Mar 12, 2026

@bors r=lqd

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 12, 2026

📌 Commit 0670491 has been approved by lqd

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 12, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Mar 12, 2026
Don't add empty target features for target-cpu=native on macOS

LLVM does not support host feature detection (only host cpu detection) on apple platforms. As such, the returned feature string will be empty. Adding this empty string to the target-features attribute results in a verifier error on LLVM 22.

Fix this by not adding the empty string to the target features. The reason why this was not caught by the target-cpu-native test is that it requires a function that adds *some* target features, otherwise the attribute is omitted entirely. We achieve this with a somewhat peculiar construction that enables `neon` if it's already enabled. (This is to avoid enabling it on softfloat targets.)

Fixes rust-lang#153397.
rust-bors bot pushed a commit that referenced this pull request Mar 12, 2026
Rollup of 11 pull requests

Successful merges:

 - #153726 (Add optional CI job to build the compiler with the parallel frontend)
 - #153763 (Don't add empty target features for target-cpu=native on macOS)
 - #153432 (Fix some comments about dataflow analysis.)
 - #153529 (Fix LegacyKeyValueFormat report from docker build: pr)
 - #153694 (fix(query): Pass Query Key to `value_from_cycle_error`)
 - #153708 (de-non_const `Iterator` trait methods)
 - #153717 (unused_macro_rules switched used and unused comments)
 - #153736 (add test that an incomplete feature emits a warning)
 - #153748 (editorconfig: css uses tabs)
 - #153750 (rustc-dev-guide subtree update)
 - #153762 (actually make the is-fn test test what it says it tests)
Zalathar added a commit to Zalathar/rust that referenced this pull request Mar 12, 2026
Don't add empty target features for target-cpu=native on macOS

LLVM does not support host feature detection (only host cpu detection) on apple platforms. As such, the returned feature string will be empty. Adding this empty string to the target-features attribute results in a verifier error on LLVM 22.

Fix this by not adding the empty string to the target features. The reason why this was not caught by the target-cpu-native test is that it requires a function that adds *some* target features, otherwise the attribute is omitted entirely. We achieve this with a somewhat peculiar construction that enables `neon` if it's already enabled. (This is to avoid enabling it on softfloat targets.)

Fixes rust-lang#153397.
rust-bors bot pushed a commit that referenced this pull request Mar 12, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #153726 (Add optional CI job to build the compiler with the parallel frontend)
 - #153763 (Don't add empty target features for target-cpu=native on macOS)
 - #153432 (Fix some comments about dataflow analysis.)
 - #153529 (Fix LegacyKeyValueFormat report from docker build: pr)
 - #153694 (fix(query): Pass Query Key to `value_from_cycle_error`)
 - #153717 (unused_macro_rules switched used and unused comments)
 - #153736 (add test that an incomplete feature emits a warning)
 - #153748 (editorconfig: css uses tabs)
 - #153750 (rustc-dev-guide subtree update)
 - #153762 (actually make the is-fn test test what it says it tests)
@madsmtm madsmtm added the O-macos Operating system: macOS label Mar 12, 2026
@rust-bors rust-bors bot merged commit 0102e91 into rust-lang:main Mar 12, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 12, 2026
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Mar 16, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#153726 (Add optional CI job to build the compiler with the parallel frontend)
 - rust-lang/rust#153763 (Don't add empty target features for target-cpu=native on macOS)
 - rust-lang/rust#153432 (Fix some comments about dataflow analysis.)
 - rust-lang/rust#153529 (Fix LegacyKeyValueFormat report from docker build: pr)
 - rust-lang/rust#153694 (fix(query): Pass Query Key to `value_from_cycle_error`)
 - rust-lang/rust#153717 (unused_macro_rules switched used and unused comments)
 - rust-lang/rust#153736 (add test that an incomplete feature emits a warning)
 - rust-lang/rust#153748 (editorconfig: css uses tabs)
 - rust-lang/rust#153750 (rustc-dev-guide subtree update)
 - rust-lang/rust#153762 (actually make the is-fn test test what it says it tests)
@rustbot
Copy link
Collaborator

rustbot commented Mar 19, 2026

beta backport approved as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them.

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs beta-accepted Accepted for backporting to the compiler in the beta channel. beta-nominated Nominated for backporting to the compiler in the beta channel. O-macos Operating system: macOS S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: LLVM ERROR "Broken module" with -C target-cpu=native on aarch64-apple-darwin (Apple M5, LLVM 22.1.0)

6 participants