Skip to content

Emit future-incompatibility lint when calling/declaring functions with vectors that require missing target feature#127731

Merged
bors merged 1 commit intorust-lang:masterfrom
veluca93:abi_checks
Oct 25, 2024
Merged

Emit future-incompatibility lint when calling/declaring functions with vectors that require missing target feature#127731
bors merged 1 commit intorust-lang:masterfrom
veluca93:abi_checks

Conversation

@veluca93
Copy link
Contributor

@veluca93 veluca93 commented Jul 14, 2024

On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.)

As discussed in rust-lang/lang-team#235, this turns out to very easily lead to unsound code.

This commit makes it a post-monomorphization error to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI.

See the nomination comment for more discussion.

r? RalfJung

Part of #116558

@rustbot
Copy link
Collaborator

rustbot commented Jul 14, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @RalfJung (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@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 Jul 14, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jul 14, 2024

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

Please also add some tests so that we can see this check in action.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@veluca93 veluca93 force-pushed the abi_checks branch 2 times, most recently from ef2609c to e8302b3 Compare July 28, 2024 20:36
@RalfJung
Copy link
Member

RalfJung commented Aug 1, 2024

Looks good for the initial draft, let's see what crater says. :)

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 1, 2024
Emit error when calling/declaring functions with unavailable vectors.

On some architectures, vector types may have a different ABI when relevant target features are enabled.

As discussed in rust-lang/lang-team#235, this turns out to very easily lead to unsound code.

This commit makes it an error to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant.

r? RalfJung
@bors
Copy link
Collaborator

bors commented Aug 1, 2024

⌛ Trying commit e8302b3 with merge 7587ff3...

@bors
Copy link
Collaborator

bors commented Aug 1, 2024

☀️ Try build successful - checks-actions
Build commit: 7587ff3 (7587ff3622fbec0abf6ac551eab5226f22f5d958)

@RalfJung
Copy link
Member

RalfJung commented Aug 1, 2024

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-127731 created and queued.
🤖 Automatically detected try build 7587ff3
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@bors
Copy link
Collaborator

bors commented Oct 25, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 25, 2024
@RalfJung
Copy link
Member

@bors retry error: linking with link.exe failed: exit code: 1104 on dist-x86_64-msvc

@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 Oct 25, 2024
@RalfJung RalfJung added the CI-spurious-fail-msvc CI spurious failure: target env msvc label Oct 25, 2024
@bors
Copy link
Collaborator

bors commented Oct 25, 2024

⌛ Testing commit 5af56ca with merge 6faf0bd...

@bors
Copy link
Collaborator

bors commented Oct 25, 2024

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 6faf0bd to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 25, 2024
@bors bors merged commit 6faf0bd into rust-lang:master Oct 25, 2024
@rustbot rustbot added this to the 1.84.0 milestone Oct 25, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6faf0bd): comparison URL.

Overall result: ❌ regressions - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
5.0% [0.3%, 16.9%] 77
Regressions ❌
(secondary)
4.7% [0.1%, 29.4%] 30
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.9% [-0.1%, 16.9%] 78

Max RSS (memory usage)

Results (primary 4.1%, secondary 3.6%)

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)
4.1% [0.8%, 15.8%] 69
Regressions ❌
(secondary)
3.6% [1.0%, 7.4%] 24
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.1% [0.8%, 15.8%] 69

Cycles

