Skip to content

Commit acb349a

Browse files
committed
try using #[cfg(bootstrap)]
1 parent 614ab5e commit acb349a

File tree

7 files changed

+32
-16
lines changed

7 files changed

+32
-16
lines changed

compiler-builtins/src/aarch64.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
use core::intrinsics;
44

55
intrinsics! {
6-
#[unsafe(naked)]
6+
#[cfg_attr(bootstrap, naked)]
7+
#[cfg_attr(not(bootstrap), unsafe(naked))]
78
#[cfg(all(target_os = "uefi", not(feature = "no-asm")))]
89
pub unsafe extern "C" fn __chkstk() {
910
core::arch::naked_asm!(

compiler-builtins/src/aarch64_linux.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ macro_rules! compare_and_swap {
131131
($ordering:ident, $bytes:tt, $name:ident) => {
132132
intrinsics! {
133133
#[maybe_use_optimized_c_shim]
134-
#[unsafe(naked)]
134+
#[cfg_attr(bootstrap, naked)]
135+
#[cfg_attr(not(bootstrap), unsafe(naked))]
135136
pub unsafe extern "C" fn $name (
136137
expected: int_ty!($bytes), desired: int_ty!($bytes), ptr: *mut int_ty!($bytes)
137138
) -> int_ty!($bytes) {
@@ -161,7 +162,8 @@ macro_rules! compare_and_swap_i128 {
161162
($ordering:ident, $name:ident) => {
162163
intrinsics! {
163164
#[maybe_use_optimized_c_shim]
164-
#[unsafe(naked)]
165+
#[cfg_attr(bootstrap, naked)]
166+
#[cfg_attr(not(bootstrap), unsafe(naked))]
165167
pub unsafe extern "C" fn $name (
166168
expected: i128, desired: i128, ptr: *mut i128
167169
) -> i128 {
@@ -190,7 +192,8 @@ macro_rules! swap {
190192
($ordering:ident, $bytes:tt, $name:ident) => {
191193
intrinsics! {
192194
#[maybe_use_optimized_c_shim]
193-
#[unsafe(naked)]
195+
#[cfg_attr(bootstrap, naked)]
196+
#[cfg_attr(not(bootstrap), unsafe(naked))]
194197
pub unsafe extern "C" fn $name (
195198
left: int_ty!($bytes), right_ptr: *mut int_ty!($bytes)
196199
) -> int_ty!($bytes) {
@@ -215,7 +218,8 @@ macro_rules! fetch_op {
215218
($ordering:ident, $bytes:tt, $name:ident, $op:literal) => {
216219
intrinsics! {
217220
#[maybe_use_optimized_c_shim]
218-
#[unsafe(naked)]
221+
#[cfg_attr(bootstrap, naked)]
222+
#[cfg_attr(not(bootstrap), unsafe(naked))]
219223
pub unsafe extern "C" fn $name (
220224
val: int_ty!($bytes), ptr: *mut int_ty!($bytes)
221225
) -> int_ty!($bytes) {

compiler-builtins/src/arm.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ macro_rules! bl {
2020
intrinsics! {
2121
// NOTE This function and the ones below are implemented using assembly because they are using a
2222
// custom calling convention which can't be implemented using a normal Rust function.
23-
#[unsafe(naked)]
23+
#[cfg_attr(bootstrap, naked)]
24+
#[cfg_attr(not(bootstrap), unsafe(naked))]
2425
#[cfg(not(target_env = "msvc"))]
2526
pub unsafe extern "C" fn __aeabi_uidivmod() {
2627
core::arch::naked_asm!(
@@ -34,7 +35,8 @@ intrinsics! {
3435
);
3536
}
3637

37-
#[unsafe(naked)]
38+
#[cfg_attr(bootstrap, naked)]
39+
#[cfg_attr(not(bootstrap), unsafe(naked))]
3840
pub unsafe extern "C" fn __aeabi_uldivmod() {
3941
core::arch::naked_asm!(
4042
"push {{r4, lr}}",
@@ -49,7 +51,8 @@ intrinsics! {
4951
);
5052
}
5153

52-
#[unsafe(naked)]
54+
#[cfg_attr(bootstrap, naked)]
55+
#[cfg_attr(not(bootstrap), unsafe(naked))]
5356
pub unsafe extern "C" fn __aeabi_idivmod() {
5457
core::arch::naked_asm!(
5558
"push {{r0, r1, r4, lr}}",
@@ -61,7 +64,8 @@ intrinsics! {
6164
);
6265
}
6366

64-
#[unsafe(naked)]
67+
#[cfg_attr(bootstrap, naked)]
68+
#[cfg_attr(not(bootstrap), unsafe(naked))]
6569
pub unsafe extern "C" fn __aeabi_ldivmod() {
6670
core::arch::naked_asm!(
6771
"push {{r4, lr}}",

compiler-builtins/src/int/udiv.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ intrinsics! {
4444
((rem as u64) << 32) | (div as u64)
4545
}
4646

47-
#[unsafe(naked)]
47+
#[cfg_attr(bootstrap, naked)]
48+
#[cfg_attr(not(bootstrap), unsafe(naked))]
4849
pub unsafe extern "C" fn __udivmodqi4() {
4950
// compute unsigned 8-bit `n / d` and `n % d`.
5051
//
@@ -79,7 +80,8 @@ intrinsics! {
7980
);
8081
}
8182

82-
#[unsafe(naked)]
83+
#[cfg_attr(bootstrap, naked)]
84+
#[cfg_attr(not(bootstrap), unsafe(naked))]
8385
pub unsafe extern "C" fn __udivmodhi4() {
8486
// compute unsigned 16-bit `n / d` and `n % d`.
8587
//

compiler-builtins/src/macros.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ macro_rules! intrinsics {
423423
// Naked functions are special: we can't generate wrappers for them since
424424
// they use a custom calling convention.
425425
(
426-
#[unsafe(naked)]
426+
#[cfg_attr(bootstrap, naked)]
427+
#[cfg_attr(not(bootstrap), unsafe(naked))]
427428
$(#[$($attr:tt)*])*
428429
pub unsafe extern $abi:tt fn $name:ident( $($argname:ident: $ty:ty),* ) $(-> $ret:ty)? {
429430
$($body:tt)*
@@ -433,7 +434,8 @@ macro_rules! intrinsics {
433434
) => (
434435
// `#[naked]` definitions are referenced by other places, so we can't use `cfg` like the others
435436
pub mod $name {
436-
#[unsafe(naked)]
437+
#[cfg_attr(bootstrap, naked)]
438+
#[cfg_attr(not(bootstrap), unsafe(naked))]
437439
$(#[$($attr)*])*
438440
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
439441
#[cfg_attr(not(any(all(windows, target_env = "gnu"), target_os = "cygwin")), linkage = "weak")]

compiler-builtins/src/x86.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use core::intrinsics;
88
// NOTE These functions are never mangled as they are not tested against compiler-rt
99

1010
intrinsics! {
11-
#[unsafe(naked)]
11+
#[cfg_attr(bootstrap, naked)]
12+
#[cfg_attr(not(bootstrap), unsafe(naked))]
1213
#[cfg(all(
1314
any(all(windows, target_env = "gnu"), target_os = "uefi"),
1415
not(feature = "no-asm")
@@ -20,7 +21,8 @@ intrinsics! {
2021
);
2122
}
2223

23-
#[unsafe(naked)]
24+
#[cfg_attr(bootstrap, naked)]
25+
#[cfg_attr(not(bootstrap), unsafe(naked))]
2426
#[cfg(all(
2527
any(all(windows, target_env = "gnu"), target_os = "uefi"),
2628
not(feature = "no-asm")

compiler-builtins/src/x86_64.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use core::intrinsics;
88
// NOTE These functions are never mangled as they are not tested against compiler-rt
99

1010
intrinsics! {
11-
#[unsafe(naked)]
11+
#[cfg_attr(bootstrap, naked)]
12+
#[cfg_attr(not(bootstrap), unsafe(naked))]
1213
#[cfg(all(
1314
any(
1415
all(windows, target_env = "gnu"),

0 commit comments

Comments
 (0)