Skip to content

fix incorrect byte count suffix on MSVC - #165458

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
paradoxicalguy:fix-msvc-byte-count-clean
Nov 10, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
paradoxicalguy:fix-msvc-byte-count-clean

Conversation

@paradoxicalguy

@paradoxicalguy paradoxicalguy commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

View all comments

fixes #165299

this moves the byte count calculation into a shared helper in rustc_codegen_ssa. it now derives the count from the original argument layouts rather than the lowered signature.

the fix is wired up for llvm. symbols are emitted with a \x01 prefix so llvm doesn’t decorate them a second time, and the linker-facing symbol naming path now handles the \x01 and ? prefixes.

testing:

verified fastcall, stdcall and vectorcall on msvc, including cross-crate references.
added regression coverage for the linker failure in #165299, including a portable build-pass test using minicore and rust-lld. the unpatched compiler fails with a linker error, while the patched compiler links successfully.

added codegen regression tests and updated the existing abi, unwind and assembly tests for the corrected symbol names and byte counts. this also resolves the over-aligned argument FIXME in win32-byte-count-suffix.rs.

cc @folkertdev @workingjubilee

@rustbot

rustbot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

rustc_codegen_cranelift is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_cranelift instead.

cc @bjorn3

@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 Nov 4, 2026
@rustbot

rustbot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
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: codegen, compiler
  • codegen, compiler expanded to 77 candidates
  • Random selection from 21 candidates

@rust-log-analyzer

This comment has been minimized.

@paradoxicalguy
paradoxicalguy force-pushed the fix-msvc-byte-count-clean branch from 3536372 to 3ec1e11 Compare November 4, 2026 14:01
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@paradoxicalguy

Copy link
Copy Markdown
Member Author

current CI failure is pointing to this existing FIXME

#[target_feature(enable = "sse2")]
extern "vectorcall" fn four_vectors_vectorcall(_: i32x4, _: i32x4, _: i32x4, _: i32x4) {}
// CHECK-LABEL: eight_vectors_vectorcall@@128:
#[unsafe(no_mangle)]
#[target_feature(enable = "sse2")]
extern "vectorcall" fn eight_vectors_vectorcall(
_: i32x4,
_: i32x4,
_: i32x4,
_: i32x4,
_: i32x4,
_: i32x4,
_: i32x4,
_: i32x4,
) {
}
/// FIXME: the mangled name for this type is incorrect on msvc, where the argument is passed
/// indirectly and a pointer takes up 4 bytes, but clang counts the size of the type and uses
/// @8 there. With GNU the value is passed directly, so the suffix is correct.
#[repr(C, align(8))]

the existing win32-byte-count-suffix.rs test expected @4 for over-aligned arguments on msvc. the patch now emits @8, matching the original argument layout and the existing windows-gnu expectations.
updated that and edited the FIXME.

@paradoxicalguy

Copy link
Copy Markdown
Member Author

@bors squash msg = "fix MSVC calling convention symbol byte counts"

@rust-bors

rust-bors Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Unknown value for argument "". Run @bors help or go to https://bors.rust-lang.org/help to see available commands.

@paradoxicalguy

Copy link
Copy Markdown
Member Author

is it because of blank space 🤔
@bors squash msg="fix MSVC calling convention symbol byte counts"

@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🔨 5 commits were squashed into 71146c7.

@rust-bors
rust-bors Bot force-pushed the fix-msvc-byte-count-clean branch from 19b93cf to 71146c7 Compare November 4, 2026 21:25
@paradoxicalguy paradoxicalguy changed the title Fix msvc byte count clean fix incorrect byte count suffix on MSVC Nov 4, 2026
@paradoxicalguy
paradoxicalguy force-pushed the fix-msvc-byte-count-clean branch from 71146c7 to 16191b5 Compare November 4, 2026 22:15
@jieyouxu

jieyouxu commented Nov 5, 2026

Copy link
Copy Markdown
Member

Probably
r? folkertdev
since you're already reviewing.

@rustbot rustbot assigned folkertdev and unassigned jieyouxu Nov 5, 2026

@folkertdev folkertdev left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 6, 2026
@rustbot

rustbot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Nov 11, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - rust-lang/rust#165709 (remove 'x miri' smoke test from PR CI)
 - rust-lang/rust#164217 (Prepare to make `rustc_trivial_field_reads` usable in user code)
 - rust-lang/rust#165569 (`Move` trait feature gate)
 - rust-lang/rust#165575 (Upgrade bundled musl to 1.2.6)
 - rust-lang/rust#163241 (Add enclosing item context when pointing at `FnMut` bound)
 - rust-lang/rust#163992 (add `core::arch::{x86, x86_64}::x87_f80`)
 - rust-lang/rust#165047 (Change the span building of paths from first-to-last to chained)
 - rust-lang/rust#165458 (fix incorrect byte count suffix on MSVC)
 - rust-lang/rust#165490 (Mark the compile unit for `-Zdebuginfo-for-profiling`)
 - rust-lang/rust#165586 (Remove `backend_optimization_level`.)
 - rust-lang/rust#165646 (fix NumScalableVectors::from_field_count)
 - rust-lang/rust#165655 (Unignore passing GCC backend tests)
 - rust-lang/rust#165740 (miri subtree update)
 - rust-lang/rust#165753 (avoid Terminator:None in MIR inliner)
 - rust-lang/rust#153261 (Partially stabilize `ptr_alignment_type` as `alignment_type`)
 - rust-lang/rust#164559 (Windows: fix Dir::remove and Dir::rename following symlinks)
 - rust-lang/rust#165562 (stop using gce in a test)
 - rust-lang/rust#165681 (Add safety requirements for Pattern and Searcher)
 - rust-lang/rust#165682 (interpret: ensure newly created unions have uninit in their padding)
 - rust-lang/rust#165693 (Move `check_attr` to attribute parsing)
 - rust-lang/rust#165715 (windows: check for null before wide encoding)
 - rust-lang/rust#165717 (mpsc_sync::stream_send_recv_stress: wait for all threads to finish)
 - rust-lang/rust#165733 (docs(num): remove needless whitespaces)
 - rust-lang/rust#165739 (remove NOP File::flush from fs tests)

Failed merges:

 - rust-lang/rust#165727 (Normalize "beta release channel" in `const-supertrait-unstable` test)
 - rust-lang/rust#164218 (Tweak private re-export errors to point at correct span and have more context)
RalfJung pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 11, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - rust-lang/rust#165709 (remove 'x miri' smoke test from PR CI)
 - rust-lang/rust#164217 (Prepare to make `rustc_trivial_field_reads` usable in user code)
 - rust-lang/rust#165569 (`Move` trait feature gate)
 - rust-lang/rust#165575 (Upgrade bundled musl to 1.2.6)
 - rust-lang/rust#163241 (Add enclosing item context when pointing at `FnMut` bound)
 - rust-lang/rust#163992 (add `core::arch::{x86, x86_64}::x87_f80`)
 - rust-lang/rust#165047 (Change the span building of paths from first-to-last to chained)
 - rust-lang/rust#165458 (fix incorrect byte count suffix on MSVC)
 - rust-lang/rust#165490 (Mark the compile unit for `-Zdebuginfo-for-profiling`)
 - rust-lang/rust#165586 (Remove `backend_optimization_level`.)
 - rust-lang/rust#165646 (fix NumScalableVectors::from_field_count)
 - rust-lang/rust#165655 (Unignore passing GCC backend tests)
 - rust-lang/rust#165740 (miri subtree update)
 - rust-lang/rust#165753 (avoid Terminator:None in MIR inliner)
 - rust-lang/rust#153261 (Partially stabilize `ptr_alignment_type` as `alignment_type`)
 - rust-lang/rust#164559 (Windows: fix Dir::remove and Dir::rename following symlinks)
 - rust-lang/rust#165562 (stop using gce in a test)
 - rust-lang/rust#165681 (Add safety requirements for Pattern and Searcher)
 - rust-lang/rust#165682 (interpret: ensure newly created unions have uninit in their padding)
 - rust-lang/rust#165693 (Move `check_attr` to attribute parsing)
 - rust-lang/rust#165715 (windows: check for null before wide encoding)
 - rust-lang/rust#165717 (mpsc_sync::stream_send_recv_stress: wait for all threads to finish)
 - rust-lang/rust#165733 (docs(num): remove needless whitespaces)
 - rust-lang/rust#165739 (remove NOP File::flush from fs tests)

