Skip to content

Instantly share code, notes, and snippets.

@dmilith
Last active August 29, 2015 14:15
Show Gist options
  • Save dmilith/39dee6a9cad87ab6f07c to your computer and use it in GitHub Desktop.
Save dmilith/39dee6a9cad87ab6f07c to your computer and use it in GitHub Desktop.
Linking issue with GHC (platform independent issue)
# I did GHC 7.8.4 build with my custom prefix set to /Software/Ghc
# Everything looks good after GHC build:
⇒ ldd /Software/Ghc/lib/ghc-7.8.4/bin/ghc
/Software/Ghc/lib/ghc-7.8.4/bin/ghc:
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/Software/Ghc/lib/libgmp.10.dylib (compatibility version 12.0.0, current version 12.3.0)
@rpath/libHShaskeline-0.7.1.2-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSterminfo-0.4.0.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSghc-7.8.4-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHStransformers-0.3.0.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHStemplate-haskell-2.9.0.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHShpc-0.6.0.1-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHShoopl-3.10.0.1-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSbin-package-db-0.0.0.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSbinary-0.7.1.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSCabal-1.18.1.5-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSprocess-1.2.0.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSpretty-1.1.1.1-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHScontainers-0.5.5.1-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSdirectory-1.2.1.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSunix-2.7.0.1-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHStime-1.4.2-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSold-locale-1.0.0.6-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSfilepath-1.3.0.2-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSbytestring-0.10.4.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSdeepseq-1.3.0.2-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSarray-0.5.0.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSbase-4.7.0.2-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSinteger-gmp-0.5.1.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSghc-prim-0.3.1.0-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSrts_thr-ghc7.8.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libffi.dylib (compatibility version 7.0.0, current version 7.0.0)
# The thing is, that I can't build relocatable (independent code) with Ghc cause it hardcodes library prefix
# into binary on each build (link):
⇒ ghc Core
[1 of 2] Compiling Utils ( Utils.hs, Utils.o )
[2 of 2] Compiling Main ( Core.hs, Core.o )
Linking Core ...
# and here's the thing:
⇒ otool -L ./Core
./Core:
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/Software/Ghc/lib/libgmp.10.dylib (compatibility version 12.0.0, current version 12.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
# Every code compiled with that Ghc will produce binary with dependency on library from
# Ghc prefix (/Software/Ghc/lib/libgmp.10.dylib in this case) which
# wont exist on other machines with same architecture (without my Ghc build),
# hence I would need to rebuild my code for each machine, which is a PITA.
# This example most likely applies to all platforms supported by Ghc (confirmed under FreeBSD 10.1 and OSX 10.10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment