ghc build --with-* libraries causes dyld link error with libc++ and libSystem on macOS 10.15
Summary
Using ghc
's --with-*
configure directives causes a link error in the ghc-stage2
build:
dyld: initializer in image (/usr/lib/libc++.1.dylib) that does not link with libSystem.dylib
We're writing a MacPorts port of ghc
that avoids native iconv
linking issues by linking with MacPorts-installed libiconv
and using the ghc
configure directives,
--with-iconv-includes=${prefix}/include \
--with-iconv-libraries=${prefix}/lib
Observed on these build platforms:
macOS 10.15.6 19G2021 macOS 10.15.7 19H2 Xcode 12.0.1 12A7300
Steps to reproduce
sudo port build ghc
using this Portfile.
The Portfile simply implements ghc's basic quick start build instructions.
Removing the --with-*
configure directives results in a successful build with this linking error.
Logs
Basic error:
./inplace/bin/ghc-stage2
dyld: initializer in image (/usr/lib/libc++.1.dylib) that does not link with libSystem.dylib
Log file:
:info:build "inplace/bin/ghc-stage2" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -H32m -O -Wall -hide-all-packages -i -iutils/check-ppr/. -iutils/check-ppr/dist-install/build -Iutils/check-ppr/dist-install/build -iutils/check-ppr/dist-install/build/check-ppr/autogen -Iutils/check-ppr/dist-install/build/check-ppr/autogen -optP-include -optPutils/check-ppr/dist-install/build/check-ppr/autogen/cabal_macros.h -package-id Cabal-3.2.0.0 -package-id base-4.14.1.0 -package-id bytestring-0.10.10.0 -package-id containers-0.6.2.1 -package-id directory-1.3.6.0 -package-id filepath-1.4.2.1 -package-id ghc-8.10.2 -Wall -XHaskell2010 -no-user-package-db -rtsopts -Wnoncanonical-monad-instances -outputdir utils/check-ppr/dist-install/build -c utils/check-ppr/./Main.hs -o utils/check-ppr/dist-install/build/Main.dyn_o
:info:build dyld: initializer in image (/usr/lib/libc++.1.dylib) that does not link with libSystem.dylib
:info:build make[1]: *** [utils/haddock/dist/build/Haddock/Backends/HaddockDB.dyn_o] Abort trap: 6
…
:info:build make: *** [all] Error 2
:info:build Command failed: export PATH=/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/bootstrap/bin:/opt/local/Library/Frameworks/Python.framework/Versions/3.8/bin CC=/usr/bin/clang CXX=/usr/bin/clang++; /usr/bin/make -j12
Expected behavior
Successful build.
Environment
- GHC version used: 10.8.2
Optional:
- Operating System: macOS 10.15
See: