Kaynağa Gözat

Use `nm` to weed out panics

Alex Crichton 7 yıl önce
ebeveyn
işleme
a16ebb0dcb
3 değiştirilmiş dosya ile 16 ekleme ve 3 silme
  1. 12 1
      ci/run.sh
  2. 2 0
      src/float/conv.rs
  3. 2 2
      src/int/mul.rs

+ 12 - 1
ci/run.sh

@@ -63,7 +63,6 @@ case $1 in
         ;;
 esac
 
-# Look out for duplicated symbols when we include the compiler-rt (C) implementation
 PREFIX=$(echo $1 | sed -e 's/unknown-//')-
 case $1 in
     armv7-*)
@@ -95,6 +94,7 @@ else
     path=/target/${1}/debug/deps/libcompiler_builtins-*.rlib
 fi
 
+# Look out for duplicated symbols when we include the compiler-rt (C) implementation
 for rlib in $(echo $path); do
     set +x
     stdout=$($PREFIX$NM -g --defined-only $rlib 2>&1)
@@ -109,4 +109,15 @@ for rlib in $(echo $path); do
     set -ex
 done
 
+# Ensure no references to a panicking function
+for rlib in $(echo $path); do
+    set +x
+    $PREFIX$NM -u $rlib 2>&1 | grep panicking
+
+    if test $? = 0; then
+        exit 1
+    fi
+    set -ex
+done
+
 true

+ 2 - 0
src/float/conv.rs

@@ -78,6 +78,7 @@ intrinsics! {
         int_to_float!(i, i32, f64)
     }
 
+    #[use_c_shim_if(any(target_arch = "x86", target_arch = "x86_64"))]
     pub extern "C" fn __floatdidf(i: i64) -> f64 {
         int_to_float!(i, i64, f64)
     }
@@ -100,6 +101,7 @@ intrinsics! {
         int_to_float!(i, u32, f64)
     }
 
+    #[use_c_shim_if(any(target_arch = "x86", target_arch = "x86_64"))]
     pub extern "C" fn __floatundidf(i: u64) -> f64 {
         int_to_float!(i, u64, f64)
     }

+ 2 - 2
src/int/mul.rs

@@ -54,11 +54,11 @@ trait Mulo: Int + ops::Neg<Output = Self> {
             return result;
         }
         if sa == sb {
-            if abs_a > Self::max_value() / abs_b {
+            if abs_a > Self::max_value().checked_div(abs_b).unwrap_or_else(|| ::abort()) {
                 *overflow = 1;
             }
         } else {
-            if abs_a > Self::min_value() / -abs_b {
+            if abs_a > Self::min_value().checked_div(-abs_b).unwrap_or_else(|| ::abort()) {
                 *overflow = 1;
             }
         }