guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04/09: gnu: zig: Build with baseline cpu by default.


From: guix-commits
Subject: 04/09: gnu: zig: Build with baseline cpu by default.
Date: Sun, 3 Dec 2023 03:09:43 -0500 (EST)

efraim pushed a commit to branch master
in repository guix.

commit a8a7153996ebce795bbbefab01c38852c545f87e
Author: Ekaitz Zarraga <ekaitz@elenq.tech>
AuthorDate: Sat Nov 18 17:51:09 2023 +0100

    gnu: zig: Build with baseline cpu by default.
    
    * gnu/packages/patches/zig-use-baseline-cpu-by-default.patch: Add file.
    * gnu/packages/zig.scm (zig-0.10.1): Apply patch above.
    * gnu/local/mk (dist_patch_DATA): Register it.
    
    Change-Id: I40bd28071c97c0dd0a907c704072b52b26d2de28
    Signed-off-by: Efraim Flashner <efraim@flashner.co.il>
---
 gnu/local.mk                                       |  1 +
 .../patches/zig-use-baseline-cpu-by-default.patch  | 36 ++++++++++++++++++++++
 gnu/packages/zig.scm                               |  3 +-
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index fd90b954a9..fde91b33eb 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2177,6 +2177,7 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/yggdrasil-extra-config.patch    \
   %D%/packages/patches/zig-0.9-riscv-support.patch             \
   %D%/packages/patches/zig-do-not-link-against-librt.patch     \
+  %D%/packages/patches/zig-use-baseline-cpu-by-default.patch   \
   %D%/packages/patches/zig-use-system-paths.patch              \
   %D%/packages/patches/zsh-egrep-failing-test.patch
 
diff --git a/gnu/packages/patches/zig-use-baseline-cpu-by-default.patch 
b/gnu/packages/patches/zig-use-baseline-cpu-by-default.patch
new file mode 100644
index 0000000000..be78d9c6c7
--- /dev/null
+++ b/gnu/packages/patches/zig-use-baseline-cpu-by-default.patch
@@ -0,0 +1,36 @@
+From 1dc188129950031243c5a0c80ec2562fab8ec549 Mon Sep 17 00:00:00 2001
+From: Ekaitz Zarraga <ekaitz@elenq.tech>
+Date: Sat, 18 Nov 2023 15:04:16 +0100
+Subject: [PATCH] Use `baseline` cpu by default.
+
+This helps Guix tune the package later. Tunning will only add
+`-Dcpu=whatever` which should override the standard behaviour.
+
+Zig by default uses `native`, which interferes with our build process.
+In our previous zig-build-system we chose to add `-Dcpu=baseline` flag
+in each `zig build` execution, but that doesn't allow us to tune the
+package later. Tunning is only designed to add extra flags in the
+command line call, and we already had one set for the baseline case.
+With this patch we set the standard behavior to `baseline` so we don't
+need to add the `-Dcpu=baseline` flag in the zig-build-system and we can
+tune with no issues.
+---
+ lib/std/zig/CrossTarget.zig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/std/zig/CrossTarget.zig b/lib/std/zig/CrossTarget.zig
+index 6c59a4a3a..f5ec065fe 100644
+--- a/lib/std/zig/CrossTarget.zig
++++ b/lib/std/zig/CrossTarget.zig
+@@ -12,7 +12,7 @@ const mem = std.mem;
+ /// `null` means native.
+ cpu_arch: ?Target.Cpu.Arch = null,
+ 
+-cpu_model: CpuModel = CpuModel.determined_by_cpu_arch,
++cpu_model: CpuModel = CpuModel.baseline,
+ 
+ /// Sparse set of CPU features to add to the set from `cpu_model`.
+ cpu_features_add: Target.Cpu.Feature.Set = Target.Cpu.Feature.Set.empty,
+-- 
+2.41.0
+
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index 08ee650d8b..853b5766c2 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -146,7 +146,8 @@ toolchain.  Among other features it provides
        (file-name (git-file-name name version))
        (sha256
         (base32 "1sh5xjsksl52i4cfv1qj36sz5h0ln7cq4pdhgs3960mk8a90im7b"))
-       (patches (search-patches "zig-do-not-link-against-librt.patch"))))
+       (patches (search-patches "zig-do-not-link-against-librt.patch"
+                                "zig-use-baseline-cpu-by-default.patch"))))
     (arguments
      (substitute-keyword-arguments (package-arguments zig-0.9)
        ((#:configure-flags flags ''())



reply via email to

[Prev in Thread] Current Thread [Next in Thread]