Skip to content

Add (back) unsupported_calling_conventions lint to reject more invalid calling conventions #141435

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

Merged
merged 5 commits into from
Jun 9, 2025

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented May 23, 2025

This adds back the unsupported_calling_conventions lint that was removed in #129935, in order to start the process of dealing with #137018. Specifically, we are going for the plan laid out here:

  • thiscall, stdcall, fastcall, cdecl should only be accepted on x86-32
  • vectorcall should only be accepted on x86-32 and x86-64

The difference to the status quo is that:

  • We stop accepting stdcall, fastcall on targets that are windows && non-x86-32 (we already don't accept these on targets that are non-windows && non-x86-32)
  • We stop accepting cdecl on targets that are non-x86-32
  • (There is no difference for thiscall, this was already a hard error on non-x86-32)
  • We stop accepting vectorcall on targets that are windows && non-x86-*

Vectorcall is an unstable ABI so we can just make this a hard error immediately. The others are stable, so we emit the unsupported_calling_conventions forward-compat lint. I set up the lint to show up in dependencies via cargo's future-compat report immediately, but we could also make it show up just for the local crate first if that is preferred.

try-job: i686-msvc-1
try-job: x86_64-msvc-1
try-job: test-various

@rustbot
Copy link
Collaborator

rustbot commented May 23, 2025

r? @lcnr

rustbot has assigned @lcnr.
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
Copy link
Collaborator

rustbot commented May 23, 2025

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

@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 May 23, 2025
@RalfJung RalfJung force-pushed the unsupported_calling_conventions branch 3 times, most recently from f4146aa to b8f4367 Compare May 23, 2025 12:09
@RalfJung RalfJung added the T-lang Relevant to the language team label May 23, 2025
@RalfJung
Copy link
Member Author

@rust-lang/lang following positive vibes expressed here, I'd like to land this PR as a first step to implement the plan from that issue. Can we get this FCPd? :)

The one potential open question here is whether this should be a regular FCW first or whether it can immediately become an FCW that shows up in dependencies. I assume stdcall and fastcall are sufficiently rare that we can go for report-in-deps immediately (since they already get rejected on non-x86-32 non-Windows targets). "cdecl" might be more widely used though so it may be worth ramping up the lint more slowly.

@RalfJung RalfJung added the I-lang-nominated Nominated for discussion during a lang team meeting. label May 23, 2025
@traviscross traviscross added P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 23, 2025
@traviscross
Copy link
Contributor

Searching across GitHub, there are 506 Rust file hits on extern "cdecl".

Regarding whether to fire the FCW in deps immediately, I lean toward it probably being OK. Given that this may show up in cfg-heavy code, I could imagine that many library authors may not notice until their downstreams report anyway. But if anyone on lang feels we should walk this more slowly, that's what I'd estimate we'd do, so I'm curious to hear what others think.

@RalfJung
Copy link
Member Author

Oh that's the syntax for doing such a search... I tried and failed to get a similar result out of github search.^^

@traviscross traviscross changed the title add (back) unsupported_calling_conventions lint to reject more invalid calling conventions Add (back) unsupported_calling_conventions lint to reject more invalid calling conventions May 27, 2025
@traviscross
Copy link
Contributor

Let's propose to do it.

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented May 28, 2025

Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels May 28, 2025
@tmandry
Copy link
Member

tmandry commented May 28, 2025

@rfcbot reviewed

@joshtriplett
Copy link
Member

@rfcbot reviewed

I think, in the case of extern "stdcall", we should consider proviing a suggestion for extern "system".

extern "fastcall" is uncommon enough that it's not that onerous if we tell people to either use cfg (despite the substantial duplication at the moment) or use a macro for this.

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels May 28, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented May 28, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@traviscross traviscross added I-lang-radar Items that are on lang's radar and will need eventual work or consideration. and removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels May 28, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 8, 2025

⌛ Trying commit 7b0653c with merge c248def

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 8, 2025
…try>

Add (back) `unsupported_calling_conventions` lint to reject more invalid calling conventions

This adds back the `unsupported_calling_conventions` lint that was removed in #129935, in order to start the process of dealing with #137018. Specifically, we are going for the plan laid out [here](#137018 (comment)):
- thiscall, stdcall, fastcall, cdecl should only be accepted on x86-32
- vectorcall should only be accepted on x86-32 and x86-64

The difference to the status quo is that:
- We stop accepting stdcall, fastcall on targets that are windows && non-x86-32 (we already don't accept these on targets that are non-windows && non-x86-32)
- We stop accepting cdecl on targets that are non-x86-32
- (There is no difference for thiscall, this was already a hard error on non-x86-32)
- We stop accepting vectorcall on targets that are windows && non-x86-*

Vectorcall is an unstable ABI so we can just make this a hard error immediately. The others are stable, so we emit the `unsupported_calling_conventions` forward-compat lint. I set up the lint to show up in dependencies via cargo's future-compat report immediately, but we could also make it show up just for the local crate first if that is preferred.

try-job: i686-msvc-1
try-job: x86_64-msvc-1
try-job: test-various
@RalfJung RalfJung force-pushed the unsupported_calling_conventions branch from 7b0653c to b154e03 Compare June 8, 2025 18:36
@RalfJung
Copy link
Member Author

RalfJung commented Jun 8, 2025

@bors2 try

@rust-bors
Copy link

rust-bors bot commented Jun 8, 2025

❗ A try build is currently in progress. You can cancel it using @bors2 try cancel.

@RalfJung
Copy link
Member Author

RalfJung commented Jun 8, 2025

@bors2 try cancel
@bors2 try

@rust-bors
Copy link

rust-bors bot commented Jun 8, 2025

Try build cancelled. Cancelled workflows:

@rust-bors
Copy link

rust-bors bot commented Jun 8, 2025

❗ A try build is currently in progress. You can cancel it using @bors2 try cancel.

@RalfJung
Copy link
Member Author

RalfJung commented Jun 8, 2025

@bors2 try

@rust-bors
Copy link

rust-bors bot commented Jun 8, 2025

⌛ Trying commit b154e03 with merge 604947b

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 8, 2025
…try>

Add (back) `unsupported_calling_conventions` lint to reject more invalid calling conventions

This adds back the `unsupported_calling_conventions` lint that was removed in #129935, in order to start the process of dealing with #137018. Specifically, we are going for the plan laid out [here](#137018 (comment)):
- thiscall, stdcall, fastcall, cdecl should only be accepted on x86-32
- vectorcall should only be accepted on x86-32 and x86-64

The difference to the status quo is that:
- We stop accepting stdcall, fastcall on targets that are windows && non-x86-32 (we already don't accept these on targets that are non-windows && non-x86-32)
- We stop accepting cdecl on targets that are non-x86-32
- (There is no difference for thiscall, this was already a hard error on non-x86-32)
- We stop accepting vectorcall on targets that are windows && non-x86-*

Vectorcall is an unstable ABI so we can just make this a hard error immediately. The others are stable, so we emit the `unsupported_calling_conventions` forward-compat lint. I set up the lint to show up in dependencies via cargo's future-compat report immediately, but we could also make it show up just for the local crate first if that is preferred.

try-job: i686-msvc-1
try-job: x86_64-msvc-1
try-job: test-various
@rust-bors
Copy link

rust-bors bot commented Jun 8, 2025

☀️ Try build successful (CI)
Build commit: 604947b (604947b5e40a96118d12c0ab49d2284d80a6ada3)

@workingjubilee
Copy link
Member

🙏 @bors r+

@bors
Copy link
Collaborator

bors commented Jun 9, 2025

📌 Commit b154e03 has been approved by workingjubilee

It is now in the queue for this repository.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 9, 2025
@bors
Copy link
Collaborator

bors commented Jun 9, 2025

⌛ Testing commit b154e03 with merge b6685d7...

@bors
Copy link
Collaborator

bors commented Jun 9, 2025

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 9, 2025
@bors bors merged commit b6685d7 into rust-lang:master Jun 9, 2025
11 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 9, 2025
Copy link
Contributor

github-actions bot commented Jun 9, 2025

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 334ba81 (parent) -> b6685d7 (this PR)

Test differences

Show 170 test diffs

Stage 1

  • errors::verify_metadata_async_drop_types_in_dependency_80: [missing] -> pass (J0)
  • errors::verify_metadata_async_drop_types_in_dependency_81: pass -> [missing] (J0)
  • errors::verify_metadata_binary_output_to_tty_53: [missing] -> pass (J0)
  • errors::verify_metadata_binary_output_to_tty_54: pass -> [missing] (J0)
  • errors::verify_metadata_conflicting_alloc_error_handler_48: [missing] -> pass (J0)
  • errors::verify_metadata_conflicting_alloc_error_handler_49: pass -> [missing] (J0)
  • errors::verify_metadata_conflicting_global_alloc_47: [missing] -> pass (J0)
  • errors::verify_metadata_conflicting_global_alloc_48: pass -> [missing] (J0)
  • errors::verify_metadata_crate_location_unknown_type_68: [missing] -> pass (J0)
  • errors::verify_metadata_crate_location_unknown_type_69: pass -> [missing] (J0)
  • errors::verify_metadata_crate_not_compiler_builtins_42: [missing] -> pass (J0)
  • errors::verify_metadata_crate_not_compiler_builtins_43: pass -> [missing] (J0)
  • errors::verify_metadata_crate_not_panic_runtime_41: [missing] -> pass (J0)
  • errors::verify_metadata_crate_not_panic_runtime_42: pass -> [missing] (J0)
  • errors::verify_metadata_dl_error_63: [missing] -> pass (J0)
  • errors::verify_metadata_dl_error_64: pass -> [missing] (J0)
  • errors::verify_metadata_extern_location_not_exist_58: [missing] -> pass (J0)
  • errors::verify_metadata_extern_location_not_exist_59: pass -> [missing] (J0)
  • errors::verify_metadata_extern_location_not_file_59: [missing] -> pass (J0)
  • errors::verify_metadata_extern_location_not_file_60: pass -> [missing] (J0)
  • errors::verify_metadata_fail_create_file_encoder_39: [missing] -> pass (J0)
  • errors::verify_metadata_fail_create_file_encoder_40: pass -> [missing] (J0)
  • errors::verify_metadata_fail_write_file_40: [missing] -> pass (J0)
  • errors::verify_metadata_fail_write_file_41: pass -> [missing] (J0)
  • errors::verify_metadata_failed_copy_to_stdout_52: [missing] -> pass (J0)
  • errors::verify_metadata_failed_copy_to_stdout_53: pass -> [missing] (J0)
  • errors::verify_metadata_failed_create_encoded_metadata_56: [missing] -> pass (J0)
  • errors::verify_metadata_failed_create_encoded_metadata_57: pass -> [missing] (J0)
  • errors::verify_metadata_failed_create_file_55: [missing] -> pass (J0)
  • errors::verify_metadata_failed_create_file_56: pass -> [missing] (J0)
  • errors::verify_metadata_failed_create_tempdir_54: [missing] -> pass (J0)
  • errors::verify_metadata_failed_create_tempdir_55: pass -> [missing] (J0)
  • errors::verify_metadata_failed_write_error_51: [missing] -> pass (J0)
  • errors::verify_metadata_failed_write_error_52: pass -> [missing] (J0)
  • errors::verify_metadata_found_staticlib_66: [missing] -> pass (J0)
  • errors::verify_metadata_found_staticlib_67: pass -> [missing] (J0)
  • errors::verify_metadata_full_metadata_not_found_60: [missing] -> pass (J0)
  • errors::verify_metadata_full_metadata_not_found_61: pass -> [missing] (J0)
  • errors::verify_metadata_global_alloc_required_49: [missing] -> pass (J0)
  • errors::verify_metadata_global_alloc_required_50: pass -> [missing] (J0)
  • errors::verify_metadata_import_name_type_form_71: [missing] -> pass (J0)
  • errors::verify_metadata_import_name_type_form_72: pass -> [missing] (J0)
  • errors::verify_metadata_import_name_type_raw_74: [missing] -> pass (J0)
  • errors::verify_metadata_import_name_type_raw_75: pass -> [missing] (J0)
  • errors::verify_metadata_import_name_type_x86_72: [missing] -> pass (J0)
  • errors::verify_metadata_import_name_type_x86_73: pass -> [missing] (J0)
  • errors::verify_metadata_incompatible_rustc_67: [missing] -> pass (J0)
  • errors::verify_metadata_incompatible_rustc_68: pass -> [missing] (J0)
  • errors::verify_metadata_incompatible_target_modifiers_76: [missing] -> pass (J0)
  • errors::verify_metadata_incompatible_target_modifiers_77: pass -> [missing] (J0)
  • errors::verify_metadata_incompatible_target_modifiers_l_missed_77: [missing] -> pass (J0)
  • errors::verify_metadata_incompatible_target_modifiers_l_missed_78: pass -> [missing] (J0)
  • errors::verify_metadata_incompatible_target_modifiers_r_missed_78: [missing] -> pass (J0)
  • errors::verify_metadata_incompatible_target_modifiers_r_missed_79: pass -> [missing] (J0)
  • errors::verify_metadata_lib_filename_form_69: [missing] -> pass (J0)
  • errors::verify_metadata_lib_filename_form_70: pass -> [missing] (J0)
  • errors::verify_metadata_multiple_import_name_type_70: [missing] -> pass (J0)
  • errors::verify_metadata_multiple_import_name_type_71: pass -> [missing] (J0)
  • errors::verify_metadata_newer_crate_version_64: [missing] -> pass (J0)
  • errors::verify_metadata_newer_crate_version_65: pass -> [missing] (J0)
  • errors::verify_metadata_no_crate_with_triple_65: [missing] -> pass (J0)
  • errors::verify_metadata_no_crate_with_triple_66: pass -> [missing] (J0)
  • errors::verify_metadata_no_multiple_alloc_error_handler_46: [missing] -> pass (J0)
  • errors::verify_metadata_no_multiple_alloc_error_handler_47: pass -> [missing] (J0)
  • errors::verify_metadata_no_multiple_global_alloc_45: [missing] -> pass (J0)
  • errors::verify_metadata_no_multiple_global_alloc_46: pass -> [missing] (J0)
  • errors::verify_metadata_no_panic_strategy_43: [missing] -> pass (J0)
  • errors::verify_metadata_no_panic_strategy_44: pass -> [missing] (J0)
  • errors::verify_metadata_no_transitive_needs_dep_50: [missing] -> pass (J0)
  • errors::verify_metadata_no_transitive_needs_dep_51: pass -> [missing] (J0)
  • errors::verify_metadata_non_ascii_name_57: [missing] -> pass (J0)
  • errors::verify_metadata_non_ascii_name_58: pass -> [missing] (J0)
  • errors::verify_metadata_not_profiler_runtime_44: [missing] -> pass (J0)
  • errors::verify_metadata_not_profiler_runtime_45: pass -> [missing] (J0)
  • errors::verify_metadata_raw_dylib_unsupported_abi_38: [missing] -> pass (J0)
  • errors::verify_metadata_stable_crate_id_collision_62: [missing] -> pass (J0)
  • errors::verify_metadata_stable_crate_id_collision_63: pass -> [missing] (J0)
  • errors::verify_metadata_symbol_conflicts_current_61: [missing] -> pass (J0)
  • errors::verify_metadata_symbol_conflicts_current_62: pass -> [missing] (J0)
  • errors::verify_metadata_unknown_import_name_type_73: [missing] -> pass (J0)
  • errors::verify_metadata_unknown_import_name_type_74: pass -> [missing] (J0)
  • errors::verify_metadata_unknown_target_modifier_unsafe_allowed_79: [missing] -> pass (J0)
  • errors::verify_metadata_unknown_target_modifier_unsafe_allowed_80: pass -> [missing] (J0)
  • errors::verify_metadata_unsupported_abi_39: pass -> [missing] (J0)
  • errors::verify_metadata_unsupported_abi_i686_38: pass -> [missing] (J0)
  • errors::verify_metadata_wasm_c_abi_75: [missing] -> pass (J0)
  • errors::verify_metadata_wasm_c_abi_76: pass -> [missing] (J0)
  • [ui] tests/ui/abi/unsupported.rs#x64_win: [missing] -> pass (J2)

Stage 2

  • [ui] tests/ui/abi/unsupported.rs#x64_win: [missing] -> pass (J1)

Additionally, 81 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard b6685d748fe4668571c05ba338f61520db6dacc9 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-apple-various: 7628.9s -> 5843.0s (-23.4%)
  2. x86_64-apple-2: 7012.5s -> 5720.4s (-18.4%)
  3. dist-aarch64-apple: 5449.7s -> 4564.9s (-16.2%)
  4. dist-ohos-armv7: 4508.1s -> 3869.7s (-14.2%)
  5. x86_64-gnu-aux: 6024.8s -> 6620.3s (9.9%)
  6. dist-x86_64-apple: 8376.1s -> 7742.6s (-7.6%)
  7. dist-powerpc64-linux: 4769.1s -> 5117.4s (7.3%)
  8. dist-aarch64-linux: 5814.2s -> 5391.3s (-7.3%)
  9. x86_64-rust-for-linux: 2800.2s -> 2999.4s (7.1%)
  10. dist-powerpc64le-linux-musl: 4942.0s -> 5278.1s (6.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b6685d7): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -2.0%, secondary 3.3%)

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)
- - 0
Regressions ❌
(secondary)
9.0% [9.0%, 9.0%] 1
Improvements ✅
(primary)
-2.0% [-2.0%, -2.0%] 1
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) -2.0% [-2.0%, -2.0%] 1

Cycles

Results (secondary -6.7%)

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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.7% [-6.7%, -6.7%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 755.214s -> 753.257s (-0.26%)
Artifact size: 372.33 MiB -> 372.34 MiB (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. 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-lang Relevant to the language team to-announce Announce this issue on triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.