Self-Bootstrap of 9.4.2 Fails on macOS with missing symbol _iconv_open
Summary
I'm self-bootstrapping ghc 9.4.2 using hadrian for deployment on MacPorts.
Running hadrian -f binary-dist
throws this error:
:info:build Command line: /opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/bootstrap/opt/local/bin/ghc -Wall -Wcompat -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-env -' '-package-db _build/stage0/lib/package.conf.d' '-package-id array-0.5.4.0' '-package-id base-4.17.0.0' '-package-id bytestring-0.11.3.1' '-package-id containers-0.6.6' '-package-id directory-1.3.7.1' '-package-id filepath-1.4.2.2' '-package-id ghc-9.4.2' '-package-id ghc-boot-9.4.2' '-package-id process-1.6.15.0' '-package-id transformers-0.5.6.2' '-package-id unix-2.7.3' -i -i/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/src/ghc-9.4.2/_build/stage0/ghc/build -i/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/src/ghc-9.4.2/_build/stage0/ghc/build/ghc/autogen -i/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/src/ghc-9.4.2/ghc -I_build/stage0/ghc/build -I/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/src/ghc-9.4.2/_build/stage0/lib/x86_64-osx-ghc-9.4.2/process-1.6.15.0/include -I/opt/local/include -I/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/src/ghc-9.4.2/_build/stage0/lib/x86_64-osx-ghc-9.4.2/unix-2.7.3/include -I/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/src/ghc-9.4.2/_build/stage0/lib/x86_64-osx-ghc-9.4.2/time-1.12.2/include -I/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/src/ghc-9.4.2/_build/stage0/lib/x86_64-osx-ghc-9.4.2/bytestring-0.11.3.1/include -I/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/bootstrap/opt/local/lib/ghc-9.4.2/lib/x86_64-osx-ghc-9.4.2/base-4.17.0.0/include -I/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/bootstrap/opt/local/lib/ghc-9.4.2/lib/x86_64-osx-ghc-9.4.2/ghc-bignum-1.3/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi -I/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/bootstrap/opt/local/lib/ghc-9.4.2/lib/x86_64-osx-ghc-9.4.2/rts-1.0.2/include -optP-include -optP_build/stage0/ghc/build/ghc/autogen/cabal_macros.h -optc--target=x86_64-apple-darwin -outputdir _build/stage0/ghc/build -no-auto-link-packages -rtsopts -optc-Wno-unknown-pragmas -optP-Wno-nonportable-include-path _build/stage0/ghc/build/Main.o -o _build/stage0/bin/ghc -O -H32m -Wall -Wnoncanonical-monad-instances -Wnoncanonical-monoid-instances -rtsopts=all '-with-rtsopts=-K512M -H -I5 -T' -threaded -XHaskell2010 -XNoImplicitPrelude -XScopedTypeVariables -XBangPatterns -I_build/stage0/compiler/build
:info:build ===> Command failed with error code: 1
:info:build Undefined symbols for architecture x86_64:
:info:build "_iconv_close", referenced from:
:info:build _hs_iconv_close in libHSbase-4.17.0.0.a(iconv.o)
:info:build (maybe you meant: _hs_iconv_close)
:info:build "_iconv", referenced from:
:info:build _hs_iconv in libHSbase-4.17.0.0.a(iconv.o)
…
:info:build (maybe you meant: _hs_iconv_open)
:info:build ld: symbol(s) not found for architecture x86_64
:info:build clang: error: linker command failed with exit code 1 (use -v to see invocation)
:info:build `clang' failed in phase `Linker'. (Exit code: 1)
:info:build Command failed
:info:build Build failed.
I see that the archive file libHSbase-4.17.0.0.a
in the ghc
install uses this undefined symbol:
nm -gC /opt/local/lib/ghc-9.4.2/lib/x86_64-osx-ghc-9.4.2/base-4.17.0.0/libHSbase-4.17.0.0.a | grep iconv_open
0000000000000000 T _hs_iconv_open
U _iconv_open
U _hs_iconv_open
However, macOS 12.5.1 no longer appears to provide a system libiconv:
ls /usr/lib/libiconv*
ls: /usr/lib/libiconv*: No such file or directory
And the port iconv
provides the _libiconv_open
symbol, not the _iconv_open
symbol.
Please advise.
Steps to reproduce
I'm bootstrapping per the documentation here and for hadrian
, essentially:
./boot
autoconf
hadrian -j24 binary-dist
Expected behavior
Working bootstrap of ghc.
Environment
- GHC version used: 9.4.2
macOS 12.5.1 21G83 x86_64 Xcode 13.4.1 13F100