Results (primary 11.4%, secondary 14.0%)

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)
11.4% [1.5%, 26.1%] 54
Regressions ❌
(secondary)
14.0% [2.0%, 38.1%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 11.4% [1.5%, 26.1%] 54

Binary size

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

Bootstrap: 790.301s -> 788.765s (-0.19%)
Artifact size: 333.71 MiB -> 333.61 MiB (-0.03%)

@rustbot rustbot added the perf-regression Performance regression. label Oct 25, 2024
@Kobzol
Copy link
Member

Kobzol commented Oct 25, 2024

This looks pretty bad, even when ignoring the incr-unchanged results. I'd say that we revert it ASAP and then try to figure out how to improve perf.

@RalfJung
Copy link
Member

Oh damn, we should have done a perf run... yeah, first order of business is a revert. @veluca93 can you prepare a revert?

@lqd
Copy link
Member

lqd commented Oct 25, 2024

I was preparing one and have opened #132152

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 26, 2024
Revert rust-lang#127731 "Emit error when calling/declaring functions with unavailable …"

This reverts rust-lang#127731 due to the unexpected [perf regressions](rust-lang#127731 (comment)) and to give time to mitigate the regressions before re-landing it.

r? `@RalfJung` cc `@veluca93`
veluca93 added a commit to veluca93/rust that referenced this pull request Oct 26, 2024
On some architectures, vector types may have a different ABI depending
on whether the relevant target features are enabled. (The ABI when the
feature is disabled is often not specified, but LLVM implements some
de-facto ABI.)

As discussed in rust-lang/lang-team#235, this turns out to very easily
lead to unsound code.

This commit makes it a post-monomorphization future-incompat warning to
declare or call functions using those vector types in a context in which
the corresponding target features are disabled, if using an ABI for
which the difference is relevant. This ensures that these functions are
always called with a consistent ABI.

See the [nomination
comment](rust-lang#127731 (comment))
for more discussion.

Part of rust-lang#116558
veluca93 added a commit to veluca93/rust that referenced this pull request Oct 26, 2024
On some architectures, vector types may have a different ABI depending
on whether the relevant target features are enabled. (The ABI when the
feature is disabled is often not specified, but LLVM implements some
de-facto ABI.)

As discussed in rust-lang/lang-team#235, this turns out to very easily
lead to unsound code.

This commit makes it a post-monomorphization future-incompat warning to
declare or call functions using those vector types in a context in which
the corresponding target features are disabled, if using an ABI for
which the difference is relevant. This ensures that these functions are
always called with a consistent ABI.

See the [nomination comment](rust-lang#127731 (comment))
for more discussion.

Part of rust-lang#116558
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 26, 2024
Emit warning when calling/declaring functions with unavailable vectors.

On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.)

As discussed in rust-lang/lang-team#235, this turns out to very easily lead to unsound code.

This commit makes it a post-monomorphization future-incompat warning to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI.

See the [nomination comment](rust-lang#127731 (comment)) for more discussion.

Part of rust-lang#116558

r? RalfJung
veluca93 added a commit to veluca93/rust that referenced this pull request Oct 26, 2024
On some architectures, vector types may have a different ABI depending
on whether the relevant target features are enabled. (The ABI when the
feature is disabled is often not specified, but LLVM implements some
de-facto ABI.)

As discussed in rust-lang/lang-team#235, this turns out to very easily
lead to unsound code.

This commit makes it a post-monomorphization future-incompat warning to
declare or call functions using those vector types in a context in which
the corresponding target features are disabled, if using an ABI for
which the difference is relevant. This ensures that these functions are
always called with a consistent ABI.

See the [nomination comment](rust-lang#127731 (comment))
for more discussion.

Part of rust-lang#116558
veluca93 added a commit to veluca93/rust that referenced this pull request Oct 26, 2024
On some architectures, vector types may have a different ABI depending
on whether the relevant target features are enabled. (The ABI when the
feature is disabled is often not specified, but LLVM implements some
de-facto ABI.)

As discussed in rust-lang/lang-team#235, this turns out to very easily
lead to unsound code.

This commit makes it a post-monomorphization future-incompat warning to
declare or call functions using those vector types in a context in which
the corresponding target features are disabled, if using an ABI for
which the difference is relevant. This ensures that these functions are
always called with a consistent ABI.

See the [nomination comment](rust-lang#127731 (comment))
for more discussion.

Part of rust-lang#116558
@Kobzol
Copy link
Member

Kobzol commented Oct 29, 2024

Reverted in #132152.

@rustbot label: +perf-regression-triaged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. CI-spurious-fail-msvc CI spurious failure: target env msvc L-abi_unsupported_vector_types Lint: abi_unsupported_vector_types merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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-lang Relevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.