如何在Alpinelinux中构建GHC的交叉编译器?

时间:2019-03-10 02:45:17

标签: ghc alpine

我已经在Alpinelinux v3.9 x86_64中完成了以下步骤,并出现了错误。

  1. 在port中运行bootstrap.sh以获得aarch64-alpine-linux-musl- *工具。
  2. 在x86_64中构建并安装llvm6。
  3. 将所有aarch64-alpine-linux-musl- *链接到aarch64-unknown-linux-*。
  4. 仅使用“ --target = aarch64-unknown-linux”配置ghc 8.6.3。

    Configure completed successfully.
    
       Building GHC version  : 8.6.3
              Git commit id  : 31cd867e4d37072c3ce1d51efadc94e66ddc1c28
    
       Build platform        : x86_64-alpine-linux
       Host platform         : x86_64-alpine-linux
       Target platform       : aarch64-unknown-linux
    
       Bootstrapping using   : /usr/bin/ghc
          which is version   : 8.4.3
    
       Using (for bootstrapping) : gcc
       Using gcc                 : aarch64-unknown-linux-gcc
          which is version       : 8.2.0
       Building a cross compiler : YES
       Unregisterised            : NO
       hs-cpp       : aarch64-unknown-linux-gcc
       hs-cpp-flags : -E -undef -traditional
       ar           : aarch64-unknown-linux-ar
       ld           : aarch64-unknown-linux-ld.gold
       nm           : aarch64-unknown-linux-nm
       libtool      : 
       objdump      : aarch64-unknown-linux-objdump
       ranlib       : aarch64-unknown-linux-ranlib
       windres      : 
       dllwrap      : 
       genlib       : 
       Happy        :  ()
       Alex         :  ()
       Perl         : /usr/bin/perl
       sphinx-build : 
       xelatex      : 
    
       Using LLVM tools
          clang : 
          llc   : llc
          opt   : opt
    
       HsColour was not found; documentation will not contain source links
    
       Tools to build Sphinx HTML documentation available: NO
       Tools to build Sphinx PDF documentation available: NO
    ----------------------------------------------------------------------
    
    For a standard build of GHC (fully optimised with profiling), type (g)make.
    
    To make changes to the default build configuration, copy the file
    mk/build.mk.sample to mk/build.mk, and edit the settings in there.
    
    For more information on how to configure your GHC build, see
       http://ghc.haskell.org/trac/ghc/wiki/Building
    
  5. 制作。

    ===--- building final phase
    make --no-print-directory -f ghc.mk phase=final all
    "ld" -z noexecstack -r  -o libraries/ghc-prim/dist-install/build/HSghc-prim-0.5.3.o  libraries/ghc-prim/dist-install/build/GHC/CString.o libraries/ghc-prim/dist-install/build/GHC/Classes.o libraries/ghc-prim/dist-install/build/GHC/Debug.o libraries/ghc-prim/dist-install/build/GHC/IntWord64.o libraries/ghc-prim/dist-install/build/GHC/Magic.o libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.o libraries/ghc-prim/dist-install/build/GHC/Tuple.o libraries/ghc-prim/dist-install/build/GHC/Types.o   libraries/ghc-prim/dist-install/build/cbits/atomic.o libraries/ghc-prim/dist-install/build/cbits/bswap.o libraries/ghc-prim/dist-install/build/cbits/clz.o libraries/ghc-prim/dist-install/build/cbits/ctz.o libraries/ghc-prim/dist-install/build/cbits/debug.o libraries/ghc-prim/dist-install/build/cbits/longlong.o libraries/ghc-prim/dist-install/build/cbits/pdep.o libraries/ghc-prim/dist-install/build/cbits/pext.o libraries/ghc-prim/dist-install/build/cbits/popcnt.o libraries/ghc-prim/dist-install/build/cbits/word2float.o   
    ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 183)
    ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: Relocations in generic ELF (EM: 183)
    ld: libraries/ghc-prim/dist-install/build/GHC/CString.o: error adding symbols: file in wrong format
    make[1]: *** [libraries/ghc-prim/ghc.mk:4: libraries/ghc-prim/dist-install/build/HSghc-prim-0.5.3.o] Error 1
    make: *** [Makefile:127: all] Error 2
    
    $ file ./libraries/ghc-prim/dist-install/build/GHC/CString.o
    ./libraries/ghc-prim/dist-install/build/GHC/CString.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped
    

1 个答案:

答案 0 :(得分:1)

知道了。删除ld.gold并将ld复制为ld.gold之后,构建过程结束。简单测试通过。