@@ -41,24 +41,23 @@ fn windows_msvc_system() {
41
41
}
42
42
}
43
43
44
- /// homebrew says
45
- ///
46
- /// > openblas is keg-only, which means it was not symlinked into /usr/local,
47
- /// > because macOS provides BLAS in Accelerate.framework.
48
- /// > For compilers to find openblas you may need to set:
49
- ///
50
- /// ```text
51
- /// export LDFLAGS="-L/usr/local/opt/openblas/lib"
52
- /// export CPPFLAGS="-I/usr/local/opt/openblas/include"
53
- /// ```
44
+ /// Add linker flag (`-L`) to path where brew installs OpenBLAS
54
45
fn macos_system ( ) {
55
- if cfg ! ( target_arch = "aarch64" ) {
56
- println ! ( "cargo:rustc-link-search=/opt/homebrew/opt/openblas/lib" ) ;
57
- println ! ( "cargo:rustc-link-search=/opt/homebrew/opt/libomp/lib" ) ;
58
- } else {
59
- println ! ( "cargo:rustc-link-search=/usr/local/homebrew/opt/openblas/lib" ) ;
60
- println ! ( "cargo:rustc-link-search=/usr/local/homebrew/opt/libomp/lib" ) ;
46
+ fn brew_prefix ( target : & str ) -> PathBuf {
47
+ let out = Command :: new ( "brew" )
48
+ . arg ( "--prefix" )
49
+ . arg ( target)
50
+ . output ( )
51
+ . expect ( "brew not installed" ) ;
52
+ assert ! ( out. status. success( ) , "`brew --prefix` failed" ) ;
53
+ let path = String :: from_utf8 ( out. stdout ) . expect ( "Non-UTF8 path by `brew --prefix`" ) ;
54
+ PathBuf :: from ( path. trim ( ) )
61
55
}
56
+ let openblas = brew_prefix ( "openblas" ) ;
57
+ let libomp = brew_prefix ( "libomp" ) ;
58
+
59
+ println ! ( "cargo:rustc-link-search={}/lib" , openblas. display( ) ) ;
60
+ println ! ( "cargo:rustc-link-search={}/lib" , libomp. display( ) ) ;
62
61
}
63
62
64
63
fn main ( ) {
0 commit comments