liudidi
大佬,也是在编译 pandoc,目前是想用 https://github.com/loong64/ghc-musl 来实现,但是目前也遇到了 relocation R_LARCH_B26 报错,尝试加 -optc-mcmodel=medium -optl-mcmodel=medium 构建也还是一样的错误。
cd ~
git clone --depth=1 -b 3.9.0.2 https://github.com/jgm/pandoc
cd ~/pandoc
export DOCKERIMAGE=ghcr.io/loong64/ghc/ghc-musl:9.14.1
export GHCOPTS="-j4 +RTS -A256m -RTS -split-sections -optc-Os -optl=-pthread"
export CABALOPTS="-f-export-dynamic -fembed_data_files -fhttp -fserver -flua --enable-executable-static -j4"
export REVISION=1
docker run --rm --platform linux/loong64 -v $PWD:/mnt -v $PWD/linux/artifacts:/artifacts -e REVISION -e CABALOPTS -e GHCOPTS -w /mnt --userns host --memory=0 $DOCKERIMAGE bash /mnt/linux/make_artifacts.sh
Configuring executable 'pandoc' for pandoc-cli-3.9.0.2...
Preprocessing executable 'pandoc' for pandoc-cli-3.9.0.2...
Building executable 'pandoc' for pandoc-cli-3.9.0.2...
[1 of 3] Compiling PandocCLI.Lua
[2 of 3] Compiling PandocCLI.Server
[3 of 3] Compiling Main
[4 of 4] Linking /mnt/dist-newstyle/build/loongarch64-linux/ghc-9.14.1/pandoc-cli-3.9.0.2/x/pandoc/build/pandoc/pandoc
/usr/lib/gcc/loongarch64-alpine-linux-musl/15.2.0/../../../../loongarch64-alpine-linux-musl/bin/ld: /usr/lib/libc.a(exit.lo): relocation R_LARCH_B26 overflow 0x802d834
Dump relocate record:
stack top relocation name symbol
at /usr/lib/libc.a(exit.lo)(.text.libc_exit_fini+0x10):
...
0x0000000000000000 R_LARCH_PCALA_HI20 `__fini_array_end'
0x0000000000000000 R_LARCH_RELAX `<nameless>'
at /usr/lib/libc.a(exit.lo)(.text.libc_exit_fini+0x14):
0x0000000000000000 R_LARCH_PCALA_LO12 `__fini_array_end'
0x0000000000000000 R_LARCH_RELAX `<nameless>'
at /usr/lib/libc.a(exit.lo)(.text.libc_exit_fini+0x18):
0x0000000000000000 R_LARCH_PCALA_HI20 `__fini_array_start'
0x0000000000000000 R_LARCH_RELAX `<nameless>'
at /usr/lib/libc.a(exit.lo)(.text.libc_exit_fini+0x1c):
0x0000000000000000 R_LARCH_PCALA_LO12 `__fini_array_start'
0x0000000000000000 R_LARCH_RELAX `<nameless>'
at /usr/lib/libc.a(exit.lo)(.text.libc_exit_fini+0x20):
0x0000000000000000 R_LARCH_B26 `.L4'
at /usr/lib/libc.a(exit.lo)(.text.libc_exit_fini+0x30):
0x0000000000000000 R_LARCH_B16 `.L5'
at /usr/lib/libc.a(exit.lo)(.text.libc_exit_fini+0x44):
0x0000000000000000 R_LARCH_B26 `_fini'
at /usr/lib/libc.a(exit.lo)(.text.exit+0xc):
0x0000000000000000 R_LARCH_B26 `__funcs_on_exit'
-- Record dump end --
/usr/lib/libc.a(exit.lo): in function `exit':
/home/buildozer/aports/main/musl/src/musl-1.2.5/src/exit/exit.c:29:0: error:
(.text.exit+0xc): relocation truncated to fit: R_LARCH_B26 against symbol `__funcs_on_exit' defined in .text.__funcs_on_exit section in /usr/lib/libc.a(atexit.lo)
/usr/lib/gcc/loongarch64-alpine-linux-musl/15.2.0/../../../../loongarch64-alpine-linux-musl/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
ghc-9.14.1: Uncaught exception ghc-9.14.1-inplace:GHC.Utils.Panic.GhcException:
`gcc' failed in phase `Linker'. (Exit code: 1)
While handling `gcc' failed in phase `Linker'. (Exit code: 1)
HasCallStack backtrace:
throwIO, called at libraries/exceptions/src/Control/Monad/Catch.hs:343:12 in exceptions-0.10.11-inplace:Control.Monad.Catch
throwM, called at libraries/exceptions/src/Control/Monad/Catch.hs:855:84 in exceptions-0.10.11-inplace:Control.Monad.Catch
onException, called at compiler/GHC/Driver/MakeAction.hs:235:23 in ghc-9.14.1-inplace:GHC.Driver.MakeAction
Error: [Cabal-7125]
Failed to build exe:pandoc from pandoc-cli-3.9.0.2.
另外 ghc 交叉编译我也遇到了@lafudru 一样的问题,编译出来的二进制文件是 x86_64 的而不是 loongarch64 架构的。
按照文档的说法,我需要对构建出来的包执行一次 make install,然后重新用这个 ghc 再次交叉编译一次吗?