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

Explicitly choose x86 softfloat/hardfloat ABI #136146

Merged
merged 2 commits into from
Feb 3, 2025
Merged

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Jan 27, 2025

Part of #135408:
Instead of choosing this based on the target features listed in the target spec, make that choice explicit.
All built-in targets are being updated here; custom (JSON-defined) x86 (32bit and 64bit) softfloat targets need to explicitly set rustc-abi to x86-softfloat.

@rustbot
Copy link
Collaborator

rustbot commented Jan 27, 2025

r? @cjgillot

rustbot has assigned @cjgillot.
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

@rustbot rustbot added 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 Jan 27, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 27, 2025

These commits modify compiler targets.
(See the Target Tier Policy.)

@RalfJung
Copy link
Member Author

Cc @workingjubilee

@RalfJung RalfJung changed the title Explicit choose x86 softfloat/hardfloat ABI Explicitly choose x86 softfloat/hardfloat ABI Jan 27, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor

r? compiler

@rustbot rustbot assigned lcnr and unassigned cjgillot Jan 28, 2025
@RalfJung RalfJung force-pushed the x86-abi branch 3 times, most recently from bd35e7c to 89fa12a Compare January 28, 2025 01:40
("soft-float", Stability::Forbidden { reason: "unsound because it changes float ABI" }, &[]),
// This cannot actually be toggled, the ABI always fixes it, so it'd make little sense to
// stabilize. It must be in this list for the ABI check to be able to use it.
("soft-float", Stability::Unstable(sym::x87_target_feature), &[]),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this "forbidden" just leads to duplicate warnings so there's little point in doing that.

This makes riscv's forced-atomics the only remaining "forbidden" feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me.

Copy link
Member

@workingjubilee workingjubilee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that while it changes some error outputs, this PR shouldn't have any practical effect on people, correct? Except those using our unstable target-spec.json, I suppose, and they bought the ticket for the ride they're going to get.

r=me with nits addressed

