Skip to content

Conversation

pmur
Copy link
Contributor

@pmur pmur commented Jul 9, 2025

Extend the .optimized-compiler-builtins bootstrap option to accept a path to a prebuilt compiler-rt builtins library, and update compiler-builtins to enable optimized builtins without building compiler-rt builtins.

@rustbot
Copy link
Collaborator

rustbot commented Jul 9, 2025

r? @Kobzol

rustbot has assigned @Kobzol.
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 rustbot added A-compiler-builtins Area: compiler-builtins (https://github.com/rust-lang/compiler-builtins) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 9, 2025

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

This PR modifies bootstrap.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

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

cc @tgross35

@rust-log-analyzer

This comment has been minimized.

@pmur pmur force-pushed the murp/external-rt-optimized-compiler-builtins branch from 27fcb13 to 1ea1789 Compare July 9, 2025 18:29
@Kobzol
Copy link
Member

Kobzol commented Jul 9, 2025

I don't really know much about the optimized compiler-rt builtins. Maybe @tgross35 might know more?

@tgross35 tgross35 self-assigned this Jul 9, 2025
@Mark-Simulacrum
Copy link
Member

Can you say more about how much time this saves? Historically it's been my impression locally that building is basically free, this flag is more about whether it's possible to build (e.g., needs to be off if you're ad-hoc cross compiling). Though maybe I'm remembering wrong?

@pmur
Copy link
Contributor Author

pmur commented Jul 10, 2025

Can you say more about how much time this saves? Historically it's been my impression locally that building is basically free, this flag is more about whether it's possible to build (e.g., needs to be off if you're ad-hoc cross compiling). Though maybe I'm remembering wrong?

The goal is to enable optimized compiler-builtins in fedora packaging. There, rust is built using the distro provided llvm and resulting libraries. Some runtime features are absent if optimized compiler-builtins are not used. Notably, outlined aarch64 LSE atomic operations are not available without this support.

@cuviper
Copy link
Member

cuviper commented Jul 10, 2025

Right, it's less about time and more about wanting to use our existing system LLVM packages.

@pmur
Copy link
Contributor Author

pmur commented Jul 22, 2025

Ping @tgross35. The intent here is to enable optimized-builtins in Fedora using the system's compiler-rt.builtins library.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

The changes to compiler-builtins lgtm with a possible rename of the var, assuming you have verified this works locally. Somebody more familiar with bootstrap (@Kobzol?) will need to review the changes there.

@pmur pmur force-pushed the murp/external-rt-optimized-compiler-builtins branch from 1ea1789 to 8ce8e15 Compare July 24, 2025 16:20
@pmur
Copy link
Contributor Author

pmur commented Jul 28, 2025

The changes to compiler-builtins lgtm with a possible rename of the var, assuming you have verified this works locally. Somebody more familiar with bootstrap (@Kobzol?) will need to review the changes there.

I did test builds with the fedora targets (excepting s390x, it lacks a libcompiler-rt.builtins library in rawhide right now). Likewise, I verified the LSE support linked in for aarch64 does work.

Is it a realistic case to consider something trying to link libgcc.a or libcompiler-rt.builtins.a when std already includes a copy of libcompiler-rt.builtins? That case I haven't tested.

Comment on lines 616 to 622
if let Some(dir) = rt_builtins_ext.parent() {
println!("cargo::rustc-link-search=native={}", dir.display());
}
println!(
"cargo::rustc-link-lib=static:+verbatim={}",
rt_builtins_ext.to_str().unwrap()
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does println!("cargo::rustc-link-arg={}", rt_builtins_ext.to_str().unwrap()) work to replace these by chance? I think passing the exact path to the linker should avoid needing to set both -l and -L.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems like it should work, but trying locally (x86-64-unknown-linux-gnu) didn't work as expected. The builtins library wasn't copied into the .rlib as is the case with the above or letting rust built them.

@tgross35
Copy link
Contributor

tgross35 commented Aug 1, 2025

Is it a realistic case to consider something trying to link libgcc.a or libcompiler-rt.builtins.a when std already includes a copy of libcompiler-rt.builtins? That case I haven't tested.

I think this can happen in niche build setups, but no special handling should be needed; all three libraries make their builtin symbols weak, so conflicts aren't a problem.

@bors
Copy link
Collaborator

bors commented Aug 1, 2025

☔ The latest upstream changes (presumably #144773) made this pull request unmergeable. Please resolve the merge conflicts.

@pmur pmur force-pushed the murp/external-rt-optimized-compiler-builtins branch from 8ce8e15 to f8de502 Compare August 4, 2025 21:23
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 7, 2025
compiler-builtins: plumb LSE support for aarch64 on linux/gnu when optimized-compiler-builtins not enabled

Add dynamic support for aarch64 LSE atomic ops on linux/gnu targets when optimized-compiler-builtins is not enabled.

Enabling LSE is the primary motivator for rust-lang#143689, though extending the rust version doesn't seem too farfetched. Are there more details which I have overlooked which make this impractical? I've tested this on an aarch64 host with LSE.

r? `@tgross35`
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 7, 2025
compiler-builtins: plumb LSE support for aarch64 on linux/gnu when optimized-compiler-builtins not enabled

Add dynamic support for aarch64 LSE atomic ops on linux/gnu targets when optimized-compiler-builtins is not enabled.

Enabling LSE is the primary motivator for rust-lang#143689, though extending the rust version doesn't seem too farfetched. Are there more details which I have overlooked which make this impractical? I've tested this on an aarch64 host with LSE.

r? ``@tgross35``
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 7, 2025
compiler-builtins: plumb LSE support for aarch64 on linux/gnu when optimized-compiler-builtins not enabled

Add dynamic support for aarch64 LSE atomic ops on linux/gnu targets when optimized-compiler-builtins is not enabled.

Enabling LSE is the primary motivator for rust-lang#143689, though extending the rust version doesn't seem too farfetched. Are there more details which I have overlooked which make this impractical? I've tested this on an aarch64 host with LSE.

r? ```@tgross35```
tgross35 added a commit to tgross35/rust that referenced this pull request Aug 7, 2025
compiler-builtins: plumb LSE support for aarch64 on linux/gnu when optimized-compiler-builtins not enabled

Add dynamic support for aarch64 LSE atomic ops on linux/gnu targets when optimized-compiler-builtins is not enabled.

Enabling LSE is the primary motivator for rust-lang#143689, though extending the rust version doesn't seem too farfetched. Are there more details which I have overlooked which make this impractical? I've tested this on an aarch64 host with LSE.

r? ````@tgross35````
tgross35 added a commit to tgross35/rust that referenced this pull request Aug 7, 2025
compiler-builtins: plumb LSE support for aarch64 on linux/gnu when optimized-compiler-builtins not enabled

Add dynamic support for aarch64 LSE atomic ops on linux/gnu targets when optimized-compiler-builtins is not enabled.

Enabling LSE is the primary motivator for rust-lang#143689, though extending the rust version doesn't seem too farfetched. Are there more details which I have overlooked which make this impractical? I've tested this on an aarch64 host with LSE.

r? `````@tgross35`````
tgross35 added a commit to tgross35/rust that referenced this pull request Aug 8, 2025
compiler-builtins: plumb LSE support for aarch64 on linux/gnu when optimized-compiler-builtins not enabled

Add dynamic support for aarch64 LSE atomic ops on linux/gnu targets when optimized-compiler-builtins is not enabled.

Enabling LSE is the primary motivator for rust-lang#143689, though extending the rust version doesn't seem too farfetched. Are there more details which I have overlooked which make this impractical? I've tested this on an aarch64 host with LSE.

r? ``````@tgross35``````
tgross35 added a commit to tgross35/rust that referenced this pull request Aug 8, 2025
compiler-builtins: plumb LSE support for aarch64 on linux/gnu when optimized-compiler-builtins not enabled

Add dynamic support for aarch64 LSE atomic ops on linux/gnu targets when optimized-compiler-builtins is not enabled.

Enabling LSE is the primary motivator for rust-lang#143689, though extending the rust version doesn't seem too farfetched. Are there more details which I have overlooked which make this impractical? I've tested this on an aarch64 host with LSE.

r? ```````@tgross35```````
Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

Since this changes config options, you could also add a change entry to change_tracker.rs, but this is probably so niche that it's not even needed.

LGTM from my side.

@pmur pmur force-pushed the murp/external-rt-optimized-compiler-builtins branch 2 times, most recently from ad333e4 to 12172b6 Compare August 20, 2025 20:22
@rustbot

This comment has been minimized.

@pmur
Copy link
Contributor Author

pmur commented Aug 20, 2025

Thanks. I also tried to improve the documentation in bootstrap.example.toml too.

@bors
Copy link
Collaborator

bors commented Aug 22, 2025

☔ The latest upstream changes (presumably #145352) made this pull request unmergeable. Please resolve the merge conflicts.

@pmur pmur force-pushed the murp/external-rt-optimized-compiler-builtins branch from 12172b6 to c1d67ef Compare August 25, 2025 14:54
@rustbot

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Aug 25, 2025

☔ The latest upstream changes (presumably #145472) made this pull request unmergeable. Please resolve the merge conflicts.

Paul Murphy and others added 2 commits August 25, 2025 16:08
Extend the <target>.optimized-compiler-builtins bootstrap option to accept a
path to a prebuilt compiler-rt builtins library, and update compiler-builtins
to enable optimized builtins without building compiler-rt builtins.
Create a dedicated enum to abstract the different ways compiler-builtins
can be configured.

This also relaxes build.optimized-compiler-builtins to accept the path
of a library to match the behavior of <target>.optimized-compiler-builtins
override.
@pmur pmur force-pushed the murp/external-rt-optimized-compiler-builtins branch from c1d67ef to 148a07c Compare August 25, 2025 21:10
@rustbot
Copy link
Collaborator

rustbot commented Aug 25, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@tgross35
Copy link
Contributor

Thanks for the updates, LGTM as well
@bors r=Kobzol,tgross35

@bors
Copy link
Collaborator

bors commented Aug 25, 2025

📌 Commit 148a07c has been approved by Kobzol,tgross35

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 Aug 25, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 26, 2025
…mpiler-builtins, r=Kobzol,tgross35

Allow linking a prebuilt optimized compiler-rt builtins library

Extend the <target>.optimized-compiler-builtins bootstrap option to accept a path to a prebuilt compiler-rt builtins library, and update compiler-builtins to enable optimized builtins without building compiler-rt builtins.
bors added a commit that referenced this pull request Aug 26, 2025
Rollup of 13 pull requests

Successful merges:

 - #143193 (Port `#[link]` to the new attribute parsing infrastructure )
 - #143689 (Allow linking a prebuilt optimized compiler-rt builtins library)
 - #144885 (Implement some more checks in `ptr_guaranteed_cmp`. )
 - #145535 (make rustdoc::invalid_html_tags more robust)
 - #145766 (test(rustfmt): Verify frontmatter is preserved)
 - #145811 (Fix some minor issues in comments)
 - #145814 (Handle unwinding fatal errors in codegen workers)
 - #145815 (Wait for DPkg frontend lock when trying to remove packages)
 - #145821 (compiletest: if a compiler fails, show its output)
 - #145845 (Make `x test distcheck` self-contained)
 - #145847 (Don't show warnings from xcrun with -Zverbose-internals)
 - #145856 (Update books)
 - #145858 (Update wasm-component-ld dependency)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 26, 2025
Rollup of 12 pull requests

Successful merges:

 - #143689 (Allow linking a prebuilt optimized compiler-rt builtins library)
 - #144885 (Implement some more checks in `ptr_guaranteed_cmp`. )
 - #145535 (make rustdoc::invalid_html_tags more robust)
 - #145766 (test(rustfmt): Verify frontmatter is preserved)
 - #145811 (Fix some minor issues in comments)
 - #145814 (Handle unwinding fatal errors in codegen workers)
 - #145815 (Wait for DPkg frontend lock when trying to remove packages)
 - #145821 (compiletest: if a compiler fails, show its output)
 - #145845 (Make `x test distcheck` self-contained)
 - #145847 (Don't show warnings from xcrun with -Zverbose-internals)
 - #145856 (Update books)
 - #145858 (Update wasm-component-ld dependency)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 26, 2025
…tins, r=Kobzol,tgross35

Allow linking a prebuilt optimized compiler-rt builtins library

Extend the <target>.optimized-compiler-builtins bootstrap option to accept a path to a prebuilt compiler-rt builtins library, and update compiler-builtins to enable optimized builtins without building compiler-rt builtins.
@bors
Copy link
Collaborator

bors commented Aug 26, 2025

⌛ Testing commit 148a07c with merge 822f4de...

@Zalathar
Copy link
Contributor

Yielding to enclosing rollup, which flaked out.

@bors retry

bors added a commit that referenced this pull request Aug 26, 2025
Rollup of 12 pull requests

Successful merges:

 - #143689 (Allow linking a prebuilt optimized compiler-rt builtins library)
 - #144885 (Implement some more checks in `ptr_guaranteed_cmp`. )
 - #145535 (make rustdoc::invalid_html_tags more robust)
 - #145766 (test(rustfmt): Verify frontmatter is preserved)
 - #145811 (Fix some minor issues in comments)
 - #145814 (Handle unwinding fatal errors in codegen workers)
 - #145815 (Wait for DPkg frontend lock when trying to remove packages)
 - #145821 (compiletest: if a compiler fails, show its output)
 - #145845 (Make `x test distcheck` self-contained)
 - #145847 (Don't show warnings from xcrun with -Zverbose-internals)
 - #145856 (Update books)
 - #145858 (Update wasm-component-ld dependency)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2741508 into rust-lang:master Aug 26, 2025
10 of 11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 26, 2025
rust-timer added a commit that referenced this pull request Aug 26, 2025
Rollup merge of #143689 - pmur:murp/external-rt-optimized-compiler-builtins, r=Kobzol,tgross35

Allow linking a prebuilt optimized compiler-rt builtins library

Extend the <target>.optimized-compiler-builtins bootstrap option to accept a path to a prebuilt compiler-rt builtins library, and update compiler-builtins to enable optimized builtins without building compiler-rt builtins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiler-builtins Area: compiler-builtins (https://github.com/rust-lang/compiler-builtins) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants