Skip to content

[AIX] update linker default to bcdtors#155247

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
daltenty:daltenty/bcdtors
Apr 28, 2026
Merged

[AIX] update linker default to bcdtors#155247
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
daltenty:daltenty/bcdtors

Conversation

@daltenty
Copy link
Copy Markdown
Contributor

The bcdtor mode affects how the AIX linker choose to pull in static constructors and destructors (https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command) to the link.

The current setting of all makes static init in archive members live regardless of if the archive member would be otherwise referenced, causing that whole archive member to become part of the link.

This default was initially retained for compatibility purposes with historical compilers on the platform which defaulted to this setting. Unfortunately this greedy pulling in of static init can have unintended consequences for applications, for example for programs linked against parts of compiler-rt which contain optional instrumentation (containing static initializers) which may be unused as these now become live in all programs regardless of use.

For that reason and similar reasons, this PR switches the default to mbr, which only extracts static init from archive members which would otherwise be referenced. This gives a behaviour very consistent with linkers on other platforms (e.g. Linux).

Users requiring the old default behaviour can manually pass -bcdtors:all on the link step which will override any default we pass here.

(Note: this mirrors LLVM change: llvm/llvm-project#191265)

The bcdtor mode affects how the AIX linker choose to pull in static constructors and destructors (https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command) to the link.

The current setting of all makes static init in archive members live regardless of if the archive member would be otherwise referenced, causing that whole archive member to become part of the link.

This default was initially retained for compatibility purposes with historical compilers on the platform which defaulted to this setting. Unfortunately this greedy pulling in of static init can have unintended consequences for applications, for example for programs linked against parts of compiler-rt which contain optional instrumentation (containing static initializers) which may be unused as these now become live in all programs regardless of use.

For that reason and similar reasons, this PR switches the default to mbr, which only extracts static init from archive members which would otherwise be referenced. This gives a behaviour very consistent with linkers on other platforms (e.g. Linux).

Users requiring the old default behaviour can manually pass -bcdtors:all on the link step which will override any default we pass here.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 13, 2026

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 Apr 13, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 13, 2026

r? @davidtwco

rustbot has assigned @davidtwco.
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 13 candidates

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 13, 2026

⚠️ Warning ⚠️

@davidtwco
Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 28, 2026

📌 Commit 824cc42 has been approved by davidtwco

It is now in the queue for this repository.

@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 Apr 28, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 28, 2026
Rollup of 9 pull requests

Successful merges:

 - #155381 (Fix a bug in `ChunkedBitSet::subtract`)
 - #155847 (Don't reload length in String::push)
 - #155858 (`slice::join`: borrow only once during length calc)
 - #155879 (enable pipe tests in Miri)
 - #155905 (Update LLVM to 22.1.4 (again))
 - #155247 ([AIX] update linker default to bcdtors)
 - #155812 ([codex] tests: mark migrated UI tests as check-pass)
 - #155854 (Rename the diagnostic item for `std::sync::mpsc::Receiver`)
 - #155882 (Add regression test for #101363)
@rust-bors rust-bors Bot merged commit 0611bfc into rust-lang:main Apr 28, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 28, 2026
rust-timer added a commit that referenced this pull request Apr 28, 2026
Rollup merge of #155247 - daltenty:daltenty/bcdtors, r=davidtwco

[AIX] update linker default to bcdtors

The bcdtor mode affects how the AIX linker choose to pull in static constructors and destructors (https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command) to the link.

The current setting of all makes static init in archive members live regardless of if the archive member would be otherwise referenced, causing that whole archive member to become part of the link.

This default was initially retained for compatibility purposes with historical compilers on the platform which defaulted to this setting. Unfortunately this greedy pulling in of static init can have unintended consequences for applications, for example for programs linked against parts of compiler-rt which contain optional instrumentation (containing static initializers) which may be unused as these now become live in all programs regardless of use.

For that reason and similar reasons, this PR switches the default to mbr, which only extracts static init from archive members which would otherwise be referenced. This gives a behaviour very consistent with linkers on other platforms (e.g. Linux).

Users requiring the old default behaviour can manually pass `-bcdtors:all` on the link step which will override any default we pass here.

(Note: this mirrors LLVM change: llvm/llvm-project#191265)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants