In my cross-platform GHC quest, today I am trying to get GHC up and running on MacOS. The Mac I have access to is running MacOS 10.13.6, which I realize is a bit old, but GHC claims to support back to MacOS 10.7.
For the record, here are all the versions I’m using:
Janes-iMac:~ mignon$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.6
BuildVersion: 17G14033
Janes-iMac:~ mignon$ uname -a
Darwin Janes-iMac.lan 17.7.0 Darwin Kernel Version 17.7.0: Mon Aug 31 22:11:23 PDT 2020; root:xnu-4570.71.82.6~1/RELEASE_X86_64 x86_64
Janes-iMac:~ mignon$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.4.7
Janes-iMac:~ mignon$ cabal --version
cabal-install version 3.10.1.0
compiled using version 3.10.1.0 of the Cabal library
Janes-iMac:~ mignon$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Janes-iMac:~ mignon$ ld -v
@(#)PROGRAM:ld PROJECT:ld64-409.12
BUILD 17:47:51 Sep 25 2018
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 10.0.0, (clang-1000.10.44.4) (static support for 21, runtime is 21)
TAPI support using: Apple TAPI version 10.0.0 (tapi-1000.10.8)
Janes-iMac:~ mignon$
I am able to build a simple “Hello, World!” program, as well as many libraries from Hackage. However, I am unable to build the unix
package:
Starting unix-2.8.2.1 (all, legacy fallback)
Building unix-2.8.2.1 (all, legacy fallback)
Failed to build unix-2.8.2.1.
Build log ( /Users/mignon/.cabal/logs/ghc-9.4.7/nx-2.8.2.1-ab3b6c44.log ):
Configuring unix-2.8.2.1...
configure: WARNING: unrecognized options: --with-compiler
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
[...snip...]
checking for library containing dlopen... none required
checking for library containing sem_close... none required
checking whether sem_getvalue is declared... yes
configure: creating ./config.status
config.status: creating unix.buildinfo
config.status: creating include/HsUnixConfig.h
configure: WARNING: unrecognized options: --with-compiler
Preprocessing library for unix-2.8.2.1..
linking dist/build/System/Posix/Resource_hsc_make.o failed (exit code 1)
rsp file was: "dist/build/System/Posix/hsc2hscall74173-2.rsp"
command was: /usr/bin/gcc dist/build/System/Posix/Resource_hsc_make.o dist/build/System/Posix/Resource_hsc_utils.o -o dist/build/System/Posix/Resource_hsc_make --target=x86_64-apple-darwin -Wl,-no_fixup_chains --target=x86_64-apple-darwin -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/time-1.12.2 -L/Users/mignon/.cabal/store/ghc-9.4.7/flpth-1.4.100.4-db0bbe6a/lib -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/exceptions-0.10.5 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/stm-2.5.1.0 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/mtl-2.2.2 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/transformers-0.5.6.2 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/bytestring-0.11.5.2 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/template-haskell-2.19.0.0 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/pretty-1.1.3.6 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/ghc-boot-th-9.4.7 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/deepseq-1.4.8.0 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/array-0.5.4.0 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/base-4.17.2.0 -liconv -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/ghc-bignum-1.3 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/ghc-prim-0.9.1 -L/Users/mignon/.ghcup/ghc/9.4.7/lib/ghc-9.4.7/lib/../lib/x86_64-osx-ghc-9.4.7/rts-1.0.2 -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lm -ldl -lffi
error: ld: unknown option: -no_fixup_chains
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have been unable to figure out where the -no_fixup_chains
linker option is coming from. I grepped through the source of the unix
package and didn’t see it there. Maybe it’s coming from Cabal? But strange that Cabal is only specifying this option on the unix
package, and not on any of the other packages I tried to build.