ghc version >= 9.2 generating object files built for unknown-unsupported file format
Summary
On ghc versions >= 9.2 the compiler generates files built for unknown-unsupported file format (output of Xcode ld). I've only tested this on my M1 Mac with GHC 9.2.3, 9.2.2, and 9.0.2 and can confirm the latter does not exhibit this behavior. A well-formed Mach-O 64-bit object begins with the bytes 0xFEEDFACF.
Steps to reproduce
- Install ghc, cabal, and Homebrew LLVM 12-14.
- git clone https://github.com/haskell/primitive.git
- cd primitive && cabal build
Expected behavior
Produce a well formed Mach-O object.
What do you expect the reproducer described above to do?
Xcode ld output:
[2 of 2] Compiling Data.Primitive.Internal.Operations ( Operations.hs, Operations.o )
ld: warning: platform not specified
ld: warning: -arch not specified
ld: warning: No platform min-version specified on command line
ld: warning: ignoring file /var/folders/0c/smkz_9457_71qqm2bvrm1vgw0000gn/T/ghc30007_0/ghc_12.ldscript, building for -unknown but attempting to link with file built for unknown-unsupported file format ( 0x49 0x4E 0x50 0x55 0x54 0x28 0x22 0x2F 0x76 0x61 0x72 0x2F 0x66 0x6F 0x6C 0x64 )
Undefined symbols for architecture unknown:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture unknown
`ld' failed in phase `Merge objects'. (Exit code: 1)
Environment
- GHC version used: 9.2.3, 9.2.2
Optional:
- Operating System: macOS 12.4
- System Architecture: arm64 (but has been reproduced on x64), see https://github.com/haskell/primitive/issues/348