From 530201f895f91c72d08b6e3f1d4a93825e7dc3b7 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 - --- sys/build.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/build.rs b/sys/build.rs index 7e9fe81..011786a 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -203,10 +203,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()