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

compile error on ARM Mac #12

Closed
boccio-john opened this issue Dec 2, 2020 · 11 comments
Closed

compile error on ARM Mac #12

boccio-john opened this issue Dec 2, 2020 · 11 comments

Comments

@boccio-john
Copy link

Fortran 90 code - compile works with gfortran 10.2 on intel Mac.
However, when I try to do same compile using gfortran 11.0 on ARM Mac (installed using simple package over 10.2 version),
it fails with message:

ld:library not found for -lm
collect2: error: ld returned 1 exit value

compile command is:

/usr/local/gfortran/bin/gfortran treecode.f90 treegrav.f90 treeio.f90 treeload.f90 -o treecode

@fxcoudert
Copy link
Owner

Do you have the command-line tools installed (with xcode-select --install)?

@boccio-john
Copy link
Author

boccio-john commented Dec 2, 2020 via email

@martin-frbg
Copy link

Quoting isuruf from OpenMathLib/OpenBLAS#3032 (comment)

It looks like gfortran was compiled with /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk and gfortran saves this location into its binary. You have /Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk which becomes a problem.
A workaround is to do export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk

and that suggestion later refined to
export MACOSX_DEPLOYMENT_TARGET=11.0

@boccio-john
Copy link
Author

Thanks. That worked. I am a physicist compiling fortran 90 code to do galaxy-galaxy collisions. I am not a UNIX expert at all. I just issued the export command in the terminal window before I ran the compile operation. Is there somewhere I should enter the export command so that is always active? Thanks for any help. By the way it is running extremely fast on the MacBook Air M1 system.

@sholmas
Copy link

sholmas commented Dec 18, 2020

macOS 11.1 is now available to all users, it solved this issue for me after reinstalling the command line tools (using xcode-select --install).

@boccio-john
Copy link
Author

boccio-john commented Dec 18, 2020 via email

@fxcoudert
Copy link
Owner

macOS 11.1 and the command-line tools 12.3 fix this issue. I will try to make my next build more robust.

@iains
Copy link

iains commented Mar 20, 2021

This issue was referenced in a discussion of static linking:

  • we should also fix libgfortran's spec to omit "-lm" which has not been needed on macOS "forever" and
  • put a translation spec in for libquadmath to be static for static-libgfortran.

e.g
*lib: %{!static-libgfortran: -lquadmath } %{static-libgfortran: libquadmath.a%s} %(libgcc) %(liborig)

@beausoleilmo
Copy link

beausoleilmo commented Mar 26, 2021

About lquadmath, when trying to install RcppArmadillo in R, I get this message:

ld: library not found for -lquadmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [RcppArmadillo.so] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo’

I already modified the line in Makeconf
FLIBS = -L/usr/local/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
(see here https://stackoverflow.com/questions/23916219/os-x-package-installation-depends-on-gfortran-4-8)

to specify the "proper" location of the gcc, but lquadmath seems it's not working at all. Do you have a quick workaround?

@iains
Copy link

iains commented Mar 26, 2021

for Arm64, there is no libquadmath - theres no REAL*16 equivalent on the platform at present. This means that we need a configure change to omit the "-lquadmath" from the spec.

You should be able to hack around it in the short-term by editing /path/to/compiler/lib/libgfortran.spec and removing the "-lquadmath" from the last line.

@iains
Copy link

iains commented Mar 28, 2021

(for Arm64 on Darwin)

  • the size of long double is set to 64 bits, since that's what the current platform ABI supports.
  • The configuration for libgfortran checks for the availability of __float128 before enabling libquadmath.
  • I took a scan through the aarch64 backend and can't see anywhere where that's explicitly enabled - so somehow either the libgfortran configuration is failing to detect that the type is not available, or the compiler is publishing its availability when that isn't really true.
  • A workaround would be to configure with --disable-libquadmath-support , I guess

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

6 participants