Skip to content

Commit b7cdb73

Browse files
committed
Remove no-asm gating when there is no alternative implementation
Assembly-related configuration was added in 1621c6d ("Use `specialized-div-rem` 1.0.0 for division algorithms") to account for Cranelift not yet supporting assembly. This hasn't been relevant for a while, so we no longer need to gate `asm!` behind this configuration. Thus, remove `cfg(not(feature = "no-asm"))` in places where there is no generic fallback. There are other cases, however, where setting the `no-asm` configuration enables testing of generic version of builtins when there are platform- specific implementations available; these cases are left unchanged. This could be improved in the future by exposing both versions for testing rather than using a configuration and running the entire testsuite twice. This is the compiler-builtins portion of rust-lang/rust#144471.
1 parent a4f24dc commit b7cdb73

File tree

10 files changed

+12
-29
lines changed

10 files changed

+12
-29
lines changed

builtins-shim/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ default = ["compiler-builtins"]
3737
# implementations and also filling in unimplemented intrinsics
3838
c = ["dep:cc"]
3939

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

4445
# Workaround for codegen backends which haven't yet implemented `f16` and

builtins-test/tests/lse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(decl_macro)] // so we can use pub(super)
22
#![feature(macro_metavar_expr_concat)]
3-
#![cfg(all(target_arch = "aarch64", target_os = "linux", not(feature = "no-asm")))]
3+
#![cfg(all(target_arch = "aarch64", target_os = "linux"))]
44

55
/// Translate a byte size to a Rust type.
66
macro int_ty {

compiler-builtins/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ default = ["compiler-builtins"]
3535
# implementations and also filling in unimplemented intrinsics
3636
c = ["dep:cc"]
3737

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

4243
# Workaround for codegen backends which haven't yet implemented `f16` and

compiler-builtins/src/aarch64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::intrinsics;
44

55
intrinsics! {
66
#[unsafe(naked)]
7-
#[cfg(all(target_os = "uefi", not(feature = "no-asm")))]
7+
#[cfg(target_os = "uefi")]
88
pub unsafe extern "custom" fn __chkstk() {
99
core::arch::naked_asm!(
1010
".p2align 2",

compiler-builtins/src/arm.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(feature = "no-asm"))]
2-
31
// Interfaces used by naked trampolines.
42
// SAFETY: these are defined in compiler-builtins
53
unsafe extern "C" {

compiler-builtins/src/hexagon.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(feature = "no-asm"))]
2-
31
use core::arch::global_asm;
42

53
global_asm!(include_str!("hexagon/func_macro.s"), options(raw));

compiler-builtins/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub mod arm;
6060
#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))]
6161
pub mod aarch64;
6262

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

6666
#[cfg(all(

compiler-builtins/src/probestack.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
#![cfg(not(feature = "mangled-names"))]
4545
// Windows and Cygwin already has builtins to do this.
4646
#![cfg(not(any(windows, target_os = "cygwin")))]
47-
// All these builtins require assembly
48-
#![cfg(not(feature = "no-asm"))]
4947
// We only define stack probing for these architectures today.
5048
#![cfg(any(target_arch = "x86_64", target_arch = "x86"))]
5149

compiler-builtins/src/x86.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ use core::intrinsics;
99

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

2320
#[unsafe(naked)]
24-
#[cfg(all(
25-
any(all(windows, target_env = "gnu"), target_os = "uefi"),
26-
not(feature = "no-asm")
27-
))]
21+
#[cfg(any(all(windows, target_env = "gnu"), target_os = "uefi"))]
2822
pub unsafe extern "custom" fn _alloca() {
2923
// __chkstk and _alloca are the same function
3024
core::arch::naked_asm!(

compiler-builtins/src/x86_64.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@ use core::intrinsics;
99

1010
intrinsics! {
1111
#[unsafe(naked)]
12-
#[cfg(all(
13-
any(
14-
all(windows, target_env = "gnu"),
15-
target_os = "cygwin",
16-
target_os = "uefi"
17-
),
18-
not(feature = "no-asm")
19-
))]
12+
#[cfg(any(all(windows, target_env = "gnu"), target_os = "cygwin", target_os = "uefi"))]
2013
pub unsafe extern "custom" fn ___chkstk_ms() {
2114
core::arch::naked_asm!(
2215
"push %rcx",

0 commit comments

Comments
 (0)