GNU bug report logs - #74421
[PATCH] gnu: zstd: Fix cross-building to mingw32.

Previous Next

Package: guix-patches;

Reported by: Efraim Flashner <efraim <at> flashner.co.il>

Date: Mon, 18 Nov 2024 18:41:01 UTC

Severity: normal

Tags: patch

Done: Efraim Flashner <efraim <at> flashner.co.il>

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 74421 in the body.
You can then email your comments to 74421 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 guix-patches <at> gnu.org:
bug#74421; Package guix-patches. (Mon, 18 Nov 2024 18:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Efraim Flashner <efraim <at> flashner.co.il>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 18 Nov 2024 18:41:02 GMT) Full text and rfc822 format available.

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

From: Efraim Flashner <efraim <at> flashner.co.il>
To: guix-patches <at> gnu.org
Cc: Efraim Flashner <efraim <at> flashner.co.il>
Subject: [PATCH] gnu: zstd: Fix cross-building to mingw32.
Date: Mon, 18 Nov 2024 20:39:59 +0200
* gnu/packages/compression.scm (zstd)[arguments]: Adjust the custom
'adjust-library-locations phase to have separate logic for targeting
mingw32.  Adjust the make-flags to add some extra flags when targeting
mingw32.

Change-Id: Ifd32a6bd9157af93c7338dacc96467e2756b9314
---

I tested this to the best of my ability by using it as an input for
ncdu <at> 2.6 on the wip-zig-bootstrap branch and by comparing the outputs to
the pre-compiled release tarball for win64 on Github.


 gnu/packages/compression.scm | 45 ++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/compression.scm b/gnu/packages/compression.scm
index b3eca16191c..fcde956c4f9 100644
--- a/gnu/packages/compression.scm
+++ b/gnu/packages/compression.scm
@@ -7,7 +7,7 @@
 ;;; Copyright © 2015, 2016, 2017, 2018, 2020, 2021, 2022, 2024 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2015, 2017, 2018 Leo Famulari <leo <at> famulari.name>
 ;;; Copyright © 2015 Jeff Mickey <j <at> codemac.net>
-;;; Copyright © 2015-2023 Efraim Flashner <efraim <at> flashner.co.il>
+;;; Copyright © 2015-2024 Efraim Flashner <efraim <at> flashner.co.il>
 ;;; Copyright © 2016 Ben Woodcroft <donttrustben <at> gmail.com>
 ;;; Copyright © 2016 Danny Milosavljevic <dannym <at> scratchpost.org>
 ;;; Copyright © 2016–2022 Tobias Geerinckx-Rice <me <at> tobias.gr>
@@ -1779,24 +1779,45 @@ (define-public zstd
                     (static (assoc-ref outputs "static"))
                     (shared-libs (string-append lib "/lib"))
                     (static-libs (string-append static "/lib")))
-               ;; Move the static library to its own output to save ~1MiB.
                (mkdir-p static-libs)
-               (for-each (lambda (ar)
-                           (link ar (string-append static-libs "/"
-                                                   (basename ar)))
-                           (delete-file ar))
-                         (find-files shared-libs "\\.a$"))
+               ;; This is based on the win64 release zip file from zstd.
+               ,@(if (target-mingw?)
+                     `((for-each delete-file (find-files out "\\.so"))
+                       (for-each delete-file (find-files shared-libs "\\.so"))
+                       (rename-file (string-append shared-libs "/libzstd.a")
+                                    (string-append static-libs "/libzstd_static.lib"))
+                       (delete-file-recursively
+                         (string-append shared-libs "/pkgconfig"))
+                       ;; no binary for interpreter `sh' found in $PATH
+                       (delete-file (string-append out "/bin/zstdgrep"))
+                       (delete-file (string-append out "/bin/zstdless"))
+                       (delete-file (string-append out "/share/man/man1/zstdgrep.1"))
+                       (delete-file (string-append out "/share/man/man1/zstdless.1")))
+                     `(;; Move the static library to its own output to save ~1MiB.
+                       (for-each (lambda (ar)
+                                   (link ar (string-append static-libs "/"
+                                                           (basename ar)))
+                                   (delete-file ar))
+                                 (find-files shared-libs "\\.a$"))
 
-               ;; Make sure the pkg-config file refers to the right output.
-               (substitute* (string-append shared-libs "/pkgconfig/libzstd.pc")
-                 (("^prefix=.*")
-                  ;; Note: The .pc file expects a trailing slash for 'prefix'.
-                  (string-append "prefix=" lib "/\n")))))))
+                       ;; Make sure the pkg-config file refers to the right output.
+                       (substitute* (string-append shared-libs "/pkgconfig/libzstd.pc")
+                         (("^prefix=.*")
+                          ;; Note: The .pc file expects a trailing slash for 'prefix'.
+                          (string-append "prefix=" lib "/\n")))))))))
        #:make-flags
        (list ,(string-append "CC=" (cc-for-target))
              (string-append "prefix=" (assoc-ref %outputs "out"))
              (string-append "libdir=" (assoc-ref %outputs "lib") "/lib")
              (string-append "includedir=" (assoc-ref %outputs "lib") "/include")
+             ,@(if (target-mingw?)
+                   `(;; See the note in the Makefile.
+                     "TARGET_SYSTEM=Windows"
+                     ;; Don't try to link with pthread.
+                     "THREAD_LD="
+                     ;; This isn't picked up correctly in the Makefiles.
+                     "EXT=.exe")
+                   '())
              ;; Auto-detection is over-engineered and buggy.
              "PCLIBDIR=lib"
              "PCINCDIR=include"

base-commit: 1affd2b5aa7f5467a44cf757c4fc0c6956d3f3c9
-- 
Efraim Flashner   <efraim <at> flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted





Reply sent to Efraim Flashner <efraim <at> flashner.co.il>:
You have taken responsibility. (Mon, 02 Dec 2024 11:58:02 GMT) Full text and rfc822 format available.

Notification sent to Efraim Flashner <efraim <at> flashner.co.il>:
bug acknowledged by developer. (Mon, 02 Dec 2024 11:58:02 GMT) Full text and rfc822 format available.

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

From: Efraim Flashner <efraim <at> flashner.co.il>
To: 74421-done <at> debbugs.gnu.org
Subject: Re: bug#74421: Acknowledgement ([PATCH] gnu: zstd: Fix
 cross-building to mingw32.)
Date: Mon, 2 Dec 2024 13:56:35 +0200
[Message part 1 (text/plain, inline)]
Patch pushed!

-- 
Efraim Flashner   <efraim <at> flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 30 Dec 2024 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 227 days ago.

Previous Next


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