Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to compile on intel based Mac #315

Open
Ykid opened this issue Jun 22, 2022 · 7 comments
Open

Not able to compile on intel based Mac #315

Ykid opened this issue Jun 22, 2022 · 7 comments

Comments

@Ykid
Copy link

Ykid commented Jun 22, 2022

Issue I have

= note: ld: warning: could not create compact unwind for _chseqr_: stack subq instruction is too different from dwarf stack size
          ld: warning: could not create compact unwind for _dhseqr_: stack subq instruction is too different from dwarf stack size
          ld: warning: could not create compact unwind for _shseqr_: stack subq instruction is too different from dwarf stack size
          ld: warning: could not create compact unwind for _zhseqr_: stack subq instruction is too different from dwarf stack size
          Undefined symbols for architecture x86_64:
            "__gfortran_concat_string", referenced from:
                _dormbr_ in libopenblas_src-4151971bd483fad6.rlib(dormbr.o)
                _dormlq_ in libopenblas_src-4151971bd483fad6.rlib(dormlq.o)
                _dormqr_ in libopenblas_src-4151971bd483fad6.rlib(dormqr.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Code to reproduce this issue

use ndarray::{array, Array, Ix2};
use ndarray_linalg::{LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace};

fn main() {
    let array_a: Array<f64, Ix2> = array![[1.,2.]];
    let array_b: Array<f64, Ix2> = array![[1.,2.]];
    let solution = array_b.least_squares(&array_a).unwrap().solution;
    println!("{:?}", solution);
}

cargo.toml

[package]
name = "example"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ndarray = { version = "0.15.0", features = ["approx", "blas"] }
ndarray-stats = "0.5"
ndarray-linalg = { version = "0.14.1", features = ["openblas-static"] }

just do cargo run will reproduce this issue

Version information

rustup --version
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.63.0-nightly (bb8c2f411 2022-06-19)`

rustc --version
rustc 1.63.0-nightly (bb8c2f411 2022-06-19)

cargo --version
cargo 1.63.0-nightly (8d42b0e87 2022-06-17)

MacOS 12 with Intel Chip

Any help/pointer will be appreciated!

@jturner314-nrl
Copy link

jturner314-nrl commented Jun 23, 2022

Fwiw, I can reproduce this (Intel CPU, macOS 10.15, rustc 1.60.0). Changing openblas-static to openblas-system in the Cargo.toml (to link to the system OpenBLAS instead of building it from source) is a workaround on my system. There are a few known issues with building on MacOS listed at blas-lapack-rs/openblas-src#54, although the specific issues listed there are different.

@martin-frbg
Copy link

maybe related to https://github.com/blas-lapack-rs/openblas-src#20 , as they appear to have been post-processing the generated Makefile.conf to eliminate the libgfortran reference ? (that would work for pure BLAS builds as it is"only" LAPACK that is written in Fortran) Upcoming OpenBLAS 0.3.21 will include copies of the LAPACK sources converted to C

@jianshu93
Copy link

Hello all,

It seems with OpenBLAS 0.3.21, similar error appears when statically linking (dynamic linking is ok) for my intel MacOS (Monterey):

= note: Undefined symbols for architecture x86_64:
"__gfortran_concat_string", referenced from:
sormbr in libopenblas_src-6aab0a1a3b783b73.rlib(sormbr.o)
sormlq in libopenblas_src-6aab0a1a3b783b73.rlib(sormlq.o)
sormqr in libopenblas_src-6aab0a1a3b783b73.rlib(sormqr.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

I tried both to use CC from brew installed gcc and also llvm clang (also brew installed), put /usr/local/bin/CC and /usr/local/bin/cc to link to the brew installed gcc or clang. Neither works.

Hope there is a work around for static link, which is quite useful for me.

Thanks,

Jianshu

@martin-frbg
Copy link

when doing static linking, you will need to link in libgfortran.a - or build OpenBLAS-0.3.21 with the NOFORTRAN option to get f2c-translated versions of the LAPACK functions instead of the original Fortran ones.

@jianshu93
Copy link

Hello,

How exactly can I do that? Since i use v 0.15 from crate.io.

Thanks

Jianshu

@jianshu93
Copy link

jianshu93 commented Sep 12, 2022

This is intel-mkl-static static link error (dynamic link is ok) on intel MacOS:

= note: Undefined symbols for architecture x86_64:
"_cblas_sgemm", referenced from:
__ZN7ndarray6linalg11impl_linalg12mat_mul_impl17h92b8364d9bc0e871E in annembed-61e783314e7c0a52.annembed.5de54790-cgu.9.rcgu.o
"sgelqf", referenced from:
__ZN8annembed5tools9svdapprox5do_qr17h0d0d10466375a1bcE in annembed-61e783314e7c0a52.annembed.5de54790-cgu.9.rcgu.o
"sorglq", referenced from:
__ZN8annembed5tools9svdapprox5do_qr17h0d0d10466375a1bcE in annembed-61e783314e7c0a52.annembed.5de54790-cgu.9.rcgu.o
"sgesdd", referenced from:
ZN42$LT$f32$u20$as$u20$lax..svddc..SVDDC$GT$5svddc17h7a7540c7445de7f6E in annembed-61e783314e7c0a52.annembed.5de54790-cgu.9.rcgu.o
"_cblas_sgemv", referenced from:
__ZN8annembed5tools9svdapprox16MatRepr$LT$F$GT$14mat_dot_vector17h984c90a3c75e92a8E in annembed-61e783314e7c0a52.annembed.5de54790-cgu.9.rcgu.o
"_cblas_sdot", referenced from:
_ZN7ndarray6linalg11impl_linalg110$LT$impl$u20$ndarray..ArrayBase$LT$S$C$ndarray..dimension..dim..Dim$LT$$u5b$usize$u3b$$u20$1$u5d$$GT$$GT$$GT$3dot17h09e278420f5f78ceE in annembed-61e783314e7c0a52.annembed.5de54790-cgu.9.rcgu.o
__ZN8annembed5tools9svdapprox20orthogonalize_with_q17hec15268f252f9042E in annembed-61e783314e7c0a52.annembed.5de54790-cgu.9.rcgu.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

error: could not compile annembed due to previous error

Any idea?

Thanks,

Jianshu

@jianshu93
Copy link

running example with static is ok. The above mentioned error appeared when link to a binary statically for other binary crates.

Jianshu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants