From a2dc57562dd459dca0edaf539acca610bc4807d8 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Wed, 2 Jun 2021 11:27:13 -0400 Subject: [PATCH] Don't panic if autocfg probe fails Motivation: [autocfg panics when building with `-Zbuild-std`][1]. Instead of panicking when the `i128` feature is requested but `probe_type("i128")` fails, just go ahead and enable the feature. If `i128` truly isn't available then compilation will still fail, just later on. This is unlikely to be an issue in practice since [`i128` was stabilized in Rust 1.26.0][2]. Tested by building with: cargo +nightly build --target=x86_64-unknown-uefi \ -Zbuild-std=core,alloc --no-default-features \ --features=i128 [1]: https://github.com/cuviper/autocfg/issues/34 [2]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1260-2018-05-10 --- build.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 997df66..e885975 100644 --- a/build.rs +++ b/build.rs @@ -4,9 +4,7 @@ use std::env; fn main() { let ac = autocfg::new(); - if ac.probe_type("i128") { + if ac.probe_type("i128") || env::var_os("CARGO_FEATURE_I128").is_some() { println!("cargo:rustc-cfg=has_i128"); - } else if env::var_os("CARGO_FEATURE_I128").is_some() { - panic!("i128 support was not detected!"); } -} \ No newline at end of file +}