error: ld: unknown option: -no_warn_duplicate_libraries on macOS with GHC 9.6.4
Summary
I've upgraded from GHC 9.6.3 to 9.6.4 on my macOS machine and zlib-0.6.3.0
stopped building.
Steps to reproduce
$ cabal-3.10.2.0 unpack zlib && cd zlib-0.6.3.0 && cabal-3.10.2.0 build -w ghc-9.6.4
Unpacking to zlib-0.6.3.0/
Resolving dependencies...
Build profile: -w ghc-9.6.4 -O1
In order, the following will be built (use -v for more details):
- zlib-0.6.3.0 (lib) (first run)
Configuring library for zlib-0.6.3.0..
Preprocessing library for zlib-0.6.3.0..
linking /private/tmp/zlib-0.6.3.0/dist-newstyle/build/aarch64-osx/ghc-9.6.4/zlib-0.6.3.0/build/Codec/Compression/Zlib/Stream_hsc_make.o failed (exit code 1)
rsp file was: "/private/tmp/zlib-0.6.3.0/dist-newstyle/build/aarch64-osx/ghc-9.6.4/zlib-0.6.3.0/build/Codec/Compression/Zlib/hsc2hscall71797-2.rsp"
command was: /usr/bin/gcc /private/tmp/zlib-0.6.3.0/dist-newstyle/build/aarch64-osx/ghc-9.6.4/zlib-0.6.3.0/build/Codec/Compression/Zlib/Stream_hsc_make.o /private/tmp/zlib-0.6.3.0/dist-newstyle/build/aarch64-osx/ghc-9.6.4/zlib-0.6.3.0/build/Codec/Compression/Zlib/Stream_hsc_utils.o -o /private/tmp/zlib-0.6.3.0/dist-newstyle/build/aarch64-osx/ghc-9.6.4/zlib-0.6.3.0/build/Codec/Compression/Zlib/Stream_hsc_make --target=arm64-apple-darwin -Wl,-no_fixup_chains -Wl,-no_warn_duplicate_libraries --target=arm64-apple-darwin -Wl,-no_fixup_chains -lz -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/bytestring-0.11.5.3 -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/template-haskell-2.20.0.0 -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/pretty-1.1.3.6 -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/ghc-boot-th-9.6.4 -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/deepseq-1.4.8.1 -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/array-0.5.6.0 -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/base-4.18.2.0 -liconv -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/ghc-bignum-1.3 -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/ghc-prim-0.10.0 -L/Users/andrew/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/rts-1.0.2 -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lm -ldl -lffi
error: ld: unknown option: -no_warn_duplicate_libraries
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: cabal-3.10.2.0: Failed to build zlib-0.6.3.0.
Expected behavior
I expect it to build successfully. For instance, GHC 9.8.1 works fine:
$ cabal-3.10.2.0 unpack zlib && cd zlib-0.6.3.0 && cabal-3.10.2.0 build -w ghc-9.8.1
Unpacking to zlib-0.6.3.0/
Resolving dependencies...
Build profile: -w ghc-9.8.1 -O1
In order, the following will be built (use -v for more details):
- zlib-0.6.3.0 (lib) (first run)
Configuring library for zlib-0.6.3.0..
Preprocessing library for zlib-0.6.3.0..
Building library for zlib-0.6.3.0..
[1 of 6] Compiling Codec.Compression.Zlib.ByteStringCompat
[2 of 6] Compiling Codec.Compression.Zlib.Stream
[3 of 6] Compiling Codec.Compression.Zlib.Internal
[4 of 6] Compiling Codec.Compression.Zlib.Raw
[5 of 6] Compiling Codec.Compression.Zlib
[6 of 6] Compiling Codec.Compression.GZip
Environment
- GHC version used: 9.6.4, installed via ghcup.
- Cabal 3.10.2.0, installed via ghcup.
- Operating System: macOS Ventura 13.0.1.
- System Architecture: arm (M2).
$ ld -v
@(#)PROGRAM:ld PROJECT:ld64-857.1
BUILD 23:13:29 May 7 2023
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 14.0.3, (clang-1403.0.22.14.1) (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 14.0.3 (tapi-1403.0.5.1)