I'm observing different linking behaviour between two machines when compiling a binary.
Each has the same GHC (7.8.3), same code, same flags (-Wall -O2
), same libgmp (installed by Homebrew on each):
machine-one$ otool -L my-binary
my-binary:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
machine-two$ otool -L my-binary
my-binary:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/local/lib/libgmp.10.dylib (compatibility version 13.0.0, current version 13.0.0)
I can't for the life of me figure out why libgmp
is linked dynamically on the second machine.
In terms of differences I've been able to recognize: GHC has been installed via the binary distribution for OS X on the first machine and Homebrew on the second. For C compilers, we have:
machine-one$ cc --version
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
machine-two$ cc --version
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
What typically determines the linking behaviour, and how can I enforce one linking method or the other?
EDIT: I've observed the same behaviour happening with zlib
on yet another machine, so it's not a GMP-specific issue.
EDIT: I've plucked ghc --info
from each of the machines, here they are for machine one and machine two. And here's the diff between the two as well.
EDIT: I've reinstalled ghc on machine two via the distribution binary, and sure enough libgmp
is not dynamically linked when I recompile my binary. So it seems like this is related to installing GHC via Homebrew.
Still quite interested in what's going on exactly.
libSystem
andlibiconv
. – Magistrate/usr/bin/gcc
while the homebrew version withclang
This discusses installing gcc vs clang https://mcmap.net/q/816722/-using-homebrew-gcc-and-llvm-with-c-11 – Hiltan