diff mbox series

[bug#64218,4/7] gnu: lld-15: Adjust max text section size on riscv64-linux.

Message ID dbda7b77de65485d2122507e314615b975a9180b.1687425321.git.efraim@flashner.co.il
State New
Headers show
Series build ldc with llvm-15 | expand

Commit Message

Efraim Flashner June 22, 2023, 9:19 a.m. UTC
* gnu/packages/llvm.scm (ldd-15)[arguments]: When building for
riscv64-linux add a phase to mirror an upstream patch to allow for
larger text section sizes in linked libraries.
---
 gnu/packages/llvm.scm | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index d36a95879a..a15dffed93 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1525,14 +1525,29 @@  (define-public lld-15
     (inputs
      (list llvm-15))
     (arguments
-     '(#:build-type "Release"
+     `(#:build-type "Release"
        ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
        ;; package.
        #:tests? #f
-       #:phases (modify-phases %standard-phases
-                  (add-after 'unpack 'change-directory
-                    (lambda _
-                      (chdir "lld"))))))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'change-directory
+           (lambda _
+             (chdir "lld")))
+         ,@(if (target-riscv64?)
+             '((add-after 'change-directory 'patch-riscv-text-section-size
+                 (lambda _
+                   ;; https://github.com/llvm/llvm-project/issues/63374
+                   ;; https://github.com/llvm/llvm-project/commit/9d37ea95df1b84cca9b5e954d8964c976a5e303e
+                   (substitute* "ELF/Arch/RISCV.cpp"
+                     (("uint32_t delta = 0") "uint64_t delta = 0")
+                     (("isUInt<16>\\(delta\\)") "isUInt<32>(delta)")
+                     (("is too large\"") "is too large \" + Twine(delta)"))
+                   (substitute* "ELF/InputSection.h"
+                     (("uint16_t bytesDropped = 0")
+                      "uint32_t bytesDropped = 0")
+                     (("160") "168")))))
+             '()))))
     (home-page "https://lld.llvm.org/")
     (synopsis "Linker from the LLVM project")
     (description "LLD is a high-performance linker, built as a set of reusable
@@ -1544,6 +1559,13 @@  (define-public lld-14
     (inherit lld-15)
     (version "14.0.6")
     (source (llvm-monorepo version))
+    (arguments
+     (substitute-keyword-arguments (package-arguments lld-15)
+       ((#:phases phases)
+        (if (target-riscv64?)
+          `(modify-phases ,phases
+             (delete 'patch-riscv-text-section-size))
+          phases))))
     (inputs
      (list llvm-14))))