Verified Solution[rust-lang/rust] SIGSEGV in rustc when using #[link_name = "llvm.aarch64.rndrrs"]
Sponsored Content
### ROOT CAUSE
The issue occurs because the compiler crashes when processing the `#[link_name]` attribute with an intrinsic name that is not properly recognized. The crash is due to the compiler's internal handling of intrinsics and name mangling, particularly when using `#[link_name]` with an LLVM intrinsic. The specific combination of the `link_llvm_intrinsics` feature and the `#[link_name]` attribute on aarch64 causes an internal compiler error.
### CODE FIX
To resolve this issue, the user should avoid using the `link_llvm_intrinsics` feature and instead use the standard `core::arch::aarch64` module, which provides safe and stable access to CPU intrinsics. Here's the fixed code:
```rust
mod arch {
#[cfg(target_arch = "aarch64")]
pub(crate) unsafe fn seed(out: &mut u64) -> i32 {
// Use the core::arch::aarch64 module if available
// This is a stable way to access aarch64 intrinsics
unsafe {
core::arch::aarch64::llvm_aarch64_rndrrs(out)
}
}
}
```
This approach uses the standard Rust intrinsics module, which is more reliable and avoids the compiler crash. Ensure that the `core_arch` feature is enabled in your project dependencies if necessary. For more details, refer to the [Rust intrinsics documentation](https://doc.rust-lang.org/core/arch/index.html).
Deploy on DigitalOcean ($200 Credit)
Related Fixes
[golang/go] proposal: x/tools/go/analysis/passes/modernize: vars for atomic, errorsastype, plusbuild, stringscut, stditerators
[StackOverflow/go] Go http client.do returns error and nil response
[microsoft/vscode] All of a sudden the whole VS code extensions got refreshed on their own.