Skip to content

Commit c193113

Browse files
committed
Don't test mangled names on thumb
We are both the "real compiler-rt" and the "to be tested one".
1 parent 5c74fb1 commit c193113

File tree

5 files changed

+27
-30
lines changed

5 files changed

+27
-30
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ compiler-builtins = []
1818
default = ["compiler-builtins"]
1919
mem = []
2020
rustbuild = ["compiler-builtins"]
21+
mangled-names = []
2122

2223
# generate tests
2324
#

ci/run.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ case $1 in
5151
done
5252
;;
5353
*)
54-
cargo test --no-default-features --features gen-tests --target $1
55-
cargo test --no-default-features --features 'gen-tests c' --target $1
56-
cargo test --no-default-features --features gen-tests --target $1 --release
57-
cargo test --no-default-features --features 'gen-tests c' --target $1 --release
54+
run="cargo test --no-default-features --target $1"
55+
$run --features 'gen-tests mangled-names'
56+
$run --features 'gen-tests mangled-names' --release
57+
$run --features 'gen-tests mangled-names c'
58+
$run --features 'gen-tests mangled-names c' --release
5859
;;
5960
esac
6061

src/arm.rs

+16-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#[cfg(not(feature = "gen-tests"))]
21
use core::intrinsics;
32

43
#[cfg(feature = "mem")]
@@ -7,8 +6,7 @@ use mem::{memcpy, memmove, memset};
76
// NOTE This function and the ones below are implemented using assembly because they using a custom
87
// calling convention which can't be implemented using a normal Rust function
98
#[naked]
10-
#[cfg_attr(not(test), no_mangle)]
11-
#[cfg(not(feature = "gen-tests"))]
9+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
1210
pub unsafe fn __aeabi_uidivmod() {
1311
asm!("push {lr}
1412
sub sp, sp, #4
@@ -21,8 +19,7 @@ pub unsafe fn __aeabi_uidivmod() {
2119
}
2220

2321
#[naked]
24-
#[cfg_attr(not(test), no_mangle)]
25-
#[cfg(not(feature = "gen-tests"))]
22+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
2623
pub unsafe fn __aeabi_uldivmod() {
2724
asm!("push {r4, lr}
2825
sub sp, sp, #16
@@ -37,8 +34,7 @@ pub unsafe fn __aeabi_uldivmod() {
3734
}
3835

3936
#[naked]
40-
#[cfg_attr(not(test), no_mangle)]
41-
#[cfg(not(feature = "gen-tests"))]
37+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
4238
pub unsafe fn __aeabi_idivmod() {
4339
asm!("push {r0, r1, r4, lr}
4440
bl __divsi3
@@ -50,8 +46,7 @@ pub unsafe fn __aeabi_idivmod() {
5046
}
5147

5248
#[naked]
53-
#[cfg_attr(not(test), no_mangle)]
54-
#[cfg(not(feature = "gen-tests"))]
49+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
5550
pub unsafe fn __aeabi_ldivmod() {
5651
asm!("push {r4, lr}
5752
sub sp, sp, #16
@@ -75,55 +70,55 @@ extern "C" {
7570

7671
// FIXME: The `*4` and `*8` variants should be defined as aliases.
7772

78-
#[cfg_attr(not(test), no_mangle)]
73+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
7974
pub unsafe extern "aapcs" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) {
8075
memcpy(dest, src, n);
8176
}
82-
#[cfg_attr(not(test), no_mangle)]
77+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
8378
pub unsafe extern "aapcs" fn __aeabi_memcpy4(dest: *mut u8, src: *const u8, n: usize) {
8479
memcpy(dest, src, n);
8580
}
86-
#[cfg_attr(not(test), no_mangle)]
81+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
8782
pub unsafe extern "aapcs" fn __aeabi_memcpy8(dest: *mut u8, src: *const u8, n: usize) {
8883
memcpy(dest, src, n);
8984
}
9085

91-
#[cfg_attr(not(test), no_mangle)]
86+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
9287
pub unsafe extern "aapcs" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize) {
9388
memmove(dest, src, n);
9489
}
95-
#[cfg_attr(not(test), no_mangle)]
90+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
9691
pub unsafe extern "aapcs" fn __aeabi_memmove4(dest: *mut u8, src: *const u8, n: usize) {
9792
memmove(dest, src, n);
9893
}
99-
#[cfg_attr(not(test), no_mangle)]
94+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
10095
pub unsafe extern "aapcs" fn __aeabi_memmove8(dest: *mut u8, src: *const u8, n: usize) {
10196
memmove(dest, src, n);
10297
}
10398

10499
// Note the different argument order
105-
#[cfg_attr(not(test), no_mangle)]
100+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
106101
pub unsafe extern "aapcs" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) {
107102
memset(dest, c, n);
108103
}
109-
#[cfg_attr(not(test), no_mangle)]
104+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
110105
pub unsafe extern "aapcs" fn __aeabi_memset4(dest: *mut u8, n: usize, c: i32) {
111106
memset(dest, c, n);
112107
}
113-
#[cfg_attr(not(test), no_mangle)]
108+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
114109
pub unsafe extern "aapcs" fn __aeabi_memset8(dest: *mut u8, n: usize, c: i32) {
115110
memset(dest, c, n);
116111
}
117112

118-
#[cfg_attr(not(test), no_mangle)]
113+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
119114
pub unsafe extern "aapcs" fn __aeabi_memclr(dest: *mut u8, n: usize) {
120115
memset(dest, 0, n);
121116
}
122-
#[cfg_attr(not(test), no_mangle)]
117+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
123118
pub unsafe extern "aapcs" fn __aeabi_memclr4(dest: *mut u8, n: usize) {
124119
memset(dest, 0, n);
125120
}
126-
#[cfg_attr(not(test), no_mangle)]
121+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
127122
pub unsafe extern "aapcs" fn __aeabi_memclr8(dest: *mut u8, n: usize) {
128123
memset(dest, 0, n);
129124
}

src/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ macro_rules! intrinsics {
253253
$($rest:tt)*
254254
) => (
255255
$(#[$($attr)*])*
256-
#[cfg_attr(not(feature = "gen-tests"), no_mangle)]
256+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
257257
pub extern $abi fn $name( $($argname: $ty),* ) -> $ret {
258258
$($body)*
259259
}

src/mem.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type c_int = i16;
55
#[cfg(not(target_pointer_width = "16"))]
66
type c_int = i32;
77

8-
#[no_mangle]
8+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
99
pub unsafe extern "C" fn memcpy(dest: *mut u8,
1010
src: *const u8,
1111
n: usize)
@@ -18,7 +18,7 @@ pub unsafe extern "C" fn memcpy(dest: *mut u8,
1818
dest
1919
}
2020

21-
#[no_mangle]
21+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
2222
pub unsafe extern "C" fn memmove(dest: *mut u8,
2323
src: *const u8,
2424
n: usize)
@@ -41,7 +41,7 @@ pub unsafe extern "C" fn memmove(dest: *mut u8,
4141
dest
4242
}
4343

44-
#[no_mangle]
44+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
4545
pub unsafe extern "C" fn memset(s: *mut u8, c: c_int, n: usize) -> *mut u8 {
4646
let mut i = 0;
4747
while i < n {
@@ -51,7 +51,7 @@ pub unsafe extern "C" fn memset(s: *mut u8, c: c_int, n: usize) -> *mut u8 {
5151
s
5252
}
5353

54-
#[no_mangle]
54+
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
5555
pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
5656
let mut i = 0;
5757
while i < n {

0 commit comments

Comments
 (0)