Source: pandoc
Version: 3.1.3+ds-3
Severity: important
Tags: ftbfs patch
User: debian-loonga...@lists.debian.org
Usertags: loong64
X-Debbugs-Cc: wanghon...@loongson.cn, lix...@loongson.cn, fanp...@loongson.cn

Dear maintainers,

Compiling the pandoc failed for loong64 in the Debian Package Auto-Building environment.
The build error is still related to "relocation R_LARCH_B26 overflow......".
Please see the below error log,
```
Preprocessing executable 'pandoc' for pandoc-cli-0.1.1..
Building executable 'pandoc' for pandoc-cli-0.1.1..
[1 of 3] Compiling PandocCLI.Lua
[2 of 3] Compiling PandocCLI.Server
[3 of 3] Compiling Main
[4 of 4] Linking dist-ghc/build/pandoc/pandoc
/usr/bin/ld.bfd: /usr/lib/ghc/lib/../lib/loongarch64-linux-ghc-9.4.7/rts-1.0.2/libHSrts-1.0.2_thr.a(NonMovingMark.thr_o): relocation R_LARCH_B26 overflow 0xfffffffff62fb154
......
```
The full build log can be found at https://buildd.debian.org/status/logs.php?pkg=pandoc&ver=3.1.3%2Bds-3&arch=loong64

There are three suggestions to solve "relocation R_LARCH_B26 overflow ......" during static linking.
1.Add loong64 to the list of low-memory architectures.
2.Use "--enable-executable-dynamic" in d/rules to reduce binary size on loong64. 3.Add extra --ghc-options in d/rules on loong64 to increase jump-instructions' range.

It is recommended to use '--ghc-options="-optc-mcmodel=medium"' in d/rules for loong64.
Please consider the patch I attached.
- Add --ghc-options="-optc-mcmodel=medium" in d/rules for loong64.
- Remove loong64 from the list of low-memory architectures.

With the attached patch, the pandoc was built successfully in my local ENV.
And I have uploaded a native pandoc to debian ports.
```
......
dh_md5sums -ppandoc
dh_builddeb -ppandoc
dpkg-deb: building package 'pandoc' in '../pandoc_3.1.3+ds-3_loong64.deb'.
 dpkg-genbuildinfo -O../pandoc_3.1.3+ds-3_loong64.buildinfo
 dpkg-genchanges -O../pandoc_3.1.3+ds-3_loong64.changes
dpkg-genchanges: info: not including original source code in upload
 dpkg-source --after-build .
```

The end, the compilation order of the relevant packages are as follows,
- ghc
- haskell-isocline
- haskell-lua
- haskell-primitive
- haskell-splitmix
- haskell-zlib
- haskell-pandoc
- haskell-pandoc-lua-engine
- pandoc

Meanwhile, we have submitted bugs to the above 9 packages to suggest to use --ghc-options="-optc-mcmodel=medium".
Your opinions are welcome.

Thanks,
Dandan Zhang
diff -Nru pandoc-3.1.3+ds/debian/rules pandoc-3.1.3+ds/debian/rules
--- pandoc-3.1.3+ds/debian/rules        2024-04-20 23:16:47.000000000 +0000
+++ pandoc-3.1.3+ds/debian/rules        2024-04-20 23:16:47.000000000 +0000
@@ -50,10 +50,14 @@
 DEB_SETUP_GHC_CONFIGURE_ARGS += --ghc-options="+RTS -V0 -RTS"
 
 # Reduce compile-time memory utilization on low-memory architectures
-ifneq (,$(filter $(DEB_BUILD_ARCH),armel armhf hppa loong64 mips mipsel))
+ifneq (,$(filter $(DEB_BUILD_ARCH),armel armhf hppa mips mipsel))
 DEB_SETUP_GHC_CONFIGURE_ARGS += --ghc-options="-optc--param 
-optcggc-min-expand=10 -O0"
 endif
 
+ifneq (,$(filter $(DEB_BUILD_ARCH),loong64))
+  DEB_SETUP_GHC_CONFIGURE_ARGS += --ghc-options="-optc-mcmodel=medium"
+endif
+
 ifneq (,$(filter $(DEB_HOST_ARCH_CPU), i386))
 DEB_SETUP_GHC_CONFIGURE_ARGS += --ghc-options="-O0"
 endif

Reply via email to