Skip to content

Fix EII function aliases eliminated by LTO#153648

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
AsakuraMizu:fix-eii-lto-alias
Mar 31, 2026
Merged

Fix EII function aliases eliminated by LTO#153648
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
AsakuraMizu:fix-eii-lto-alias

Conversation

@AsakuraMizu
Copy link
Copy Markdown
Contributor

@AsakuraMizu AsakuraMizu commented Mar 10, 2026

Add EII function aliases to llvm.compiler.used so that LLVM's LTO passes do not eliminate them.

Fixes #153645

Tracking issue: #125418

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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 10, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 10, 2026

r? @TaKO8Ki

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

@rustbot

This comment has been minimized.

@Kivooeo
Copy link
Copy Markdown
Member

Kivooeo commented Mar 10, 2026

r? jdonszelmann

@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented Mar 10, 2026

I'm not sure if this is the right fix. They might need to be added to exported_symbols_for_lto instead. Otherwise they can still be made private by LTO, which would break dylibs. And I don't know if for_each_exported_symbols_include_dep already contains them to (for proper exporting during linking)

@jdonszelmann
Copy link
Copy Markdown
Contributor

hm, I wonder what the difference is between aliases and these shims. These shims pretty much act like aliases, and their symbol is the same as the EII declatation's. We already handle those symbols specially in a few places (look for the aliases field on CodegenAttrs). In fact, I personally thought we already kept them alive enough. I guess functions are optimized differently which makes some sense. In any case, I expect the problem to fundamentally also affect aliases of statics, something we don't test much at the moment, so the solution should apply to all aliases, not just these shims.

@AsakuraMizu
Copy link
Copy Markdown
Contributor Author

I'm not sure if this is the right fix. They might need to be added to exported_symbols_for_lto instead. Otherwise they can still be made private by LTO, which would break dylibs. And I don't know if for_each_exported_symbols_include_dep already contains them to (for proper exporting during linking)

Thank you for your comment. My previous attempt was more of a hack than a fix. So I redesigned a better solution based on your suggestion. This should fix both my issue and #151271 now.

In any case, I expect the problem to fundamentally also affect aliases of statics, something we don't test much at the moment, so the solution should apply to all aliases, not just these shims.

The new attempt will apply to any foreign_item_symbol_aliases now.

@jdonszelmann
Copy link
Copy Markdown
Contributor

been having a bit of a backlog. This was mostly bjorn, but I agree with the discussions had and I think the current state of the PR seems correct to me.

@bors r=me,bjorn3

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 30, 2026

📌 Commit d81cc68 has been approved by me,bjorn3

It is now in the queue for this repository.

⚠️ The following reviewer(s) could not be found: me

@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 30, 2026
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors r=jdonszelmann,bjorn3

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 30, 2026

📌 Commit d81cc68 has been approved by jdonszelmann,bjorn3

It is now in the queue for this repository.

tgross35 added a commit to tgross35/rust that referenced this pull request Mar 30, 2026
…donszelmann,bjorn3

Fix EII function aliases eliminated by LTO

Add EII function aliases to `llvm.compiler.used` so that LLVM's LTO passes do not eliminate them.

Fixes rust-lang#153645

Tracking issue: rust-lang#125418
rust-bors bot pushed a commit that referenced this pull request Mar 31, 2026
Rollup of 7 pull requests

Successful merges:

 - #142659 (compiler-builtins: Clean up features)
 - #153574 (Avoid ICE when param-env normalization leaves unresolved inference variables)
 - #153648 (Fix EII function aliases eliminated by LTO)
 - #153790 (Fix regression when dealing with generics/values with unresolved inference)
 - #153893 (Lex lifetimes as identifiers, recover from emoji and emit appropriate error)
 - #153980 (refactor: move doc(rust_logo) check to parser)
 - #154551 (Skip suggestions pointing to macro def for assert_eq)
rust-bors bot pushed a commit that referenced this pull request Mar 31, 2026
Rollup of 7 pull requests

Successful merges:

 - #142659 (compiler-builtins: Clean up features)
 - #153574 (Avoid ICE when param-env normalization leaves unresolved inference variables)
 - #153648 (Fix EII function aliases eliminated by LTO)
 - #153790 (Fix regression when dealing with generics/values with unresolved inference)
 - #153893 (Lex lifetimes as identifiers, recover from emoji and emit appropriate error)
 - #153980 (refactor: move doc(rust_logo) check to parser)
 - #154551 (Skip suggestions pointing to macro def for assert_eq)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 31, 2026
