diff --git a/build.rs b/build.rs index 3ac94eb..9eccb59 100644 --- a/build.rs +++ b/build.rs @@ -209,6 +209,14 @@ fn build(target_os: &str) -> io::Result<()> { // The cc crate has the messy logic of guessing a working prefix, // and this is a messy way of reusing that logic. let cc = cc::Build::new(); + + // Apple-clang needs this, -arch is not enough. + let target_flag = format!("--target={}", target); + if cc.is_flag_supported(&target_flag).unwrap_or(false) { + configure.arg(format!("--extra-cflags={}", target_flag)); + configure.arg(format!("--extra-ldflags={}", target_flag)); + } + let compiler = cc.get_compiler(); let compiler = compiler.path().file_stem().unwrap().to_str().unwrap(); if let Some(suffix_pos) = compiler.rfind('-') { @@ -340,6 +348,8 @@ fn build(target_os: &str) -> io::Result<()> { // configure misc build options enable!(configure, "BUILD_PIC", "pic"); + println!("configure cmd: {:?}", configure); + // run ./configure let output = configure .output()