From 390e87bc24e0ed57e649dd78d0b1556c2b2cbc8d Mon Sep 17 00:00:00 2001 From: Kornel Date: Mon, 22 Nov 2021 00:44:08 +0000 Subject: [PATCH] Fix unwrap on compiler names without - --- build.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 68b7510..6167b3e 100644 --- a/build.rs +++ b/build.rs @@ -205,10 +205,12 @@ fn build() -> io::Result<()> { let cc = cc::Build::new(); let compiler = cc.get_compiler(); let compiler = compiler.path().file_stem().unwrap().to_str().unwrap(); - let suffix_pos = compiler.rfind('-').unwrap(); // cut off "-gcc" - let prefix = compiler[0..suffix_pos].trim_end_matches("-wr"); // "wr-c++" compiler + if let Some(suffix_pos) = compiler.rfind('-') { + // cut off "-gcc" + let prefix = compiler[0..suffix_pos].trim_end_matches("-wr"); // "wr-c++" compiler + configure.arg(format!("--cross-prefix={}-", prefix)); + } - configure.arg(format!("--cross-prefix={}-", prefix)); configure.arg(format!( "--arch={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap()