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