Subject: [bug#63839] [PATCH] gnu: riscv-pk: don't target riscv64-linux-gnu when current system is riscv64.

From: Z572 <[email-masked]>
Date: Fri, 2 Jun 2023 20:10:09 +0800

* gnu/packages/virtualization.scm (riscv-pk): don't target riscv64-linux-gnu
when current system is riscv64.
---
 gnu/packages/virtualization.scm | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index c88fd31146..1257bb531d 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -28,6 +28,7 @@
 ;;; Copyright © 2022 Ekaitz Zarraga <[email-masked]>
 ;;; Copyright © 2022 Arun Isaac <[email-masked]>
 ;;; Copyright © 2022 Zhu Zihao <[email-masked]>
+;;; Copyright © 2023 Zheng Junjie <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2554,16 +2555,21 @@ (define-public riscv-pk
          "1cc0rz4q3a1zw8756b8yysw8lb5g4xbjajh5lvqbjix41hbdx6xz"))))
     (build-system gnu-build-system)
     (arguments
-     (list #:out-of-source? #t
-           ;; riscv-pk can only be built for riscv64.
-           #:target "riscv64-linux-gnu"
-           #:make-flags #~(list (string-append "INSTALLDIR=" #$output))
-           ;; Add flags to keep symbols fromhost and tohost. These symbols are
-           ;; required for the correct functioning of pk.
-           #:strip-flags #~(list "--strip-unneeded"
-                                 "--keep-symbol=fromhost"
-                                 "--keep-symbol=tohost"
-                                 "--enable-deterministic-archives")))
+     (append
+      ;; riscv-pk can only be built for riscv64.
+      (if (string-prefix? "riscv64" (%current-system))
+          '()
+          (list
+           #:target "riscv64-linux-gnu"))
+      (list #:out-of-source? #t
+
+            #:make-flags #~(list (string-append "INSTALLDIR=" #$output))
+            ;; Add flags to keep symbols fromhost and tohost. These symbols are
+            ;; required for the correct functioning of pk.
+            #:strip-flags #~(list "--strip-unneeded"
+                                  "--keep-symbol=fromhost"
+                                  "--keep-symbol=tohost"
+                                  "--enable-deterministic-archives"))))
     (home-page "https://github.com/riscv-software-src/riscv-pk")
     (synopsis "RISC-V Proxy Kernel")
     (description "The RISC-V Proxy Kernel, @command{pk}, is a lightweight

base-commit: 75bdd4b05253c0e6ca5399f60e424f0f00fdb673
-- 
2.40.1