Skip to content

Remove no-asm gating when there is no alternative implementation #994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions builtins-shim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ default = ["compiler-builtins"]
# implementations and also filling in unimplemented intrinsics
c = ["dep:cc"]

# Workaround for the Cranelift codegen backend. Disables any implementations
# which use inline assembly and fall back to pure Rust versions (if available).
# For implementations where there is both a generic version and a platform-
# specific version, use the generic version. This is meant to enable testing
# the generic versions on all platforms.
no-asm = []

# Workaround for codegen backends which haven't yet implemented `f16` and
Expand Down
2 changes: 1 addition & 1 deletion builtins-test/tests/lse.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(decl_macro)] // so we can use pub(super)
#![feature(macro_metavar_expr_concat)]
#![cfg(all(target_arch = "aarch64", target_os = "linux", not(feature = "no-asm")))]
#![cfg(all(target_arch = "aarch64", target_os = "linux"))]

/// Translate a byte size to a Rust type.
macro int_ty {
Expand Down
5 changes: 3 additions & 2 deletions compiler-builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ default = ["compiler-builtins"]
# implementations and also filling in unimplemented intrinsics
c = ["dep:cc"]

# Workaround for the Cranelift codegen backend. Disables any implementations
# which use inline assembly and fall back to pure Rust versions (if available).
# For implementations where there is both a generic version and a platform-
# specific version, use the generic version. This is meant to enable testing
# the generic versions on all platforms.
no-asm = []

# Workaround for codegen backends which haven't yet implemented `f16` and
Expand Down
2 changes: 1 addition & 1 deletion compiler-builtins/src/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::intrinsics;

intrinsics! {
#[unsafe(naked)]
#[cfg(all(target_os = "uefi", not(feature = "no-asm")))]
#[cfg(target_os = "uefi")]
pub unsafe extern "custom" fn __chkstk() {
core::arch::naked_asm!(
".p2align 2",
Expand Down
2 changes: 0 additions & 2 deletions compiler-builtins/src/arm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(not(feature = "no-asm"))]

// Interfaces used by naked trampolines.
// SAFETY: these are defined in compiler-builtins
unsafe extern "C" {
Expand Down
2 changes: 0 additions & 2 deletions compiler-builtins/src/hexagon.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(not(feature = "no-asm"))]

use core::arch::global_asm;

global_asm!(include_str!("hexagon/func_macro.s"), options(raw));
Expand Down
2 changes: 1 addition & 1 deletion compiler-builtins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub mod arm;
#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))]
pub mod aarch64;

#[cfg(all(target_arch = "aarch64", target_os = "linux", not(feature = "no-asm"),))]
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
pub mod aarch64_linux;

#[cfg(all(
Expand Down
2 changes: 0 additions & 2 deletions compiler-builtins/src/probestack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
#![cfg(not(feature = "mangled-names"))]
// Windows and Cygwin already has builtins to do this.
#![cfg(not(any(windows, target_os = "cygwin")))]
// All these builtins require assembly
#![cfg(not(feature = "no-asm"))]
// We only define stack probing for these architectures today.
#![cfg(any(target_arch = "x86_64", target_arch = "x86"))]

Expand Down
10 changes: 2 additions & 8 deletions compiler-builtins/src/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ use core::intrinsics;

intrinsics! {
#[unsafe(naked)]
#[cfg(all(
any(all(windows, target_env = "gnu"), target_os = "uefi"),
not(feature = "no-asm")
))]
#[cfg(any(all(windows, target_env = "gnu"), target_os = "uefi"))]
pub unsafe extern "custom" fn __chkstk() {
core::arch::naked_asm!(
"jmp {}", // Jump to __alloca since fallthrough may be unreliable"
Expand All @@ -21,10 +18,7 @@ intrinsics! {
}

#[unsafe(naked)]
#[cfg(all(
any(all(windows, target_env = "gnu"), target_os = "uefi"),
not(feature = "no-asm")
))]
#[cfg(any(all(windows, target_env = "gnu"), target_os = "uefi"))]
pub unsafe extern "custom" fn _alloca() {
// __chkstk and _alloca are the same function
core::arch::naked_asm!(
Expand Down
9 changes: 1 addition & 8 deletions compiler-builtins/src/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ use core::intrinsics;

intrinsics! {
#[unsafe(naked)]
#[cfg(all(
any(
all(windows, target_env = "gnu"),
target_os = "cygwin",
target_os = "uefi"
),
not(feature = "no-asm")
))]
#[cfg(any(all(windows, target_env = "gnu"), target_os = "cygwin", target_os = "uefi"))]
pub unsafe extern "custom" fn ___chkstk_ms() {
core::arch::naked_asm!(
"push %rcx",
Expand Down