GNU bug report logs - #72751
[PATCH 0/2] Rework cmake cross compiling.

Previous Next

Package: guix-patches;

Reported by: Dariqq <dariqq <at> posteo.net>

Date: Wed, 21 Aug 2024 18:10:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 72751 in the body.
You can then email your comments to 72751 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to efraim <at> flashner.co.il, vagrant <at> debian.org, guix-patches <at> gnu.org:
bug#72751; Package guix-patches. (Wed, 21 Aug 2024 18:10:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dariqq <dariqq <at> posteo.net>:
New bug report received and forwarded. Copy sent to efraim <at> flashner.co.il, vagrant <at> debian.org, guix-patches <at> gnu.org. (Wed, 21 Aug 2024 18:10:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: guix-patches <at> gnu.org
Cc: Dariqq <dariqq <at> posteo.net>
Subject: [PATCH 0/2] Rework cmake cross compiling.
Date: Wed, 21 Aug 2024 18:05:44 +0000
Hi,

This is an attempt to move the cross compile logic out of the build side.

This should fix https://issues.guix.gnu.org/72697 and technically supersedes https://issues.guix.gnu.org/68366 .
Also cleans up after https://issues.guix.gnu.org/69476 by removing the need for CMAKE_SYSTEM_NAME override.

Main benefit is that this decouples the cmake native compilation and cmake cross compilation, i.e. if a new target needs a new CMAKE_SYSTEM_NAME we don't need to touch build code to enable it and thus don't need to rebuild everything natively for something only affecting cross building.

Also use the target-*? functions and c*-for-target instead of reimplementing them in build code.

The new cmake-system-name-for-target (a bit long, idk) now also supports hurd and bare-metal targets.

I have tested this with the package i had troubles in #72697, and also verified that the ath9k firmware hashes are unchanged.

Output of guix hash:

/gnu/store/0r075s8g9pr9i6yd3pvwfjl2g4mkm7s8-ath9k-htc-ar9271-firmware-1.4.0/lib/firmware/htc_9271.fw 
0bi0m4y1g8i47mal4m11pry88kjqqyk2209hw5yj2awngp31qj55

/gnu/store/msjnrh864a2c8k44hvwqs6fra7c7bb6v-ath9k-htc-ar7010-firmware-1.4.0/lib/firmware/htc_7010.fw 
01hl01gv66k8g5avw85fbfyzblsy1ccmv64wq7g3zbgdwcb4ry7f


Unfortunely this will cause a lot of rebuilds (but this will be hopefully easier in the future).

Dariqq (2):
  guix: build-system: cmake: Rework cross compilation.
  gnu: ath9k-firmware: Remove CMAKE_SYSTEM_NAME override.

 gnu/packages/firmware.scm         |  6 ++----
 guix/build-system/cmake.scm       | 19 ++++++++++++++++++-
 guix/build/cmake-build-system.scm | 11 -----------
 3 files changed, 20 insertions(+), 16 deletions(-)


base-commit: 7a149c6003d25e8b2794b113d34062be134d7710
-- 
2.45.2





Information forwarded to guix-patches <at> gnu.org:
bug#72751; Package guix-patches. (Wed, 21 Aug 2024 18:37:01 GMT) Full text and rfc822 format available.

Message #8 received at 72751 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 72751 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>
Subject: [PATCH 1/2] guix: build-system: cmake: Rework cross compilation.
Date: Wed, 21 Aug 2024 18:34:50 +0000
Move the extra configure flags for cross building out from the build side code and instead
prepend them to the configure-flags.

Use new procedure cmake-system-name-for-target to add support for hurd and
bare-metal targets.

* guix/build/cmake-build-system.scm (configure): Move cross build flags from
here ...
* guix/build-system/cmake.scm (cmake-cross-build): ... to here.
(cmake-system-name-for-target): New procedure.

Change-Id: Ic68acc246e543491ed147e53d47cec5de46b82cb
---
 guix/build-system/cmake.scm       | 19 ++++++++++++++++++-
 guix/build/cmake-build-system.scm | 11 -----------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/guix/build-system/cmake.scm b/guix/build-system/cmake.scm
index aa187c9844..fd32548342 100644
--- a/guix/build-system/cmake.scm
+++ b/guix/build-system/cmake.scm
@@ -39,6 +39,15 @@ (define-module (guix build-system cmake)
 ;;
 ;; Code:
 
+(define* (cmake-system-name-for-target
+          #:optional (target (or (%current-target-system)
+                                 (%current-system))))
+  (cond ((target-hurd? target)  "GNU")
+        ((target-linux? target) "Linux")
+        ((target-mingw? target) "Windows")
+        ;; For avr, or1k-elf, xtensa-ath9k-elf
+        (else "Generic")))
+
 (define %cmake-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build cmake-build-system)
