From patchwork Mon Nov 18 18:39:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 33554 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DEF4427BBEA; Mon, 18 Nov 2024 18:41:52 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 834E327BBE2 for ; Mon, 18 Nov 2024 18:41:50 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tD6gh-0008Sd-Se; Mon, 18 Nov 2024 13:41:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tD6gR-0008PK-TH for guix-patches@gnu.org; Mon, 18 Nov 2024 13:41:14 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tD6gI-0004bj-IU for guix-patches@gnu.org; Mon, 18 Nov 2024 13:41:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=SLxRmMjLaxhi3G4XB27XryHba44rTJRmXOHSvLDt5Ys=; b=r88/pTTum24qmYBMy7bDLhph9eO3mpJdi9QNCJTnNsTpz1TN/D9Cmb5WXm1Z2qpibWszwa5z0rn8Fe6Vkj2/76jrFtjk1sLYwU/EYVq4F+L67ZzHOV8LzALUFNVeVjAHarbhSnRP7BMpPAG650U+llnYfx8cjSlf9oGQN/0uEBi89X2k+4hpcdKCrH9SP4ujTE29BapWIswMEptGMJ7X6Pc+A6MdAUakrlA7Yrh7CMehUhcGv7vHFjv9Lwyb9gY5PHgtqkarMqBny9FigOYH2DVJZJNmnUoqpmEaYmXQQoDLq92wphuk6CXh4FT2RXJbF8J2SXmDLci8p0XyaqttgQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tD6gI-0000SL-2P for guix-patches@gnu.org; Mon, 18 Nov 2024 13:41:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74421] [PATCH] gnu: zstd: Fix cross-building to mingw32. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 18 Nov 2024 18:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74421 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74421@debbugs.gnu.org Cc: Efraim Flashner X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17319552221691 (code B ref -1); Mon, 18 Nov 2024 18:41:01 +0000 Received: (at submit) by debbugs.gnu.org; 18 Nov 2024 18:40:22 +0000 Received: from localhost ([127.0.0.1]:35135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tD6fd-0000RD-Cy for submit@debbugs.gnu.org; Mon, 18 Nov 2024 13:40:21 -0500 Received: from lists.gnu.org ([209.51.188.17]:44840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tD6fY-0000R2-Jy for submit@debbugs.gnu.org; Mon, 18 Nov 2024 13:40:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tD6fY-0008FM-3D for guix-patches@gnu.org; Mon, 18 Nov 2024 13:40:16 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tD6fV-0004aR-Tv for guix-patches@gnu.org; Mon, 18 Nov 2024 13:40:15 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-432d866f70fso141555e9.2 for ; Mon, 18 Nov 2024 10:40:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731955212; x=1732560012; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=SLxRmMjLaxhi3G4XB27XryHba44rTJRmXOHSvLDt5Ys=; b=M4p0nfRnT3T9N9WUvMUKVExHwMkyVjhbtG9cTqkLWCyf9fZ8/q3/hKQKnvDUWTmMTN ycngB/FDPxiekEO7O0Ty5Fgd2YYEuYhrLQFMYtAeBBWxezMtKxPIGLUSljw0g2oVTSAn 8E8C+VVMaCGofIvn1I+F06vC4Zap23NgAHqZxkfg5caKUNdn2RAXgn/W4j65iop5+SG/ axQJQarCL2nARLd055tBzKoR0J2UGWPN4JGJMGcM/RltJpEoEzGHyYTuFNJn9Kdi3jsg 0swUvzsEzo+e7zkbgQGPKhgNSW6NP6X6Atl2Zwf0wWnzpoVGPLRMr3OSGvVLOVCus9wU RIZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731955212; x=1732560012; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SLxRmMjLaxhi3G4XB27XryHba44rTJRmXOHSvLDt5Ys=; b=GDmMZUrYMG+gI531EASCISs2HJ9eHTgHDzWDML6bJAQTAQISFlyHWT0C2hr13kQ3M1 ZNHmgl77ulf1KqpJJ+W8wIg8gVjicZ/q0uBxBPnbwO7Qegq/T5Tm+wUiLYX1hDBCfSoD bsyamhUw8fEY/ZTmOC6w+UrVvbP5PI/oY30fGxQWe+EEctdxyTYCwXaZ9GtCg0k0vJHO F16GMmDFn+ZKEcKU93DjMPcaiFRvP15x3EkIQIcNRs4g81NB0PRgQOY2xpQnnAV+cRnk rPoTY/xp2Tsg6+CDzyEuGvybjTF5a/SvmRGq9L8eOJN7+bEcav0J1CFSjzjG2YY3AXe1 Jp+A== X-Gm-Message-State: AOJu0YxBiVbHok0cbN25XbfZE+CZ5/HYMOjQFxFQd6rvawzlg5IraMWn x28XUPvZEEIOAMzqk1N3EnpDxml+SkoY+2si/y0bFuZlxQodLlaMqaMvEnAv X-Google-Smtp-Source: AGHT+IE1Pyk+SQO7JVm+/FyfksZF7OM2d/lmxTiKB/wr4x4wKpuP0RLY0HtnFar5kHmfUlVA+emPsA== X-Received: by 2002:a05:600c:1382:b0:431:5d4f:73a3 with SMTP id 5b1f17b1804b1-432df74f0d4mr106263535e9.18.1731955211447; Mon, 18 Nov 2024 10:40:11 -0800 (PST) Received: from localhost ([31.210.180.118]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432da298c97sm167891805e9.40.2024.11.18.10.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 10:40:10 -0800 (PST) From: Efraim Flashner Date: Mon, 18 Nov 2024 20:39:59 +0200 Message-ID: <174bb50174a1779a66f95dafd90902288adb440d.1731955075.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=efraim.flashner@gmail.com; helo=mail-wm1-x330.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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@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(-) base-commit: 1affd2b5aa7f5467a44cf757c4fc0c6956d3f3c9 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 ;;; Copyright © 2015, 2017, 2018 Leo Famulari ;;; Copyright © 2015 Jeff Mickey -;;; Copyright © 2015-2023 Efraim Flashner +;;; Copyright © 2015-2024 Efraim Flashner ;;; Copyright © 2016 Ben Woodcroft ;;; Copyright © 2016 Danny Milosavljevic ;;; Copyright © 2016–2022 Tobias Geerinckx-Rice @@ -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"