Bug#1085966: ghc: ftbfs: help: Use extra --ghc-options does not reduce binary size (based on ghc 9.6.6-2)
fanpeng
fanpeng at loongson.cn
Thu Oct 24 04:35:49 BST 2024
On Thu, 24 Oct 2024 11:16:04 +0800 zhangdandan wrote:
I'm aware of the problem.
For LoongArch64, support in ghc-9.6-* is not complete. Maybe we should
finish it.
To put it simply, we should add some code like this:
----
41c41
< rewrites = [rewriteSymType, rewriteAVX, rewriteCall]
---
> rewrites = [rewriteSymType, rewriteAVX, rewriteCall, rewriteJump]
123a124,146
> appendInsn i = (`B.append` B.pack ("\n\t" ++ i))
>
> -- | This rewrites bl and b jump inst to avoid creating PLT entries for
> -- functions on loongarch64, because there is no separate call
instruction
> -- for function calls in loongarch64. Also, this replacement will load
> -- the function address from the GOT, which is resolved to point to the
> -- real address of the function.
> rewriteJump :: Rewrite
> rewriteJump platform l
> | not isLoongArch64 = Nothing
> | isBL l = Just $ replaceJump "bl" "$ra" "$ra" l
> | isB l = Just $ replaceJump "b" "$zero" "$t0" l
> | otherwise = Nothing
> where
> isLoongArch64 = platformArch platform == ArchLoongArch64
> isBL = B.isPrefixOf (B.pack "bl\t")
> isB = B.isPrefixOf (B.pack "b\t")
>
> replaceJump jump rd rj l =
> appendInsn ("jirl" ++ "\t" ++ rd ++ ", " ++ rj ++ ", 0") $
removeBracket $
> replaceOnce (B.pack (jump ++ "\t%plt(")) (B.pack ("la\t" ++
rj ++ ", ")) l
> where
> removeBracket = replaceOnce (B.pack ")") (B.pack "")
----
This will replace the jump insns with the wider's insns. Otherwise, for
building some
Larger packages, such as haskell-pandoc, cause the previous error:
R_LARCH_B26 overflow.
> Package: ghc
> Version: 9.6.6-2
> Severity: important
> Tags: ftbfs help
> User: debian-loongarch at lists.debian.org
> Usertags: loong64
>
> Hi Ilias and LocutusOfBorg,
>
> Based on ghc 9.6.6-2(use extra --ghc-options does not reduce binary
> size), compiling haskell-pandoc still throws errors.
> 1. extra --ghc-options in d/rules is as follows,
> ```
> ifneq (,$(filter loong64, $(DEB_HOST_ARCH)))
> EXTRA_HADRIAN_FLAGS += "*.*.ghc.*.opts += -optc-mcmodel=medium"
> endif
>
> ```
>
> 2. error log of haskell-pandoc is as follows,
> ```
> Building test suite 'test-pandoc' for pandoc-3.1.11.1..
> [58 of 58] Linking dist-ghc/build/test-pandoc/test-pandoc
> /usr/bin/ld: dist-ghc/build/test-pandoc/test-pandoc-tmp/Tests/Helpers.o:
> relocation R_LARCH_B26 overflow 0x89f8bbc
> Dump relocate record:
> stack top relocation name symbol
> ......
> dist-ghc/build/test-pandoc/test-pandoc-tmp/Tests/Helpers.o:(.text+0x4):
> relocation truncated to fit: R_LARCH_B26 against symbol `stg_ap_0_fast'
> defined in .text section in
>
/usr/lib/ghc/lib/../lib/loongarch64-linux-ghc-9.6.6/rts-1.0.2/libHSrts-1.0.2_thr.a(Apply.thr_o)
> /usr/bin/ld: final link failed: bad value
> collect2: error: ld returned 1 exit status
> ghc-9.6.6: `loongarch64-linux-gnu-gcc' failed in phase `Linker'. (Exit
> code: 1)
> -e: error: debian/hlibrary.setup build --builddir=dist-ghc returned exit
> code 1
> ......
>
> ```
>
> For ghc, the full build log can be found at
> https://buildd.debian.org/status/logs.php?pkg=ghc&arch=loong64.
> For haskell-pandoc, the full build log can be found at
>
https://buildd.debian.org/status/logs.php?pkg=haskell-pandoc&arch=loong64.
>
> Please give us some suggestions.
> Let's discuss and solve the problem together under this bug.
> Your opinions are welcome.
>
> Dandan
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-haskell-maintainers/attachments/20241024/ce4b3d4c/attachment.htm>
More information about the Pkg-haskell-maintainers
mailing list