gmp-mpfr-sys fails to build on macOS catalina 10.15.6

549 Views Asked by At

I am on macOS catalina 10.15.6. I am trying to use the rug crate in rust, particularly, the float library that uses MPFR. I am unable to compile the code due to a segmentation fault. The exact error and a small example program are below. Does anyone know if there is a way to fix this problem?

A small program using rug::Float

use rug::Float;                                                                 
                                                                                
fn main() {                                                                                                                        
        let valid = Float::parse("12.25e-4");                                   
        println!("{}", Float::with_val(32, valid.unwrap()));                    
}      

When I try to run it using cargo run, the build for gmp-mpfr-sys has a segmentation fault. I see this:

libtool: warning: assuming '-no-fast-install' instead
../../../gmp-src/test-driver: line 107:  4825 Segmentation fault: 11  "$@" > $log_file 2>&1
make[5]: *** [test-suite.log] Error 1
make[4]: *** [check-TESTS] Error 2
make[3]: *** [check-am] Error 2
make[2]: *** [check-recursive] Error 1
make[1]: *** [check-recursive] Error 1
make: *** [check] Error 2
thread 'main' panicked at 'Program failed with code 2: "make" "-j" "8" "check"', /Users/sample/.cargo/registry/src/github.com-1ecc6299db9ec823/gmp-mpfr-sys-1.4.0/build.rs:1146:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1

There are 1 best solutions below

0
On

The fix that worked for me was to use gmp-mpfr-sys = { version = "1.4.1", features=["use-system-libs"] } in Cargo.toml. You can see the discussion I had with the developers here: https://gitlab.com/tspiteri/rug/-/issues/23