[PATCH] gnu: llvm: Fix misc errors for unsupported targets.

  • Done
  • quality assurance status badge
Details
One participant
  • Christopher Baines
Owner
unassigned
Submitted by
Christopher Baines
Severity
normal

Debbugs page

Christopher Baines wrote 7 months ago
(address . guix-patches@gnu.org)
0e25963b235b36407c0e7f7b0ef77b02ba6029fe.1722519885.git.mail@cbaines.net
* gnu/packages/llvm.scm (system->llvm-target-arch): Return #f for unknown
targets.
(llvm-15, llvm-14): Handle system->llvm-target-arch and raise a
package-unsupported-target-error condition.

Change-Id: I647f721a64a39bb34196998b7e4adda3a25f1ab3
---
gnu/packages/llvm.scm | 49 +++++++++++++++++++++++++++----------------
1 file changed, 31 insertions(+), 18 deletions(-)

Toggle diff (87 lines)
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 2614a403c1..0c0ec1bca1 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -78,6 +78,8 @@ (define-module (gnu packages llvm)
#:use-module (gnu packages vulkan)
#:use-module (gnu packages xml)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-34)
+ #:use-module (srfi srfi-35)
#:use-module (ice-9 match)
#:export (make-lld-wrapper
system->llvm-target))
@@ -107,8 +109,7 @@ (define* (system->llvm-target-arch #:optional
(if (string-prefix? system-prefix system)
target
(matches rest ...)))
- ((_)
- (error "LLVM target arch for system is unknown" system)))))
+ ((_) #f))))
(matches ("aarch64" => "AArch64")
("armhf" => "ARM")
("mips64el" => "Mips")
@@ -591,15 +592,21 @@ (define-public llvm-15
;; These options are required for cross-compiling LLVM according
;; to <https://llvm.org/docs/HowToCrossCompileLLVM.html>.
#$@(if (%current-target-system)
- #~((string-append "-DLLVM_TABLEGEN="
+ (or (and=>
+ (system->llvm-target-arch)
+ (lambda (llvm-target-arch)
+ #~((string-append "-DLLVM_TABLEGEN="
#+(file-append this-package
"/bin/llvm-tblgen"))
- #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
- (%current-target-system))
- #$(string-append "-DLLVM_TARGET_ARCH="
- (system->llvm-target-arch))
- #$(string-append "-DLLVM_TARGETS_TO_BUILD="
- (system->llvm-target)))
+ #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
+ (%current-target-system))
+ #$(string-append "-DLLVM_TARGET_ARCH=" llvm-target-arch)
+ #$(string-append "-DLLVM_TARGETS_TO_BUILD="
+ (system->llvm-target)))))
+ (raise (condition
+ (&package-unsupported-target-error
+ (package this-package)
+ (target (%current-target-system))))))
'())
;; Note: sadly, the build system refuses the use of
;; -DBUILD_SHARED_LIBS=ON and the large static archives are needed to
@@ -651,15 +658,21 @@ (define-public llvm-14
;; These options are required for cross-compiling LLVM according
;; to <https://llvm.org/docs/HowToCrossCompileLLVM.html>.
#$@(if (%current-target-system)
- #~((string-append "-DLLVM_TABLEGEN="
- #+(file-append this-package
- "/bin/llvm-tblgen"))
- #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
- (%current-target-system))
- #$(string-append "-DLLVM_TARGET_ARCH="
- (system->llvm-target-arch))
- #$(string-append "-DLLVM_TARGETS_TO_BUILD="
- (system->llvm-target)))
+ (or (and=>
+ (system->llvm-target-arch)
+ (lambda (llvm-target-arch)
+ #~((string-append "-DLLVM_TABLEGEN="
+ #+(file-append this-package
+ "/bin/llvm-tblgen"))
+ #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
+ (%current-target-system))
+ #$(string-append "-DLLVM_TARGET_ARCH=" llvm-target-arch)
+ #$(string-append "-DLLVM_TARGETS_TO_BUILD="
+ (system->llvm-target)))))
+ (raise (condition
+ (&package-unsupported-target-error
+ (package this-package)
+ (target (%current-target-system))))))
'())
;; undefined reference to `__atomic_fetch_add_8' in lib/libLLVMOrcJIT.so.14
#$@(if (target-ppc32?)

base-commit: 56d3d04a442b52097e523dcfebf60ff5bf82bcfd
--
2.45.2
Christopher Baines wrote 7 months ago
(address . 72409-done@debbugs.gnu.org)
87bk1zz6u9.fsf@cbaines.net
Christopher Baines <mail@cbaines.net> writes:

Toggle quote (10 lines)
> * gnu/packages/llvm.scm (system->llvm-target-arch): Return #f for unknown
> targets.
> (llvm-15, llvm-14): Handle system->llvm-target-arch and raise a
> package-unsupported-target-error condition.
>
> Change-Id: I647f721a64a39bb34196998b7e4adda3a25f1ab3
> ---
> gnu/packages/llvm.scm | 49 +++++++++++++++++++++++++++----------------
> 1 file changed, 31 insertions(+), 18 deletions(-)

Pushed to master as 5f0dcf22a384af08f1e7d5aafff340f3f808b55b.

Chris
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAma4k55fFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XfUkw//UQeg2EXGmYCVgQVVo7tv4rMENnTpKe4o
UGh2Q5xP3ZY03dSV701/irgqIgYpbC9uPM7VCO6g0TEKfD5ZTXsyRXZth2vjVWUG
rAS8CZBJ4/byc36nU6kb9my1FicvfFK2zm6LtPQ9QhSsYUJcacdPI7nWnXmSK9z6
qn7ROXebofhvHZQRRyX0M9tiTFen8CyYUYhyrH5q/2vch7YMtXvW+9H6TAzh/2Zk
Wvt0oautxgT/z0bZKfrjlmV8xcX0XY5pzoJ41p0qjkrXg6yFa2779SEnPVQWoGhE
qrf4qCyHnPP4rq4/PIe2fqofF6AP2zag/1sJlLD3jdcQ6xagAqKmbA2b500snkiZ
hWqahmiQh7zGh2M6evkm6XGGZ6DEkgz2LexSpr36GaqLhiSC3SPLOf2ZVyRSDp1i
eXAc8Ss/P+3XTwlKTw/+l4GI+Nmbb0Slp0hCmfgqA7hgtEEDR8wvplpIbkhuDBCa
DfV5KXikAtnI8ZTY1w8i47O3hI0BQkiUwTw0RmaPeC55RJ5K/j1YU1+cG+eUNUeK
maqpe3OLbC7Bxy6Y7mcyrjU3JV37Lm1P7s+W2s0VEkF+YRrHbJLUYKz0I8vYuqwo
T60CYY73dHAfVmu3M2fkq6gT75xi6UnZehgprjUoViDp3ozRp5+HPDdd5J012Nlp
pesjNjLHyig=
=UauB
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 72409@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 72409
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help