mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 03:07:24 +03:00
Dynamically enable LSE for aarch64 rust provided intrinsics
Create a private module to hold the bootstrap code needed enable LSE at startup on aarch64-*-linux-* targets when rust implements the intrinsics. This is a bit more heavyweight than compiler-rt's LSE initialization, but has the benefit of initializing the aarch64 cpu feature detection for other uses. Using the rust initialization code does use some atomic operations, that's OK. Mixing LSE and non-LSE operations should work while the update flag propagates.
This commit is contained in:
@@ -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
|
||||
};
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user