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

make static on macOS does not compile a true static binary #208

Open
daniellivingston opened this issue Aug 13, 2020 · 1 comment
Open

Comments

@daniellivingston
Copy link
Member

daniellivingston commented Aug 13, 2020

Compiling with make static leaves libquadmath still dynamically linked:

$ make static
$ otool -L lagrit
lagrit:
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
        /usr/local/opt/gcc/lib/gcc/10/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)

This is a problem for binary portability.


On macOS, static linking is really hard:

It appears that the Mac OS X linker is hard-wired to search dynamic libraries before static ones...Note that you cannot pass a file extension to the -l switch (-lantlr3c.a) to force the static library to be used. One way to force the static library to be used is to simply remove the dynamic version.

A way I have compiled static libraries in the past is to do something like:

$ sudo mv /usr/local/opt/gcc/lib/gcc/10/libquadmath.0.dylib \
          /usr/local/opt/gcc/lib/gcc/10/tmp_libquadmath.0.dylib
$ make static
$ sudo mv /usr/local/opt/gcc/lib/gcc/10/tmp_libquadmath.0.dylib \
          /usr/local/opt/gcc/lib/gcc/10/libquadmath.0.dylib

That works but is not a good general solution. Currently trying to solve this in the branch mac-os-fix. https://github.com/lanl/LaGriT/tree/macos-static-fix

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

1 participant