Skip to content

Commit 537db9a

Browse files
committed
Disable 128bit atomic operations on macOS
1 parent f2f5452 commit 537db9a

File tree

3 files changed

+152
-1
lines changed

3 files changed

+152
-1
lines changed

build_sysroot/prepare_sysroot_src.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ git clone https://github.com/rust-lang/compiler-builtins.git || echo "rust-lang/
3333
pushd compiler-builtins
3434
git checkout -- .
3535
git checkout 0.1.39
36-
git apply ../../crate_patches/0001-compiler-builtins-Remove-rotate_left-from-Int.patch
36+
git apply ../../crate_patches/000*-compiler-builtins-*.patch
3737
popd
3838

3939
echo "Successfully prepared sysroot source for building"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
From 1d574bf5e32d51641dcacaf8ef777e95b44f6f2a Mon Sep 17 00:00:00 2001
2+
From: bjorn3 <[email protected]>
3+
Date: Thu, 18 Feb 2021 18:30:55 +0100
4+
Subject: [PATCH] Disable 128bit atomic operations
5+
6+
Cranelift doesn't support them yet
7+
---
8+
src/mem/mod.rs | 12 ------------
9+
1 file changed, 12 deletions(-)
10+
11+
diff --git a/src/mem/mod.rs b/src/mem/mod.rs
12+
index 107762c..2d1ae10 100644
13+
--- a/src/mem/mod.rs
14+
+++ b/src/mem/mod.rs
15+
@@ -137,10 +137,6 @@ intrinsics! {
16+
pub extern "C" fn __llvm_memcpy_element_unordered_atomic_8(dest: *mut u64, src: *const u64, bytes: usize) -> () {
17+
memcpy_element_unordered_atomic(dest, src, bytes);
18+
}
19+
- #[cfg(target_has_atomic_load_store = "128")]
20+
- pub extern "C" fn __llvm_memcpy_element_unordered_atomic_16(dest: *mut u128, src: *const u128, bytes: usize) -> () {
21+
- memcpy_element_unordered_atomic(dest, src, bytes);
22+
- }
23+
24+
#[cfg(target_has_atomic_load_store = "8")]
25+
pub extern "C" fn __llvm_memmove_element_unordered_atomic_1(dest: *mut u8, src: *const u8, bytes: usize) -> () {
26+
@@ -158,10 +154,6 @@ intrinsics! {
27+
pub extern "C" fn __llvm_memmove_element_unordered_atomic_8(dest: *mut u64, src: *const u64, bytes: usize) -> () {
28+
memmove_element_unordered_atomic(dest, src, bytes);
29+
}
30+
- #[cfg(target_has_atomic_load_store = "128")]
31+
- pub extern "C" fn __llvm_memmove_element_unordered_atomic_16(dest: *mut u128, src: *const u128, bytes: usize) -> () {
32+
- memmove_element_unordered_atomic(dest, src, bytes);
33+
- }
34+
35+
#[cfg(target_has_atomic_load_store = "8")]
36+
pub extern "C" fn __llvm_memset_element_unordered_atomic_1(s: *mut u8, c: u8, bytes: usize) -> () {
37+
@@ -179,8 +171,4 @@ intrinsics! {
38+
pub extern "C" fn __llvm_memset_element_unordered_atomic_8(s: *mut u64, c: u8, bytes: usize) -> () {
39+
memset_element_unordered_atomic(s, c, bytes);
40+
}
41+
- #[cfg(target_has_atomic_load_store = "128")]
42+
- pub extern "C" fn __llvm_memset_element_unordered_atomic_16(s: *mut u128, c: u8, bytes: usize) -> () {
43+
- memset_element_unordered_atomic(s, c, bytes);
44+
- }
45+
}
46+
--
47+
2.26.2.7.g19db9cfb68
48+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
From 894e07dfec2624ba539129b1c1d63e1d7d812bda Mon Sep 17 00:00:00 2001
2+
From: bjorn3 <[email protected]>
3+
Date: Thu, 18 Feb 2021 18:45:28 +0100
4+
Subject: [PATCH] Disable 128bit atomic operations
5+
6+
Cranelift doesn't support them yet
7+
---
8+
library/core/src/sync/atomic.rs | 38 ---------------------------------
9+
library/core/tests/atomic.rs | 4 ----
10+
library/std/src/panic.rs | 6 ------
11+
3 files changed, 48 deletions(-)
12+
13+
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
14+
index 81c9e1d..65c9503 100644
15+
--- a/library/core/src/sync/atomic.rs
16+
+++ b/library/core/src/sync/atomic.rs
17+
@@ -2228,44 +2228,6 @@ atomic_int! {
18+
"AtomicU64::new(0)",
19+
u64 AtomicU64 ATOMIC_U64_INIT
20+
}
21+
-#[cfg(target_has_atomic_load_store = "128")]
22+
-atomic_int! {
23+
- cfg(target_has_atomic = "128"),
24+
- cfg(target_has_atomic_equal_alignment = "128"),
25+
- unstable(feature = "integer_atomics", issue = "32976"),
26+
- unstable(feature = "integer_atomics", issue = "32976"),
27+
- unstable(feature = "integer_atomics", issue = "32976"),
28+
- unstable(feature = "integer_atomics", issue = "32976"),
29+
- unstable(feature = "integer_atomics", issue = "32976"),
30+
- unstable(feature = "integer_atomics", issue = "32976"),
31+
- rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
32+
- unstable(feature = "integer_atomics", issue = "32976"),
33+
- "i128", "../../../std/primitive.i128.html",
34+
- "#![feature(integer_atomics)]\n\n",
35+
- atomic_min, atomic_max,
36+
- 16,
37+
- "AtomicI128::new(0)",
38+
- i128 AtomicI128 ATOMIC_I128_INIT
39+
-}
40+
-#[cfg(target_has_atomic_load_store = "128")]
41+
-atomic_int! {
42+
- cfg(target_has_atomic = "128"),
43+
- cfg(target_has_atomic_equal_alignment = "128"),
44+
- unstable(feature = "integer_atomics", issue = "32976"),
45+
- unstable(feature = "integer_atomics", issue = "32976"),
46+
- unstable(feature = "integer_atomics", issue = "32976"),
47+
- unstable(feature = "integer_atomics", issue = "32976"),
48+
- unstable(feature = "integer_atomics", issue = "32976"),
49+
- unstable(feature = "integer_atomics", issue = "32976"),
50+
- rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
51+
- unstable(feature = "integer_atomics", issue = "32976"),
52+
- "u128", "../../../std/primitive.u128.html",
53+
- "#![feature(integer_atomics)]\n\n",
54+
- atomic_umin, atomic_umax,
55+
- 16,
56+
- "AtomicU128::new(0)",
57+
- u128 AtomicU128 ATOMIC_U128_INIT
58+
-}
59+
60+
macro_rules! atomic_int_ptr_sized {
61+
( $($target_pointer_width:literal $align:literal)* ) => { $(
62+
diff --git a/library/core/tests/atomic.rs b/library/core/tests/atomic.rs
63+
index 2d1e449..cb6da5d 100644
64+
--- a/library/core/tests/atomic.rs
65+
+++ b/library/core/tests/atomic.rs
66+
@@ -145,10 +145,6 @@ fn atomic_alignment() {
67+
assert_eq!(align_of::<AtomicU64>(), size_of::<AtomicU64>());
68+
#[cfg(target_has_atomic = "64")]
69+
assert_eq!(align_of::<AtomicI64>(), size_of::<AtomicI64>());
70+
- #[cfg(target_has_atomic = "128")]
71+
- assert_eq!(align_of::<AtomicU128>(), size_of::<AtomicU128>());
72+
- #[cfg(target_has_atomic = "128")]
73+
- assert_eq!(align_of::<AtomicI128>(), size_of::<AtomicI128>());
74+
#[cfg(target_has_atomic = "ptr")]
75+
assert_eq!(align_of::<AtomicUsize>(), size_of::<AtomicUsize>());
76+
#[cfg(target_has_atomic = "ptr")]
77+
diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs
78+
index 89a822a..779fd88 100644
79+
--- a/library/std/src/panic.rs
80+
+++ b/library/std/src/panic.rs
81+
@@ -279,9 +279,6 @@ impl RefUnwindSafe for atomic::AtomicI32 {}
82+
#[cfg(target_has_atomic_load_store = "64")]
83+
#[stable(feature = "integer_atomics_stable", since = "1.34.0")]
84+
impl RefUnwindSafe for atomic::AtomicI64 {}
85+
-#[cfg(target_has_atomic_load_store = "128")]
86+
-#[unstable(feature = "integer_atomics", issue = "32976")]
87+
-impl RefUnwindSafe for atomic::AtomicI128 {}
88+
89+
#[cfg(target_has_atomic_load_store = "ptr")]
90+
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
91+
@@ -298,9 +295,6 @@ impl RefUnwindSafe for atomic::AtomicU32 {}
92+
#[cfg(target_has_atomic_load_store = "64")]
93+
#[stable(feature = "integer_atomics_stable", since = "1.34.0")]
94+
impl RefUnwindSafe for atomic::AtomicU64 {}
95+
-#[cfg(target_has_atomic_load_store = "128")]
96+
-#[unstable(feature = "integer_atomics", issue = "32976")]
97+
-impl RefUnwindSafe for atomic::AtomicU128 {}
98+
99+
#[cfg(target_has_atomic_load_store = "8")]
100+
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
101+
--
102+
2.26.2.7.g19db9cfb68
103+

0 commit comments

Comments
 (0)