Skip to content

Re-enable outline-atomics by default on more AArch64 platforms - #164564

Merged
rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
tgross35:outline-atomics
Nov 5, 2026
Merged

rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
tgross35:outline-atomics

Conversation

@tgross35

@tgross35 tgross35 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

These originally landed in #144938 and #149633, then were reverted in #151896 due to #151486. As that issue has been resolved, re-enable them here.

There is a lot of additional context at the original PR (#144938) and the Zulip discussion leading up to it #t-compiler > outline-atomics on non-Linux targets.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 19, 2026
Windows has a similar flag `/forceInterlockedFunctions`, which uses
names such as `_InterlockedAdd64_rel`.

This is a re-land of 1ed1b6e ("Enable `outline-atomics` by default
on AArch64 Windows platforms").
Per LLVM commit c5e7e64 ("[AArch64][Clang][Linux] Enable
out-of-line atomics by default.") [1], Clang enables these on Android.
Thus, do the same in Rust.

This is a re-land of c455903 ("Enable `outline-atomics` by default
on AArch64 Android").

[1]: llvm/llvm-project@c5e7e649d537067de
Clang has done this by default since LLVM commit 1a963d3 ("[Driver]
Make -moutline-atomics default for aarch64-fuchsia targets"), [1], so do
the same here.

This is a re-land of 21525f8 ("Enable `outline-atomics` by default
on AArch64 Fuchsia").

[1]: llvm/llvm-project@1a963d3
Clang has recently started doing this, as of LLVM commit 5d774ec8d183
("[Driver] Enable outline atomics for OpenBSD/aarch64") [1]. Thus, do
the same here.

This is a re-land of 66c150c ("Enable `outline-atomics` by default
on AArch64 OpenBSD").

[1]: llvm/llvm-project@5d774ec
Many aarch64 targets without LSE in the baseline enable the
`outline-atomics` feature, which uses runtime detection of LSE for its
faster atomic ops. This provides nontrivial performance improvements on
most hardware from the past decade, at a small cost to anything pre-LSE.

This matches what Clang does [1].

This is a re-land of 383053e ("Enable `outline-atomics` by default
on AArch64 FreeBSD").

[1]: llvm/llvm-project@e24f901
@tgross35

Copy link
Copy Markdown
Member Author

@bors try jobs=dist-aarch64-freebsd,dist-aarch64-msvc

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 29, 2026
Re-enable outline-atomics by default on more AArch64 platforms


try-job: dist-aarch64-freebsd
try-job: dist-aarch64-msvc
@tgross35
tgross35 marked this pull request as ready for review October 29, 2026 22:51
@rustbot

rustbot commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

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

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

rustbot commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

r? @chenyukang

rustbot has assigned @chenyukang.
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 77 candidates
  • Random selection from 22 candidates

@rust-bors

rust-bors Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 57192fa (57192fa2706dda5be0e04e36e4a00f25b6a35b19)
Base parent: 96a18bf (96a18bf5ffa2b24f9cf3d1c731a9eb121c1acad9)

@chenyukang

Copy link
Copy Markdown
Member

@rustbot reroll

@ilovepi ilovepi 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.

LGTM. We definitely want this for Fuchsia, and are already seeing some issues w/o it.

View changes since this review

@ilovepi

ilovepi commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

I understand review capacity is limited, but is there a way we can get this landed soon, or restore and land #165212? We're unable to qualify new toolchains without this, so we'd like to see this go through ASAP. Is there something we could help with?

@tgross35

tgross35 commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

For future reference you can always ask on Zulip, I did so at #t-compiler/help > Review request.

For my understanding, why did this become necessary in Fuchsia? The inline versions should work fine, and you can mix and match.

@workingjubilee

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ec3b6ca has been approved by workingjubilee

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

Copy link
Copy Markdown
Member

@ilovepi I would like to know the answer to @tgross35's question about necessity.

@erickt

erickt commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

We were hitting compilation failures like https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/rust_toolchain.core.arm64-release-subbuild/b8666562801022530657/overview, which I think should be accessible from outside Google. If not, it was errors like this where the outline atomic functions were undefined:

error: linking with `../../prebuilt/third_party/clang/linux-x64/bin/lld` failed: exit status: 1
  |
  = note:  "../../prebuilt/third_party/clang/linux-x64/bin/lld" "-flavor" "gnu" "--version-script=/b/s/w/ir/x/w/fuchsia/out/not-default/rust-shared/lib.unstripped/rustcTLVmvA/list" "--no-undefined-version" "--build-id" "--hash-style=gnu" "-z" "max-page-size=4096" "-z" "now" "-z" "start-stop-visibility=hidden" "-z" "rodynamic" "-z" "separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr"...
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: lld: error: undefined symbol: __aarch64_cas4_acq_rel
          >>> referenced by completion.c:30 (./../../zircon/system/ulib/sync/completion.c:30)
          >>>               libsync.completion.c.o:(sync_completion_wait_deadline) in archive obj/zircon/system/ulib/sync/libsync.a
          >>> referenced by completion.c:148 (./../../zircon/system/ulib/sync/completion.c:148)
          >>>               libsync.completion.c.o:(sync_completion_signal) in archive obj/zircon/system/ulib/sync/libsync.a
          >>> referenced by completion.c:177 (./../../zircon/system/ulib/sync/completion.c:177)
          >>>               libsync.completion.c.o:(sync_completion_reset) in archive obj/zircon/system/ulib/sync/libsync.a
          
          lld: error: undefined symbol: __aarch64_cas4_acq
          >>> referenced by mutex.c:40 (./../../zircon/system/ulib/sync/mutex.c:40)
          >>>               libsync.mutex.c.o:(lock_slow_path) in archive obj/zircon/system/ulib/sync/libsync.a
          >>> referenced by mutex.c:85 (./../../zircon/system/ulib/sync/mutex.c:85)
          >>>               libsync.mutex.c.o:(lock_slow_path) in archive obj/zircon/system/ulib/sync/libsync.a
          >>> referenced by mutex.c:106 (./../../zircon/system/ulib/sync/mutex.c:106)
          >>>               libsync.mutex.c.o:(sync_mutex_lock) in archive obj/zircon/system/ulib/sync/libsync.a
          
          lld: error: undefined symbol: __aarch64_swp4_rel
          >>> referenced by mutex.c:139 (./../../zircon/system/ulib/sync/mutex.c:139)
          >>>               libsync.mutex.c.o:(sync_mutex_unlock) in archive obj/zircon/system/ulib/sync/libsync.a

We traced the issue down to the roll of compiler-builtins PR rust-lang/compiler-builtins#1354, which as far as we can tell ended up only compiling these functions if the outline-atomics target_feature is enabled. So it seems we've been using these functions anyway, but never actually expressed these dependencies?

@tgross35

tgross35 commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

It looks like those locations point to .c files, could your C toolchain be setting -moutline-atomics (maybe a new Clang default)? That wouldn't be related to Rust if so.

After this PR merges or if you set (unstable) +optimize-atomics manually, Rust's c-b will provide a definition for these symbols that would fix your linker errors. But even without this PR you should be able to grab the needed definitions from either libgcc or compiler-rt, if you're also linking those then maybe it's missing some config setup.

jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 5, 2026
…gjubilee

Re-enable outline-atomics by default on more AArch64 platforms

These originally landed in rust-lang#144938 and rust-lang#149633, then were reverted in rust-lang#151896 due to rust-lang#151486. As that issue has been resolved, re-enable them here.

There is a lot of additional context at the original PR (rust-lang#144938) and the Zulip discussion leading up to it [#t-compiler > outline-atomics on non-Linux targets](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/outline-atomics.20on.20non-Linux.20targets/with/537964562).
jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 5, 2026
…gjubilee

Re-enable outline-atomics by default on more AArch64 platforms

These originally landed in rust-lang#144938 and rust-lang#149633, then were reverted in rust-lang#151896 due to rust-lang#151486. As that issue has been resolved, re-enable them here.

There is a lot of additional context at the original PR (rust-lang#144938) and the Zulip discussion leading up to it [#t-compiler > outline-atomics on non-Linux targets](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/outline-atomics.20on.20non-Linux.20targets/with/537964562).
rust-bors Bot pushed a commit that referenced this pull request Nov 5, 2026
Rollup of 13 pull requests

Successful merges:

 - #163477 (Fancy paramenv accessors that communicate the access pattern better.)
 - #160593 (turn ABI-controlling target features into a target modifier)
 - #164896 (offload: pass the linked device image to the host pass)
 - #165468 (Remove return type from `BuilderMethods::store`)
 - #159374 (Lower #[no_mangle] to #[symbol_name]/#[link_name])
 - #164564 (Re-enable outline-atomics by default on more AArch64 platforms)
 - #164623 (add next-solver regression tests for two fixed ices)
 - #164678 (add next-solver regression test for recursive opaque ICE under validate-mir)
 - #165429 (Add tests for `-Zcrate-attr` edition and position)
 - #165430 ([tiny] Show context for found assoc item in E0107)
 - #165456 (std: Fix build for the L4Re targets)
 - #165463 (Add BTreeMap::allocator and BTreeSet::allocator)
 - #165466 (Don't "exit" using `panic` on teeos)
rust-bors Bot pushed a commit that referenced this pull request Nov 5, 2026
Rollup of 15 pull requests

Successful merges:

 - #163477 (Fancy paramenv accessors that communicate the access pattern better.)
 - #160593 (turn ABI-controlling target features into a target modifier)
 - #164896 (offload: pass the linked device image to the host pass)
 - #165468 (Remove return type from `BuilderMethods::store`)
 - #164564 (Re-enable outline-atomics by default on more AArch64 platforms)
 - #164623 (add next-solver regression tests for two fixed ices)
 - #164653 (Deprecate internal function `vec::from_elem`)
 - #164678 (add next-solver regression test for recursive opaque ICE under validate-mir)
 - #165387 (windows OpenOptionsExt examples: replace winapi by windows crate)
 - #165429 (Add tests for `-Zcrate-attr` edition and position)
 - #165430 ([tiny] Show context for found assoc item in E0107)
 - #165456 (std: Fix build for the L4Re targets)
 - #165463 (Add BTreeMap::allocator and BTreeSet::allocator)
 - #165466 (Don't "exit" using `panic` on teeos)
 - #165491 (Remove unused compiler types and associated helpers)
@rust-bors
rust-bors Bot merged commit 1759540 into rust-lang:main Nov 5, 2026
15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Nov 5, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 5, 2026
Rollup merge of #164564 - tgross35:outline-atomics, r=workingjubilee

Re-enable outline-atomics by default on more AArch64 platforms

These originally landed in #144938 and #149633, then were reverted in #151896 due to #151486. As that issue has been resolved, re-enable them here.

There is a lot of additional context at the original PR (#144938) and the Zulip discussion leading up to it [#t-compiler > outline-atomics on non-Linux targets](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/outline-atomics.20on.20non-Linux.20targets/with/537964562).
@tgross35
tgross35 deleted the outline-atomics branch November 5, 2026 14:16
@ilovepi

ilovepi commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

First thanks for prioritizing this. And sorry for the belated response.

It looks like those locations point to .c files, could your C toolchain be setting -moutline-atomics (maybe a new Clang default)? That wouldn't be related to Rust if so.

Yes. Outline atomics is the default in clang for a bit now, so it's set there. The recent change to the builtins disabled the ability to defer the atomics to compiler-rt version when building the toolchain, unless this feature is part of the triple.

After this PR merges or if you set (unstable) +optimize-atomics manually, Rust's c-b will provide a definition for these symbols that would fix your linker errors.

It's important to us that we use a single copy of the builtins since we have arbitrarily mixed Rust and C++, and we typically expect them to work identically even in the presence of cross-language inlining. Our intent is always to have the code generation options set consistently between all of our toolchains, and for us to use the canonical versions of common runtime routines, like the builtins.

But even without this PR you should be able to grab the needed definitions from either libgcc or compiler-rt, if you're also linking those then maybe it's missing some config setup.

While there may be a workaround, we'd prefer not to have to manually add the compiler builtins to all of our targets, or communicate that to people building for the Fuchsia platform. This option seems like the first step of several we'll want to pursue to align these things up across all of our targets, and is the minimal thing that would get us new candidates w/o fairly large scale build system surgery that we expect to be rather temporary.

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.

7 participants