#6086: Cross compilation fails using system linker for other architecture
binaries
---------------------------------+------------------------------------------
Reporter: mtjm | Owner:
Type: bug | Status: new
Priority: normal | Component: Build System
Version: 7.5 | Keywords:
Os: Linux | Architecture: Unknown/Multiple
Failure: Building GHC failed | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Building ghc from git revision 4b089dbacd2a14f38a335103cf8ac0779d92f937
this command run by make fails (broken lines for readability):
{{{
CROSS_COMPILE="mips64el-unknown-linux-gnu-" "inplace/bin/ghc-cabal" \
configure --with-ghc="/home/mtjm/git/ghc-cross/inplace/bin/ghc-stage1" \
--with-ghc-pkg="/home/mtjm/git/ghc-cross/inplace/bin/ghc-pkg" \
--flag=include-ghc-prim --disable-library-for-ghci \
--configure-option=CFLAGS="-g -O2 -fno-stack-protector" \
--configure-option=LDFLAGS=" -Wl,--hash-size=31 -Wl,--reduce-memory-
overheads " \
--configure-option=CPPFLAGS=" " --with-gcc="/home/mtjm/x-tools/mips64el-
unknown-linux-gnu/bin/mips64el-unknown-linux-gnu-gcc" \
--configure-option=--with-cc="/home/mtjm/x-tools/mips64el-unknown-linux-
gnu/bin/mips64el-unknown-linux-gnu-gcc" \
--with-ar="/usr/bin/ar" --with-ranlib="true" --with-alex="/usr/bin/alex"
--with-happy="/usr/bin/happy" \
-- dist-install libraries/ghc-prim
Configuring ghc-prim-0.2.0.0...
ghc-cabal: /tmp/32545.o: does not exist
}}}
After adding the --verbose=3 option its output includes this:
{{{
searching for ld in path.
found ld at /usr/bin/ld
("/home/mtjm/git/ghc-cross/inplace/bin/ghc-
stage1",["-c","/tmp/32649.c","-o","/tmp/32649.o"])
("/usr/bin/ld",["-x","-r","/tmp/32649.o","-o","/tmp/32650.o"])
/usr/bin/ld returned ExitFailure 1 with error message:
/usr/bin/ld: /tmp/32649.o: Relocations in generic ELF (EM: 8)
/tmp/32649.o: could not read symbols: File in wrong format
ghc-cabal: /tmp/32650.o: does not exist
}}}
So it uses the system (x86_64) linker to link MIPS binaries. Adding the
--with-ld option pointing to the correct cross linker makes it run without
errors.
I think this could be fixed correctly by finding the target linker like
the compiler in configure and changing rules/build-package-data.mk to pass
the --with-ld option depending on stage.
(mips64el-unknown-linux-gnu targets aren't supported, I believe this issue
wouldn't occur only for them and I want to fix bugs preventing an
unregistered build from working.)
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6086>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs