diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2025-08-07 19:36:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-07 19:36:35 -0500 |
| commit | a8f36867e009ee39f1e51e5ddc8a6587cd241d06 (patch) | |
| tree | 6361222b310eabd12ccc45afad355525152aff54 /library/std/src | |
| parent | 2fd855fbfc8239285aa2d596f76a8cc75e17ce02 (diff) | |
| parent | 6936bb975a50bf3c575d5642018ce19c58dcacf1 (diff) | |
| download | rust-a8f36867e009ee39f1e51e5ddc8a6587cd241d06.tar.gz rust-a8f36867e009ee39f1e51e5ddc8a6587cd241d06.zip | |
Rollup merge of #144705 - pmur:murp/aarch64-lse, r=Amanieu
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/rust#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```````
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/configure_builtins.rs | 22 | ||||
| -rw-r--r-- | library/std/src/sys/mod.rs | 5 |
2 files changed, 27 insertions, 0 deletions
diff --git a/library/std/src/sys/configure_builtins.rs b/library/std/src/sys/configure_builtins.rs new file mode 100644 index 00000000000..9d776b778dc --- /dev/null +++ b/library/std/src/sys/configure_builtins.rs @@ -0,0 +1,22 @@ +/// Hook into .init_array to enable LSE atomic operations at startup, if +/// supported. +#[cfg(all(target_arch = "aarch64", target_os = "linux", not(feature = "compiler-builtins-c")))] +#[used] +#[unsafe(link_section = ".init_array.90")] +static RUST_LSE_INIT: extern "C" fn() = { + extern "C" fn init_lse() { + use crate::arch; + + // This is provided by compiler-builtins::aarch64_linux. + unsafe extern "C" { + fn __rust_enable_lse(); + } + + if arch::is_aarch64_feature_detected!("lse") { + unsafe { + __rust_enable_lse(); + } + } + } + init_lse +}; diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index f9a02b522e5..8ec0a0e3302 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -1,5 +1,10 @@ #![allow(unsafe_op_in_unsafe_fn)] +/// The configure builtins provides runtime support compiler-builtin features +/// which require dynamic intialization to work as expected, e.g. aarch64 +/// outline-atomics. +mod configure_builtins; + /// The PAL (platform abstraction layer) contains platform-specific abstractions /// for implementing the features in the other submodules, e.g. UNIX file /// descriptors. |
