Skip to content

Cannot compile 8.10.5 on FreeBSD: "undefined reference to libiconv"

Happens with gmake and hadrian. As a side note: hadrian/ subdir doesn't exist in the generated source tarball, so I had to git clone, which took probably half an hour.

Configure line (as per GHC CI):

./configure --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib

Error:

| Run Ghc CompileHs Stage1: libraries/text/src/Data/Text/Internal/Encoding/Utf32.hs => _build/stage1/libraries/text/build/Data/Text/Internal/Encoding/Utf32.o
ld.lld: error: _build/stage1/lib/../lib/x86_64-freebsd-ghc-8.10.5/libHSbase-4.14.2.0-ghc8.10.5.so: undefined reference to libiconv
ld.lld: error: _build/stage1/lib/../lib/x86_64-freebsd-ghc-8.10.5/libHSbase-4.14.2.0-ghc8.10.5.so: undefined reference to libiconv_close
ld.lld: error: _build/stage1/lib/../lib/x86_64-freebsd-ghc-8.10.5/libHSbase-4.14.2.0-ghc8.10.5.so: undefined reference to libiconv_open
cc: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)
| Run Ghc CompileHs Stage1: libraries/ghc-boot/GHC/Settings.hs => _build/stage1/libraries/ghc-boot/build/GHC/Settings.p_o
ghc: interrupted
Error when running Shake build system:
  at action, called at src/Rules.hs:71:19 in main:Rules
  at need, called at src/Rules.hs:93:5 in main:Rules
* Depends on: _build/stage1/bin/runghc
* Raised the exception:
user error (Development.Shake.cmd, system command failed
Command line: _build/stage0/bin/ghc -Wall -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -hide-all-packages -no-user-package-db '-package-db _build/stage1/lib/package.conf.d' '-package-id base-4.14.2.0' '-package-id directory-1.3.6.0' '-package-id filepath-1.4.2.1' '-package-id process-1.6.9.0' '-package-id unix-2.7.2.2' -i -i_build/stage1/utils/runghc/build -i_build/stage1/utils/runghc/build/runghc/autogen -iutils/runghc/. -Iincludes -I_build/stage1/lib -I_build/stage1/utils/runghc/build -I/usr/local/include -I/usr/local/include -I/home/hasufell/ghc/_build/stage1/lib/x86_64-freebsd-ghc-8.10.5/process-1.6.9.0/include -I/home/hasufell/ghc/_build/stage1/lib/x86_64-freebsd-ghc-8.10.5/unix-2.7.2.2/include -I/home/hasufell/ghc/_build/stage1/lib/x86_64-freebsd-ghc-8.10.5/time-1.9.3/include -I/home/hasufell/ghc/_build/stage1/lib/x86_64-freebsd-ghc-8.10.5/bytestring-0.10.12.0/include -I/usr/local/include -I/home/hasufell/ghc/_build/stage1/lib/x86_64-freebsd-ghc-8.10.5/base-4.14.2.0/include -I/usr/local/include -I/home/hasufell/ghc/_build/stage1/lib/x86_64-freebsd-ghc-8.10.5/integer-gmp-1.0.3.0/include -I/home/hasufell/ghc/_build/stage1/lib/x86_64-freebsd-ghc-8.10.5/rts-1.0.1/include -I_build/stage1/lib -optc-I_build/stage1/lib -optP-include -optP_build/stage1/utils/runghc/build/runghc/autogen/cabal_macros.h -outputdir _build/stage1/utils/runghc/build -dynamic -optl-Wl,-rpath,$ORIGIN/../lib/x86_64-freebsd-ghc-8.10.5 -optl-Wl,-rpath,$ORIGIN/../../../lib/x86_64-freebsd-ghc-8.10.5 -optl-Wl,-zorigin -no-auto-link-packages -rtsopts -Wnoncanonical-monad-instances -optc-Wno-unknown-pragmas _build/stage1/utils/runghc/build/Main.dyn_o -o _build/stage1/bin/runghc -O2 -H32m -XHaskell2010 -ghcversion-file=/home/hasufell/ghc/_build/stage1/lib/ghcversion.h
Exit code: 1
Stderr:
ld.lld: error: _build/stage1/lib/../lib/x86_64-freebsd-ghc-8.10.5/libHSbase-4.14.2.0-ghc8.10.5.so: undefined reference to libiconv
ld.lld: error: _build/stage1/lib/../lib/x86_64-freebsd-ghc-8.10.5/libHSbase-4.14.2.0-ghc8.10.5.so: undefined reference to libiconv_close
ld.lld: error: _build/stage1/lib/../lib/x86_64-freebsd-ghc-8.10.5/libHSbase-4.14.2.0-ghc8.10.5.so: undefined reference to libiconv_open
cc: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)
)

This was confirmed by other FreeBSD users on IRC. However, it seemed that @trac-vdukhovni had a script that allowed him to build, but he got cut off of IRC before he could share more.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information