…donszelmann,bjorn3

Fix EII function aliases eliminated by LTO

Add EII function aliases to `llvm.compiler.used` so that LLVM's LTO passes do not eliminate them.

Fixes rust-lang#153645

Tracking issue: rust-lang#125418
rust-bors bot pushed a commit that referenced this pull request Mar 31, 2026
Rollup of 9 pull requests

Successful merges:

 - #154582 (miri subtree update)
 - #142659 (compiler-builtins: Clean up features)
 - #153574 (Avoid ICE when param-env normalization leaves unresolved inference variables)
 - #153648 (Fix EII function aliases eliminated by LTO)
 - #153790 (Fix regression when dealing with generics/values with unresolved inference)
 - #154551 (Skip suggestions pointing to macro def for assert_eq)
 - #154574 (delete several `ui/consts` tests)
 - #154577 (Update `mir-opt` 64-bit panic-abort tests for `Alignment` rename)
 - #154579 (remove debug requirement from hooks)
@rust-bors rust-bors bot merged commit 4b23782 into rust-lang:main Mar 31, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 31, 2026
rust-timer added a commit that referenced this pull request Mar 31, 2026
Rollup merge of #153648 - AsakuraMizu:fix-eii-lto-alias, r=jdonszelmann,bjorn3

Fix EII function aliases eliminated by LTO

Add EII function aliases to `llvm.compiler.used` so that LLVM's LTO passes do not eliminate them.

Fixes #153645

Tracking issue: #125418
@AsakuraMizu AsakuraMizu deleted the fix-eii-lto-alias branch March 31, 2026 16:05
github-actions bot pushed a commit to rust-lang/compiler-builtins that referenced this pull request Mar 31, 2026
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#154582 (miri subtree update)
 - rust-lang/rust#142659 (compiler-builtins: Clean up features)
 - rust-lang/rust#153574 (Avoid ICE when param-env normalization leaves unresolved inference variables)
 - rust-lang/rust#153648 (Fix EII function aliases eliminated by LTO)
 - rust-lang/rust#153790 (Fix regression when dealing with generics/values with unresolved inference)
 - rust-lang/rust#154551 (Skip suggestions pointing to macro def for assert_eq)
 - rust-lang/rust#154574 (delete several `ui/consts` tests)
 - rust-lang/rust#154577 (Update `mir-opt` 64-bit panic-abort tests for `Alignment` rename)
 - rust-lang/rust#154579 (remove debug requirement from hooks)
chenyukang pushed a commit to chenyukang/rust that referenced this pull request Apr 1, 2026
Rollup of 9 pull requests

Successful merges:

 - rust-lang#154582 (miri subtree update)
 - rust-lang#142659 (compiler-builtins: Clean up features)
 - rust-lang#153574 (Avoid ICE when param-env normalization leaves unresolved inference variables)
 - rust-lang#153648 (Fix EII function aliases eliminated by LTO)
 - rust-lang#153790 (Fix regression when dealing with generics/values with unresolved inference)
 - rust-lang#154551 (Skip suggestions pointing to macro def for assert_eq)
 - rust-lang#154574 (delete several `ui/consts` tests)
 - rust-lang#154577 (Update `mir-opt` 64-bit panic-abort tests for `Alignment` rename)
 - rust-lang#154579 (remove debug requirement from hooks)
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Apr 1, 2026
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#154582 (miri subtree update)
 - rust-lang/rust#142659 (compiler-builtins: Clean up features)
 - rust-lang/rust#153574 (Avoid ICE when param-env normalization leaves unresolved inference variables)
 - rust-lang/rust#153648 (Fix EII function aliases eliminated by LTO)
 - rust-lang/rust#153790 (Fix regression when dealing with generics/values with unresolved inference)
 - rust-lang/rust#154551 (Skip suggestions pointing to macro def for assert_eq)
 - rust-lang/rust#154574 (delete several `ui/consts` tests)
 - rust-lang/rust#154577 (Update `mir-opt` 64-bit panic-abort tests for `Alignment` rename)
 - rust-lang/rust#154579 (remove debug requirement from hooks)
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. 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.

Externally Implementable Items: error: undefined symbol when opt-level >= 1

7 participants