Failed merges:

 - rust-lang/rust#165727 (Normalize "beta release channel" in `const-supertrait-unstable` test)
 - rust-lang/rust#164218 (Tweak private re-export errors to point at correct span and have more context)
@rust-timer

Copy link
Copy Markdown
Collaborator

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (ceb2a18): comparison URL.

Overall result: ❌ regressions - please read:

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

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
1.1% [0.2%, 3.6%] 35
Regressions ❌
(secondary)
1.4% [0.1%, 9.1%] 48
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [0.2%, 3.6%] 35

Max RSS (memory usage)

Results (primary 5.0%, secondary 7.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
5.0% [1.9%, 18.7%] 27
Regressions ❌
(secondary)
7.4% [2.1%, 15.4%] 36
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.7% [-4.7%, -4.7%] 1
All ❌✅ (primary) 5.0% [1.9%, 18.7%] 27

Cycles

Results (primary 3.4%, secondary 4.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.4% [2.0%, 6.2%] 11
Regressions ❌
(secondary)
4.5% [1.8%, 12.9%] 13
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.4% [2.0%, 6.2%] 11

Binary size

This perf run didn't have relevant results for this metric.

Artifact size: 406.28 MiB -> 406.34 MiB (0.02%)

@rustbot rustbot added the perf-regression Performance regression. label Nov 11, 2026
github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Nov 12, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - rust-lang/rust#165709 (remove 'x miri' smoke test from PR CI)
 - rust-lang/rust#164217 (Prepare to make `rustc_trivial_field_reads` usable in user code)
 - rust-lang/rust#165569 (`Move` trait feature gate)
 - rust-lang/rust#165575 (Upgrade bundled musl to 1.2.6)
 - rust-lang/rust#163241 (Add enclosing item context when pointing at `FnMut` bound)
 - rust-lang/rust#163992 (add `core::arch::{x86, x86_64}::x87_f80`)
 - rust-lang/rust#165047 (Change the span building of paths from first-to-last to chained)
 - rust-lang/rust#165458 (fix incorrect byte count suffix on MSVC)
 - rust-lang/rust#165490 (Mark the compile unit for `-Zdebuginfo-for-profiling`)
 - rust-lang/rust#165586 (Remove `backend_optimization_level`.)
 - rust-lang/rust#165646 (fix NumScalableVectors::from_field_count)
 - rust-lang/rust#165655 (Unignore passing GCC backend tests)
 - rust-lang/rust#165740 (miri subtree update)
 - rust-lang/rust#165753 (avoid Terminator:None in MIR inliner)
 - rust-lang/rust#153261 (Partially stabilize `ptr_alignment_type` as `alignment_type`)
 - rust-lang/rust#164559 (Windows: fix Dir::remove and Dir::rename following symlinks)
 - rust-lang/rust#165562 (stop using gce in a test)
 - rust-lang/rust#165681 (Add safety requirements for Pattern and Searcher)
 - rust-lang/rust#165682 (interpret: ensure newly created unions have uninit in their padding)
 - rust-lang/rust#165693 (Move `check_attr` to attribute parsing)
 - rust-lang/rust#165715 (windows: check for null before wide encoding)
 - rust-lang/rust#165717 (mpsc_sync::stream_send_recv_stress: wait for all threads to finish)
 - rust-lang/rust#165733 (docs(num): remove needless whitespaces)
 - rust-lang/rust#165739 (remove NOP File::flush from fs tests)

Failed merges:

 - rust-lang/rust#165727 (Normalize "beta release channel" in `const-supertrait-unstable` test)
 - rust-lang/rust#164218 (Tweak private re-export errors to point at correct span and have more context)
@JonathanBrouwer

Copy link
Copy Markdown
Member

This caused a significant unexpected perf regression. Any idea what caused this?
Given that this is a correctness fix, I'm iffy about immediately reverting it, but the perf regression is also very large...

@panstromek

panstromek commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

From cachegrind diff on helloworld opt, it looks like some missed inlining in allocator:

949,870 (100.0%)  PROGRAM TOTALS

  Ir_________________________  file:function

<    925,940   (97.5%, 97.5%)  ???:
   6,506,552  (685.0%)           ???
  -1,209,971 (-127.4%)           tcache_bin_flush_small
  -1,151,191 (-121.2%)           pa_alloc
  -1,074,007 (-113.1%)           free
    -671,271  (-70.7%)           malloc
    -448,493  (-47.2%)           realloc
    -295,490  (-31.1%)           aligned_alloc
    -255,267  (-26.9%)           malloc_default
    -213,207  (-22.4%)           extent_try_coalesce_impl
    -192,937  (-20.3%)           ecache_evict
    -128,869  (-13.6%)           eset_remove
    -104,550  (-11.0%)           calloc
    -103,735  (-10.9%)           pa_dalloc

This PR changes/adds some more String/Vec juggling around symbols, so I suspect it's something in those paths, but nothing stands out to me at a glance.

@nnethercote

Copy link
Copy Markdown
Contributor

missed inlining in allocator

I don't think that's relevant. Selected output from an LLM analysis of the regression says the following:

  The PR added a fn_abi_of_instance query for every
  exported symbol on two paths that previously never computed it on non-Windows targets, and the
  result is then discarded on Linux.

  1. Local ThinLTO symbol list (the opt-only library regression). exported_symbols_for_lto in
     compiler/rustc_codegen_ssa/src/back/lto.rs:107 now calls the new symbol_names_for_lto. That
     calls calling_convention_for_symbol (compiler/rustc_codegen_ssa/src/back/symbol_export.rs:772),
     which runs fn_abi_of_instance for every exported non-static function. Before the PR this path
     only computed the symbol name. It runs in opt builds (Lto::ThinLocal, threshold
     SymbolExportLevel::Rust), so the cost scales with the crate's exported-symbol count.
     
  2. Linked symbols for executables (the constant binary regression).
     linking_symbol_name_for_instance_in_crate used to return immediately for non-Windows targets.
     It now calls calling_convention_for_symbol first
     (compiler/rustc_codegen_ssa/src/back/symbol_export.rs:802). linked_symbols in
     compiler/rustc_codegen_ssa/src/back/linker.rs:1791 calls it for each qualifying symbol of the
     crate and its dependencies, including std.

  On Linux the work is wasted unless the convention is vectorcall: windows_calling_convention_name
  in compiler/rustc_codegen_ssa/src/common.rs:209 returns None straight away otherwise. The third
  new call site, in declare_rust_fn, already has the FnAbi in hand and is cheap. 

My experience is that this LLM is generally very good at this kind of diagnosis, and looking at the code I think it's correct in this case.

The suggested fix:

  Avoid computing the full FnAbi unless decoration can apply. Check the target first (only
  x86/x86_64 can decorate, and non-Windows only for vectorcall), and get the calling convention from
  something cheaper than fn_abi_of_instance. The argument layouts are only needed once the
  convention is known to be stdcall, fastcall or vectorcall.

In the meantime I think we should revert this change given the size of the perf regression.

@folkertdev

Copy link
Copy Markdown
Contributor

That sounds right, there really should be no performance impact on linux (except for when using vectorcall but that is extremely niche).

@panstromek

Copy link
Copy Markdown
Contributor

My experience is that this LLM is generally very good at this kind of diagnosis, and looking at the code I think it's correct in this case.

Oh, it's actually totally clear from detailed results without doing anything fancy, those are red all over the place:

https://perf.rust-lang.org/detailed-query.html?commit=ceb2a180e363ac2effac67b53cc18e35bd9935f0&benchmark=syn-2.0.101-opt&scenario=incr-unchanged&backend=llvm&target=x86_64-unknown-linux-gnu&frontend_threads=1&base_commit=b6c79e88af6825838aed7c6a159e7e0b00259443&sort=-executionsDelta

I didn't look at those, because I didn't see anything in the size:dep_graph. I probably missclicked, those are red as well.

@JonathanBrouwer

Copy link
Copy Markdown
Member

Revert posted: #165856

rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
Revert "fix incorrect byte count suffix on MSVC"

Reverts #165458 because of a performance regression.
@paradoxicalguy

Copy link
Copy Markdown
Member Author

my bad, i'll put together a follow up after revert has landed
thanks for diagnosis :)

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 12, 2026
…egression, r=folkertdev

tests: cover MSVC ThinLTO exported symbol preservation

test-only continuation of rust-lang#165458
this pr adds regression tests for exported-symbol preservation during ThinLTO on i686 MSVC.

the test checks that ThinLTO preserves: ordinary exported functions, where LLVM IR names differ from COFF linker-visible names. stdcall functions with explicitly decorated symbol names. exported static data.
the run-make test executes on x86_64 MSVC and cross-compiles an i686 MSVC static library using `minicore`, so it does not require an installed i686 standard-library sysroot.

Verified the test against both implementations:
before the fix: test fails because ThinLTO does not preserve `___rust_lto_preserve_plain`.
after the fix: test passes with all expected exported symbols present.

both fixture compilation steps succeeded in the failing run, confirming that the failure is caused by incorrect symbol preservation rather than a compilation or linking issue.

r? @folkertdev
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 12, 2026
…egression, r=folkertdev

tests: cover MSVC ThinLTO exported symbol preservation

test-only continuation of rust-lang#165458
this pr adds regression tests for exported-symbol preservation during ThinLTO on i686 MSVC.

the test checks that ThinLTO preserves: ordinary exported functions, where LLVM IR names differ from COFF linker-visible names. stdcall functions with explicitly decorated symbol names. exported static data.
the run-make test executes on x86_64 MSVC and cross-compiles an i686 MSVC static library using `minicore`, so it does not require an installed i686 standard-library sysroot.

Verified the test against both implementations:
before the fix: test fails because ThinLTO does not preserve `___rust_lto_preserve_plain`.
after the fix: test passes with all expected exported symbols present.

both fixture compilation steps succeeded in the failing run, confirming that the failure is caused by incorrect symbol preservation rather than a compilation or linking issue.

r? @folkertdev
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 13, 2026
…egression, r=folkertdev

tests: cover MSVC ThinLTO exported symbol preservation

test-only continuation of rust-lang#165458
this pr adds regression tests for exported-symbol preservation during ThinLTO on i686 MSVC.

the test checks that ThinLTO preserves: ordinary exported functions, where LLVM IR names differ from COFF linker-visible names. stdcall functions with explicitly decorated symbol names. exported static data.
the run-make test executes on x86_64 MSVC and cross-compiles an i686 MSVC static library using `minicore`, so it does not require an installed i686 standard-library sysroot.

Verified the test against both implementations:
before the fix: test fails because ThinLTO does not preserve `___rust_lto_preserve_plain`.
after the fix: test passes with all expected exported symbols present.

both fixture compilation steps succeeded in the failing run, confirming that the failure is caused by incorrect symbol preservation rather than a compilation or linking issue.

r? @folkertdev
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 13, 2026
…egression, r=folkertdev

tests: cover MSVC ThinLTO exported symbol preservation

test-only continuation of rust-lang#165458
this pr adds regression tests for exported-symbol preservation during ThinLTO on i686 MSVC.

the test checks that ThinLTO preserves: ordinary exported functions, where LLVM IR names differ from COFF linker-visible names. stdcall functions with explicitly decorated symbol names. exported static data.
the run-make test executes on x86_64 MSVC and cross-compiles an i686 MSVC static library using `minicore`, so it does not require an installed i686 standard-library sysroot.

Verified the test against both implementations:
before the fix: test fails because ThinLTO does not preserve `___rust_lto_preserve_plain`.
after the fix: test passes with all expected exported symbols present.

both fixture compilation steps succeeded in the failing run, confirming that the failure is caused by incorrect symbol preservation rather than a compilation or linking issue.

r? @folkertdev
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 13, 2026
…egression, r=folkertdev

tests: cover MSVC ThinLTO exported symbol preservation

test-only continuation of rust-lang#165458
this pr adds regression tests for exported-symbol preservation during ThinLTO on i686 MSVC.

the test checks that ThinLTO preserves: ordinary exported functions, where LLVM IR names differ from COFF linker-visible names. stdcall functions with explicitly decorated symbol names. exported static data.
the run-make test executes on x86_64 MSVC and cross-compiles an i686 MSVC static library using `minicore`, so it does not require an installed i686 standard-library sysroot.

Verified the test against both implementations:
before the fix: test fails because ThinLTO does not preserve `___rust_lto_preserve_plain`.
after the fix: test passes with all expected exported symbols present.

both fixture compilation steps succeeded in the failing run, confirming that the failure is caused by incorrect symbol preservation rather than a compilation or linking issue.

r? @folkertdev
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 13, 2026
…egression, r=folkertdev

tests: cover MSVC ThinLTO exported symbol preservation

test-only continuation of rust-lang#165458
this pr adds regression tests for exported-symbol preservation during ThinLTO on i686 MSVC.

the test checks that ThinLTO preserves: ordinary exported functions, where LLVM IR names differ from COFF linker-visible names. stdcall functions with explicitly decorated symbol names. exported static data.
the run-make test executes on x86_64 MSVC and cross-compiles an i686 MSVC static library using `minicore`, so it does not require an installed i686 standard-library sysroot.

Verified the test against both implementations:
before the fix: test fails because ThinLTO does not preserve `___rust_lto_preserve_plain`.
after the fix: test passes with all expected exported symbols present.

both fixture compilation steps succeeded in the failing run, confirming that the failure is caused by incorrect symbol preservation rather than a compilation or linking issue.

r? @folkertdev
rust-bors Bot pushed a commit that referenced this pull request Nov 13, 2026
Rollup merge of #165771 - paradoxicalguy:msvc-lto-preserve-regression, r=folkertdev

tests: cover MSVC ThinLTO exported symbol preservation

test-only continuation of #165458
this pr adds regression tests for exported-symbol preservation during ThinLTO on i686 MSVC.

the test checks that ThinLTO preserves: ordinary exported functions, where LLVM IR names differ from COFF linker-visible names. stdcall functions with explicitly decorated symbol names. exported static data.
the run-make test executes on x86_64 MSVC and cross-compiles an i686 MSVC static library using `minicore`, so it does not require an installed i686 standard-library sysroot.

Verified the test against both implementations:
before the fix: test fails because ThinLTO does not preserve `___rust_lto_preserve_plain`.
after the fix: test passes with all expected exported symbols present.

both fixture compilation steps succeeded in the failing run, confirming that the failure is caused by incorrect symbol preservation rather than a compilation or linking issue.

r? @folkertdev
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 13, 2026
Revert "fix incorrect byte count suffix on MSVC"

Reverts rust-lang/rust#165458 because of a performance regression.
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Nov 16, 2026
Revert "fix incorrect byte count suffix on MSVC"

Reverts rust-lang/rust#165458 because of a performance regression.
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Nov 16, 2026
…, r=folkertdev

tests: cover MSVC ThinLTO exported symbol preservation

test-only continuation of rust-lang/rust#165458
this pr adds regression tests for exported-symbol preservation during ThinLTO on i686 MSVC.

the test checks that ThinLTO preserves: ordinary exported functions, where LLVM IR names differ from COFF linker-visible names. stdcall functions with explicitly decorated symbol names. exported static data.
the run-make test executes on x86_64 MSVC and cross-compiles an i686 MSVC static library using `minicore`, so it does not require an installed i686 standard-library sysroot.

Verified the test against both implementations:
before the fix: test fails because ThinLTO does not preserve `___rust_lto_preserve_plain`.
after the fix: test passes with all expected exported symbols present.

both fixture compilation steps succeeded in the failing run, confirming that the failure is caused by incorrect symbol preservation rather than a compilation or linking issue.

r? @folkertdev
folkertdev pushed a commit to folkertdev/stdarch that referenced this pull request Nov 16, 2026
Revert "fix incorrect byte count suffix on MSVC"

Reverts rust-lang/rust#165458 because of a performance regression.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
…-v2, r=folkertdev

fix MSVC calling convention byte counts

performance fixed version of rust-lang#165458
original fix _reverted_ in rust-lang#165856 due to perf issues.

fixes rust-lang#165299
companion test pr: rust-lang#165771

the regression came from unnecessary `fn_abi_of_instance` queries on targets that don't need symbol decoration. this now skips those queries while keeping non-windows `vectorcall` handling.

perf: local rustc-perf benchmarks on aarch64 (instructions:u):
original fix: +0.83%
optimized fix: ~0.00%

testing:
fastcall, stdcall and vectorcall codegen tests
i686/x86_64 msvc linking with and without thinlto, verified dll exports
lto smoke tests
also handles `\x01`-prefixed symbols under thinlto (related: rust-lang#165790).

r? @folkertdev
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
…-v2, r=folkertdev

fix MSVC calling convention byte counts

performance fixed version of rust-lang#165458
original fix _reverted_ in rust-lang#165856 due to perf issues.

fixes rust-lang#165299
companion test pr: rust-lang#165771

the regression came from unnecessary `fn_abi_of_instance` queries on targets that don't need symbol decoration. this now skips those queries while keeping non-windows `vectorcall` handling.

perf: local rustc-perf benchmarks on aarch64 (instructions:u):
original fix: +0.83%
optimized fix: ~0.00%

testing:
fastcall, stdcall and vectorcall codegen tests
i686/x86_64 msvc linking with and without thinlto, verified dll exports
lto smoke tests
also handles `\x01`-prefixed symbols under thinlto (related: rust-lang#165790).

r? @folkertdev
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
Rollup merge of #165881 - paradoxicalguy:fix-msvc-byte-count-v2, r=folkertdev

fix MSVC calling convention byte counts

performance fixed version of #165458
original fix _reverted_ in #165856 due to perf issues.

fixes #165299
companion test pr: #165771

the regression came from unnecessary `fn_abi_of_instance` queries on targets that don't need symbol decoration. this now skips those queries while keeping non-windows `vectorcall` handling.

perf: local rustc-perf benchmarks on aarch64 (instructions:u):
original fix: +0.83%
optimized fix: ~0.00%

testing:
fastcall, stdcall and vectorcall codegen tests
i686/x86_64 msvc linking with and without thinlto, verified dll exports
lto smoke tests
also handles `\x01`-prefixed symbols under thinlto (related: #165790).

r? @folkertdev
sushink70 pushed a commit to sushink70/miri that referenced this pull request Nov 17, 2026
…lkertdev

fix MSVC calling convention byte counts

performance fixed version of rust-lang/rust#165458
original fix _reverted_ in rust-lang/rust#165856 due to perf issues.

fixes rust-lang/rust#165299
companion test pr: rust-lang/rust#165771

the regression came from unnecessary `fn_abi_of_instance` queries on targets that don't need symbol decoration. this now skips those queries while keeping non-windows `vectorcall` handling.

perf: local rustc-perf benchmarks on aarch64 (instructions:u):
original fix: +0.83%
optimized fix: ~0.00%

testing:
fastcall, stdcall and vectorcall codegen tests
i686/x86_64 msvc linking with and without thinlto, verified dll exports
lto smoke tests
also handles `\x01`-prefixed symbols under thinlto (related: rust-lang/rust#165790).

r? @folkertdev
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 perf-regression Performance regression. 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.

rustc emits an incorrect byte count suffix on MSVC