Hadrian merge objects is cross-compiling unaware.
Summary
Hadrian merge objects is using target linker when merging object on stage0 which is wrong as it should use system linker (host linker).
Steps to reproduce
On x64/linux:
./configure --target=i686-unknown-linux-gnu # assuming cross tools are installed and in the path ./hadrian/build --flavour=quick-cross -V
Error:
| Run MergeObjects Stage0: _build/stage0/libraries/ghc-boot-th/build/GHC/LanguageExtensions/Type.o (and 2 more) => _build/stage0/libraries/ghc-boot-th/build/HSghc-boot-th-9.1.0.20201002.o
/export/home/karel/sfw/x-tools/i686-unknown-linux-gnu/bin/i686-unknown-linux-gnu-ld -r -o _build/stage0/libraries/ghc-boot-th/build/HSghc-boot-th-9.1.0.20201002.o _build/stage0/libraries/ghc-boot-th/build/GHC/LanguageExtensions/Type.o _build/stage0/libraries/ghc-boot-th/build/GHC/ForeignSrcLang/Type.o _build/stage0/libraries/ghc-boot-th/build/GHC/Lexeme.o
/export/home/karel/sfw/x-tools/i686-unknown-linux-gnu/bin/i686-unknown-linux-gnu-ld: relocatable linking with relocations from format elf64-x86-64 (_build/stage0/libraries/ghc-boot-th/build/GHC/LanguageExtensions/Type.o) to format elf32-i386 (_build/stage0/libraries/ghc-boot-th/build/HSghc-boot-th-9.1.0.20201002.o) is not supported
Error when running Shake build system:
at action, called at src/Rules.hs:40:19 in main:Rules
at need, called at src/Rules.hs:62:5 in main:Rules
* Depends on: _build/stage0/lib/package.conf.d/template-haskell-2.17.0.0.conf
at apply1, called at src/Development/Shake/Internal/Rules/Oracle.hs:159:32 in shake-0.19.1-6a97e69d0545d3ba1eb59903d23e00e0d9c4b6d3edc79eb4573a53c7e0697438:Development.Shake.Internal.Rules.Oracle
* Depends on: OracleQ (ContextDataKey (Context {stage = Stage0, package = Package {pkgType = Library, pkgName = "template-haskell", pkgPath = "libraries/template-haskell"}, way = v}))
at need, called at src/Hadrian/Oracles/Cabal/Rules.hs:54:9 in main:Hadrian.Oracles.Cabal.Rules
* Depends on: _build/stage0/libraries/template-haskell/setup-config
at need, called at src/Rules/Library.hs:157:18 in main:Rules.Library
* Depends on: _build/stage0/libraries/ghc-boot-th/build/HSghc-boot-th-9.1.0.20201002.o
at cmd', called at src/Builder.hs:293:23 in main:Builder
at cmd, called at src/Builder.hs:380:8 in main:Builder
* Raised the exception:
Development.Shake.cmd, system command failed
Command line: /export/home/karel/sfw/x-tools/i686-unknown-linux-gnu/bin/i686-unknown-linux-gnu-ld -r -o _build/stage0/libraries/ghc-boot-th/build/HSghc-boot-th-9.1.0.20201002.o _build/stage0/libraries/ghc-boot-th/build/GHC/LanguageExtensions/Type.o _build/stage0/libraries/ghc-boot-th/build/GHC/ForeignSrcLang/Type.o _build/stage0/libraries/ghc-boot-th/build/GHC/Lexeme.o
Exit code: 1
Stderr and Stdout:
/export/home/karel/sfw/x-tools/i686-unknown-linux-gnu/bin/i686-unknown-linux-gnu-ld: relocatable linking with relocations from format elf64-x86-64 (_build/stage0/libraries/ghc-boot-th/build/GHC/LanguageExtensions/Type.o) to format elf32-i386 (_build/stage0/libraries/ghc-boot-th/build/HSghc-boot-th-9.1.0.20201002.o) is not supported
Expected behavior
For stage0 we need to use hosts' tools.
Environment
- GHC version used:
Optional:
- Operating System:
- System Architecture: