[bug#64218,4/7] gnu: lld-15: Adjust max text section size on riscv64-linux.
Commit Message
* 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(-)
@@ -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))))