match s.parse::<super::RustcAbi>() {
Ok(rustc_abi) => base.$key_name = Some(rustc_abi),
_ => return Some(Err(format!(
"'{s}' is not a valid value for rust-abi. \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"'{s}' is not a valid value for rust-abi. \
"'{s}' is not a valid value for rustc-abi. \

/// The Rustc-specific variant of the ABI used for this target.
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
pub enum RustcAbi {
/// On x86-32/64 only: do not use any FPU or SIMD registers for the ABI/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "ABI/"?

@RalfJung
Copy link
Member Author

RalfJung commented Jan 28, 2025

My understanding is that while it changes some error outputs, this PR shouldn't have any practical effect on people, correct? Except those using our unstable target-spec.json, I suppose, and they bought the ticket for the ride they're going to get.

Correct, for custom target specs this can add -soft-float if you don't also set rustc-abi: "x86-softfloat". This is probably surprising as there is no warning about this, it just silently happens.

Maybe we should land #136147 first; that would avoid changing behavior for target-spec users and instead just emit a warning.

@workingjubilee
Copy link
Member

I'm not worried about being maximally convenient for them, but either way. I'll try to review that when I finish my tea.

@lcnr
Copy link
Contributor

lcnr commented Jan 28, 2025

r? @workingjubilee

@rustbot
Copy link
Collaborator

rustbot commented Jan 28, 2025

Could not assign reviewer from: workingjubilee.
User(s) workingjubilee are either the PR author, already assigned, or on vacation. Please use r? to specify someone else to assign.

@bors
Copy link
Contributor

bors commented Jan 29, 2025

☔ The latest upstream changes (presumably #136225) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung
Copy link
Member Author

@bors r=workingjubilee

@bors bors 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 Feb 3, 2025
@RalfJung
Copy link
Member Author

RalfJung commented Feb 3, 2025

I have pulled the docs change into a separate PR: #136493.

@bors r=workingjubilee

@bors
Copy link
Contributor

bors commented Feb 3, 2025

📌 Commit 8596ce1 has been approved by workingjubilee

It is now in the queue for this repository.

@RalfJung
Copy link
Member Author

RalfJung commented Feb 3, 2025

@jackpot51 heads-up that Redox will have to explicitly select the x86 softfloat ABI once this lands, similar to what was needed for Linux.

@bors
Copy link
Contributor

bors commented Feb 3, 2025

⌛ Testing commit 8596ce1 with merge f027438...

@bors
Copy link
Contributor

bors commented Feb 3, 2025

☀️ Test successful - checks-actions
Approved by: workingjubilee
Pushing f027438 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 3, 2025
@bors bors merged commit f027438 into rust-lang:master Feb 3, 2025
7 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Feb 3, 2025
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f027438): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -0.8%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.5% [3.5%, 3.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.0% [-4.5%, -1.4%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-4.5%, 3.5%] 3

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 779.425s -> 778.951s (-0.06%)
Artifact size: 328.79 MiB -> 328.87 MiB (0.03%)

@RalfJung RalfJung deleted the x86-abi branch February 4, 2025 13:31
https123456789 added a commit to https123456789/bootloader that referenced this pull request Feb 5, 2025
ojeda pushed a commit to ojeda/linux that referenced this pull request Feb 6, 2025
When using Rust on the x86 architecture, we are currently using the
unstable target.json feature to specify the compilation target. Rustc is
going to change how softfloat is specified in the target.json file on
x86, thus update generate_rust_target.rs to specify softfloat using the
new option.

Note that if you enable this parameter with a compiler that does not
recognize it, then that triggers a warning but it does not break the
build.

Cc: <[email protected]> # Needed in 6.12.y and 6.13.y only (Rust is pinned in older LTSs).
Link: rust-lang/rust#136146
Signed-off-by: Alice Ryhl <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[ Added 6.13.y too to Cc: stable tag and added reasoning to avoid
  over-backporting. - Miguel ]
Signed-off-by: Miguel Ojeda <[email protected]>
ojeda pushed a commit to Rust-for-Linux/linux that referenced this pull request Feb 6, 2025
When using Rust on the x86 architecture, we are currently using the
unstable target.json feature to specify the compilation target. Rustc is
going to change how softfloat is specified in the target.json file on
x86, thus update generate_rust_target.rs to specify softfloat using the
new option.

Note that if you enable this parameter with a compiler that does not
recognize it, then that triggers a warning but it does not break the
build.

[ For future reference, this solves the following error:

        RUSTC L rust/core.o
      error: Error loading target specification: target feature
      `soft-float` is incompatible with the ABI but gets enabled in
      target spec. Run `rustc --print target-list` for a list of
      built-in targets

  - Miguel ]

Cc: <[email protected]> # Needed in 6.12.y and 6.13.y only (Rust is pinned in older LTSs).
Link: rust-lang/rust#136146
Signed-off-by: Alice Ryhl <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[ Added 6.13.y too to Cc: stable tag and added reasoning to avoid
  over-backporting. - Miguel ]
Signed-off-by: Miguel Ojeda <[email protected]>
ojeda pushed a commit to Rust-for-Linux/linux that referenced this pull request Feb 6, 2025
When using Rust on the x86 architecture, we are currently using the
unstable target.json feature to specify the compilation target. Rustc is
going to change how softfloat is specified in the target.json file on
x86, thus update generate_rust_target.rs to specify softfloat using the
new option.

Note that if you enable this parameter with a compiler that does not
recognize it, then that triggers a warning but it does not break the
build.

[ For future reference, this solves the following error:

        RUSTC L rust/core.o
      error: Error loading target specification: target feature
      `soft-float` is incompatible with the ABI but gets enabled in
      target spec. Run `rustc --print target-list` for a list of
      built-in targets

  - Miguel ]

Cc: <[email protected]> # Needed in 6.12.y and 6.13.y only (Rust is pinned in older LTSs).
Link: rust-lang/rust#136146
Signed-off-by: Alice Ryhl <[email protected]>
Acked-by: Dave Hansen <[email protected]> # for x86
Link: https://lore.kernel.org/r/[email protected]
[ Added 6.13.y too to Cc: stable tag and added reasoning to avoid
  over-backporting. - Miguel ]
Signed-off-by: Miguel Ojeda <[email protected]>
@@ -28,7 +28,7 @@ rm -rf linux || true
# Download Linux at a specific commit
mkdir -p linux
git -C linux init
git -C linux remote add origin https://github.com/Rust-for-Linux/linux.git
git -C linux remote add origin https://github.com/Darksonn/linux.git
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs a cfg(bootstrap) to get bumped on release

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow, what does the Linux kernel have to do with bootstraping?

I think I did everything mentioned at https://rustc-dev-guide.rust-lang.org/tests/rust-for-linux.html.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I missed that the maintainers have taken responsibility for flipping this back and don't need extra reminders from Release.

Copy link
Contributor

@ojeda ojeda Feb 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow, what does the Linux kernel have to do with bootstraping?

I think I did everything mentioned at https://rustc-dev-guide.rust-lang.org/tests/rust-for-linux.html.

I am confused too -- this seems fine.

When v6.14-rc3 releases in a couple weeks, which is the one I am planning to get the fix into, I will send a PR with that tag, and we will be in the normal situation again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I missed that the maintainers have taken responsibility for flipping this back and don't need extra reminders from Release.

I don't think there is a technical requirement to flip it back. I mean, the idea is that we do so, but it is orthogonal to the release, no? It is just a CI test. For instance, in an ideal world, we could be testing several supported Linux versions (e.g. the latest LTS).

phil-opp added a commit to phil-opp/blog_os that referenced this pull request Feb 10, 2025
This additional field is required by the Rust compiler since rust-lang/rust#136146 .
phil-opp added a commit to phil-opp/blog_os that referenced this pull request Feb 10, 2025
The Rust compiler now requires an explicit `rustc-abi: x86-softfloat` field when using the soft-float target feature. This was added in rust-lang/rust#136146 and is part of the latest nightlies.

I updated the post branches in commit 688a21e
github-actions bot pushed a commit to anon503/linux that referenced this pull request Feb 11, 2025
commit 6273a05 upstream.

When using Rust on the x86 architecture, we are currently using the
unstable target.json feature to specify the compilation target. Rustc is
going to change how softfloat is specified in the target.json file on
x86, thus update generate_rust_target.rs to specify softfloat using the
new option.

Note that if you enable this parameter with a compiler that does not
recognize it, then that triggers a warning but it does not break the
build.

[ For future reference, this solves the following error:

        RUSTC L rust/core.o
      error: Error loading target specification: target feature
      `soft-float` is incompatible with the ABI but gets enabled in
      target spec. Run `rustc --print target-list` for a list of
      built-in targets

  - Miguel ]

Cc: <[email protected]> # Needed in 6.12.y and 6.13.y only (Rust is pinned in older LTSs).
Link: rust-lang/rust#136146
Signed-off-by: Alice Ryhl <[email protected]>
Acked-by: Dave Hansen <[email protected]> # for x86
Link: https://lore.kernel.org/r/[email protected]
[ Added 6.13.y too to Cc: stable tag and added reasoning to avoid
  over-backporting. - Miguel ]
Signed-off-by: Miguel Ojeda <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc CI-spurious-fail-msvc CI spurious failure: target env msvc merged-by-bors This PR was explicitly merged by bors. 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. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.