Skip to content

Commit 752e35a

Browse files
committed
Fix duplicate symbol __clzsi2
Looks like our tests weren't quite testing compiler-builtins when it was compiled with unmangled symbols, so update the tests to catch this and then fix the compilation of the `__clzsi2` intrinsic to use the C version if it's compiled.
1 parent 045de6e commit 752e35a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

ci/run.sh

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ else
4242
$run --release
4343
$run --features c
4444
$run --features c --release
45+
cargo build --target $1
46+
cargo build --target $1 --release
47+
cargo build --target $1 --features c
48+
cargo build --target $1 --release --features c
4549
fi
4650

4751
PREFIX=$(echo $1 | sed -e 's/unknown-//')-
@@ -68,6 +72,10 @@ fi
6872
# Look out for duplicated symbols when we include the compiler-rt (C) implementation
6973
for rlib in $(echo $path); do
7074
set +x
75+
echo "================================================================"
76+
echo checking $rlib for duplicate symbols
77+
echo "================================================================"
78+
7179
stdout=$($PREFIX$NM -g --defined-only $rlib 2>&1)
7280

7381
# NOTE On i586, It's normal that the get_pc_thunk symbol appears several
@@ -86,6 +94,7 @@ for rlib in $(echo $path); do
8694
if test $? = 0; then
8795
exit 1
8896
fi
97+
8998
set -ex
9099
done
91100

src/int/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ impl_wide_int!(u32, u64, 32);
302302
impl_wide_int!(u64, u128, 64);
303303

304304
intrinsics! {
305+
#[use_c_shim_if(/* always if C compilation is enabled */)]
305306
#[cfg(any(
306307
target_pointer_width = "16",
307308
target_pointer_width = "32",
@@ -310,7 +311,7 @@ intrinsics! {
310311
pub extern "C" fn __clzsi2(x: usize) -> usize {
311312
// TODO: const this? Would require const-if
312313
// Note(Lokathor): the `intrinsics!` macro can't process mut inputs
313-
let mut x = x;
314+
let mut x = x;
314315
let mut y: usize;
315316
let mut n: usize = {
316317
#[cfg(target_pointer_width = "64")]

0 commit comments

Comments
 (0)