about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/compiler-builtins/libm/Cargo.toml14
-rw-r--r--library/compiler-builtins/libm/build.rs8
-rwxr-xr-xlibrary/compiler-builtins/libm/ci/run.sh12
3 files changed, 21 insertions, 13 deletions
diff --git a/library/compiler-builtins/libm/Cargo.toml b/library/compiler-builtins/libm/Cargo.toml
index 7b6f9e1cecb..08342a92929 100644
--- a/library/compiler-builtins/libm/Cargo.toml
+++ b/library/compiler-builtins/libm/Cargo.toml
@@ -61,18 +61,20 @@ exclude = [
 [dev-dependencies]
 no-panic = "0.1.33"
 
-[profile.release]
-# Options for no-panic to correctly detect the lack of panics
-codegen-units = 1
-lto = "fat"
+# The default release profile is unchanged.
 
 # Release mode with debug assertions
 [profile.release-checked]
-codegen-units = 1
+inherits = "release"
 debug-assertions = true
+overflow-checks = true
+
+# Release with maximum optimizations, which is very slow to build. This is also
+# what is needed to check `no-panic`.
+[profile.release-opt]
 inherits = "release"
+codegen-units = 1
 lto = "fat"
-overflow-checks = true
 
 [profile.bench]
 # Required for iai-callgrind
diff --git a/library/compiler-builtins/libm/build.rs b/library/compiler-builtins/libm/build.rs
index caf5a108a26..7042b54d7e8 100644
--- a/library/compiler-builtins/libm/build.rs
+++ b/library/compiler-builtins/libm/build.rs
@@ -8,13 +8,9 @@ fn main() {
     println!("cargo:rerun-if-changed=build.rs");
     println!("cargo:rustc-check-cfg=cfg(assert_no_panic)");
 
-    let lvl = env::var("OPT_LEVEL").unwrap();
-    if lvl != "0" && !cfg!(debug_assertions) {
+    // If set, enable `no-panic`. Requires LTO (`release-opt` profile).
+    if env::var("ENSURE_NO_PANIC").is_ok() {
         println!("cargo:rustc-cfg=assert_no_panic");
-    } else if env::var("ENSURE_NO_PANIC").is_ok() {
-        // Give us a defensive way of ensureing that no-panic is checked  when we
-        // expect it to be.
-        panic!("`assert_no_panic `was not enabled");
     }
 
     configure::emit_libm_config(&cfg);
diff --git a/library/compiler-builtins/libm/ci/run.sh b/library/compiler-builtins/libm/ci/run.sh
index 296986d9727..a946d325ebd 100755
--- a/library/compiler-builtins/libm/ci/run.sh
+++ b/library/compiler-builtins/libm/ci/run.sh
@@ -117,4 +117,14 @@ $cmd "$profile" release-checked --features unstable-intrinsics
 $cmd "$profile" release-checked --features unstable-intrinsics --benches
 
 # Ensure that the routines do not panic.
-ENSURE_NO_PANIC=1 cargo build -p libm --target "$target" --no-default-features --release
+# 
+# `--tests` must be passed because no-panic is only enabled as a dev
+# dependency. The `release-opt` profile must be used to enable LTO and a
+# single CGU.
+ENSURE_NO_PANIC=1 cargo build \
+     -p libm \
+    --target "$target" \
+    --no-default-features \
+    --features unstable-float \
+    --tests \
+    --profile release-opt