@@ -228,7 +237,15 @@ (define* (cmake-cross-build name
                                                  search-path-specification->sexp
                                                  native-search-paths)
                        #:phases #$phases
-                       #:configure-flags #$configure-flags
+                       #:configure-flags `(#$(string-append "-DCMAKE_C_COMPILER="
+                                                            (cc-for-target target))
+                                           #$(string-append "-DCMAKE_CXX_COMPILER="
+                                                            (cxx-for-target target))
+                                           #$(string-append "-DCMAKE_SYSTEM_NAME="
+                                                            (cmake-system-name-for-target target))
+                                           ,@#$(if (pair? configure-flags)
+                                                   (sexp->gexp configure-flags)
+                                                   configure-flags))
                        #:make-flags #$make-flags
                        #:out-of-source? #$out-of-source?
                        #:build-type #$build-type
diff --git a/guix/build/cmake-build-system.scm b/guix/build/cmake-build-system.scm
index d1ff5071be..61033061c6 100644
--- a/guix/build/cmake-build-system.scm
+++ b/guix/build/cmake-build-system.scm
@@ -62,17 +62,6 @@ (define* (configure #:key outputs (configure-flags '()) (out-of-source? #t)
                   ,(string-append "-DCMAKE_INSTALL_RPATH=" out "/lib")
                   ;; enable verbose output from builds
                   "-DCMAKE_VERBOSE_MAKEFILE=ON"
-
-                  ;;  Cross-build
-                  ,@(if target
-                        (list (string-append "-DCMAKE_C_COMPILER="
-                                             target "-gcc")
-                              (string-append "-DCMAKE_CXX_COMPILER="
-                                             target "-g++")
-                              (if (string-contains target "mingw")
-                                  "-DCMAKE_SYSTEM_NAME=Windows"
-                                  "-DCMAKE_SYSTEM_NAME=Linux"))
-                        '())
                   ,@configure-flags)))
       (format #t "running 'cmake' with arguments ~s~%" args)
       (apply invoke "cmake" args))))
-- 
2.45.2





Information forwarded to efraim <at> flashner.co.il, vagrant <at> debian.org, guix-patches <at> gnu.org:
bug#72751; Package guix-patches. (Wed, 21 Aug 2024 18:37:02 GMT) Full text and rfc822 format available.

Message #11 received at 72751 <at> debbugs.gnu.org (full text, mbox):

From: Dariqq <dariqq <at> posteo.net>
To: 72751 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>
Subject: [PATCH 2/2] gnu: ath9k-firmware: Remove CMAKE_SYSTEM_NAME override.
Date: Wed, 21 Aug 2024 18:34:51 +0000
* gnu/packages/firmware.scm
(ath9k-htc-ar7010-firmware)[#:configure-flags]: Remove CMAKE_SYSTEM_NAME.
(ath9k-htc-ar9271-firmware)[#:configure-flags]: Same.

Change-Id: I87acb0aa781d104be511b1f368d9332c61d71627
---
 gnu/packages/firmware.scm | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 4348612567..183e25661d 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -116,8 +116,7 @@ (define-public ath9k-htc-ar7010-firmware
      (list #:target "xtensa-ath9k-elf"
            #:tests? #f
            #:configure-flags
-           #~'("-DCMAKE_SYSTEM_NAME=Generic"      ;override default value
-               "-DTARGET_MAGPIE=ON")
+           #~'("-DTARGET_MAGPIE=ON")
            #:phases
            #~(modify-phases %standard-phases
                (add-before 'configure 'change-directory
@@ -145,8 +144,7 @@ (define-public ath9k-htc-ar9271-firmware
      (substitute-keyword-arguments
        (package-arguments ath9k-htc-ar7010-firmware)
        ((#:configure-flags flags)
-        #~'("-DCMAKE_SYSTEM_NAME=Generic"         ;override default value
-            "-DTARGET_K2=ON"))))
+        #~'("-DTARGET_K2=ON"))))
     (synopsis "Firmware for the Atheros AR9271 USB 802.11n NICs")
     (description
      "This is the firmware for the Qualcomm Atheros AR9271 802.11n USB NICs
-- 
2.45.2





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Tue, 14 Jan 2025 13:18:02 GMT) Full text and rfc822 format available.

Notification sent to Dariqq <dariqq <at> posteo.net>:
bug acknowledged by developer. (Tue, 14 Jan 2025 13:18:02 GMT) Full text and rfc822 format available.

Message #16 received at 72751-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Dariqq <dariqq <at> posteo.net>
Cc: Vagrant Cascadian <vagrant <at> debian.org>, 72751-done <at> debbugs.gnu.org,
 Efraim Flashner <efraim <at> flashner.co.il>
Subject: Re: [bug#72751] [PATCH 0/2] Rework cmake cross compiling.
Date: Tue, 14 Jan 2025 14:16:37 +0100
Finally pushed:

  d804997897 * gnu: ath9k-firmware: Remove CMAKE_SYSTEM_NAME override.
  ad672d80d7 * build-system: cmake: Rework cross compilation.

Thanks, Dariqq!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 12 Feb 2025 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 127 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.