From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id QHWXHCU4bGVwYQAAG6o9tA:P1 (envelope-from ) for ; Sun, 03 Dec 2023 09:11:17 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QHWXHCU4bGVwYQAAG6o9tA (envelope-from ) for ; Sun, 03 Dec 2023 09:11:17 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DF9AB10C8F for ; Sun, 3 Dec 2023 09:11:16 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=I5qnWxOS; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1701591077; a=rsa-sha256; cv=none; b=u3VnwfLs+K+4EgR9Erp5bEnZOA/MV8kLBO5Gbk8y9J2lYgL9q52RDSV2mlktHwl2B9xLwg W+EQ+E8k9gjWxhVag5/hWZcndXuU2a9Oj0MVjPTb3k1U/Fk5mv+/eXxXOwk524J5/eUPCH gS5udeQjUGzUYVhBlfq6+zWzWxHZv9O/OBEORX7wgM0veasbhS1/lXDaSjK3U0VSJnMkfi l4tkkrUHFPHQb1HMdl0sk68K2r+fXJAKTLGWevcdhYMxAcu8w5zJjx21RIr2/kDTBKZbqn n1EEueMly9kCfjU/vFjflqg78+9UXzZKpDrNnLL++wgXP0ZeAEDwVSCY7eAW1w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=I5qnWxOS; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1701591077; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-to:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=WlANT2YuNvu3l4Nxc2Fg2xY+j07qXMn96RbYb7EDXo8=; b=hXke3iKazyiDZLY/kzMqinDSNApMfX3Ki+L6fiVKsb1jN9+Sk4PdHrXzZ0FjVVUtvB1Lp+ dONBeWlf57L20vKRu3O58RDE8BFSy8Qyn1wUwiK9frdvrjzniNZy6AB8hpvKm6QLK0bxvk 44KEhUKsXdJv4ntL+C+7t00sS3kUjAkm++FmFyipA1AXRNIgu94Azrg0XWb8duNK6tbF4k hjCBryDjGe4Do+C43dtRH54BF6vPQNeapx2J1n+mVddwUaYT+m2KSJgMn+LspYvm+pwj/1 C4MVYejGBTX0boCNb7mgOTf2FYAtjJo/qZHXp4YAW+wkjo+pP0hbykhJVqKd/A== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9hZA-0005I9-IC; Sun, 03 Dec 2023 03:11:05 -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 1r9hYz-0005HD-2a for guix-patches@gnu.org; Sun, 03 Dec 2023 03:10:54 -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 1r9hYy-0002SV-JC for guix-patches@gnu.org; Sun, 03 Dec 2023 03:10:52 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r9hZ7-00032h-VX for guix-patches@gnu.org; Sun, 03 Dec 2023 03:11:01 -0500 Subject: bug#67075: [PATCH] build: zig-build-system: Add CPU option Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Sun, 03 Dec 2023 08:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 67075 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ekaitz Zarraga Cc: 67075-done@debbugs.gnu.org Received: via spool by 67075-done@debbugs.gnu.org id=D67075.170159102111644 (code D ref 67075); Sun, 03 Dec 2023 08:11:01 +0000 Received: (at 67075-done) by debbugs.gnu.org; 3 Dec 2023 08:10:21 +0000 Received: from localhost ([127.0.0.1]:59076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9hYS-00031k-VU for submit@debbugs.gnu.org; Sun, 03 Dec 2023 03:10:21 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:59568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9hYP-00031T-NP for 67075-done@debbugs.gnu.org; Sun, 03 Dec 2023 03:10:19 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40c09fcfa9fso1416845e9.2 for <67075-done@debbugs.gnu.org>; Sun, 03 Dec 2023 00:10:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701591001; x=1702195801; darn=debbugs.gnu.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to :cc:subject:date:message-id:reply-to; bh=WlANT2YuNvu3l4Nxc2Fg2xY+j07qXMn96RbYb7EDXo8=; b=I5qnWxOS99/D1tl3lGsY0Xkahwm7JK5vnP1YDSii7nmfDFKM3ugzo4dG5dVWvh8YiO 3crN1xzEfgrtnNpSaZiLB2LPEheP8ARb6T06vjSqnbksZvYVAhzCLceVk+qLFVNgqKFr T0vgP0+W6ZxjoOv/YnFlVS6kxSFwSa9Rh1K0PF8OowMSb3np9iQhYsO2fHHJMCxJSko5 Aj02wneIUBJ8HWu6XDE/0EH8MD7IlJumOEGFdTBUtNjp2Fn2WitswLy9XjR82XRM0iVa HSPkG9NyQIYtVlbh1VCKFMgWl4FjM5JXCpjif2lXMjdzMAzAj6qodQ1ycSeXeMIFZ1g+ vScQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701591001; x=1702195801; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WlANT2YuNvu3l4Nxc2Fg2xY+j07qXMn96RbYb7EDXo8=; b=qFFjv3BdNP8VsGqBIZObuZnq63kF9b2qcF4zBCw0hnEEZTwTbnhjtLeqdL3mfwPK08 2jX8mF69a6tYVgU3OYS9YuJXSIvgx6+tbC/w955o+O2ex/j/5wCur0UiqCRjimKpAxnY 5F+44sc9nIpDLfV7X8C3IqfSMbynLFnPjLe12PkRCi8ANaz8ZHxj6gJybGqQR+RVUrHm 6qENrlSPkgt3uqpc0wv2puuwA9nbq04HOyqAg1CnwMl+z/4LXBhNUr3Oc0TD/xMicG0Q xQnSMAdI7kLAKD7IVrwTq/R3qAuzQVXYOHpTiG5TV3tLvunqO5/Bn8aU+DRAX1DnvQR9 ycIQ== X-Gm-Message-State: AOJu0Yyxb9NkEDgojyvJdcoWRZi+JDOVMKX0Xxzek+pJZkSdOspqEg5v 9y2TaUeesYx3R06k5K95Uuo= X-Google-Smtp-Source: AGHT+IHL7JaWQoDaRuwZKHBf3UGSRHIq8eNPWVq8tOjKnD3tpi/rJp1zpaccvRL33xezTjcy6km9aw== X-Received: by 2002:adf:fa4a:0:b0:333:3117:c412 with SMTP id y10-20020adffa4a000000b003333117c412mr1004408wrr.163.1701591000408; Sun, 03 Dec 2023 00:10:00 -0800 (PST) Received: from localhost ([188.120.129.233]) by smtp.gmail.com with ESMTPSA id o3-20020a5d6843000000b0033340d2b127sm1532584wrw.89.2023.12.03.00.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 00:09:59 -0800 (PST) Date: Sun, 3 Dec 2023 10:09:57 +0200 From: Efraim Flashner Message-ID: Mail-Followup-To: Efraim Flashner , Ekaitz Zarraga , 67075-done@debbugs.gnu.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="YpBa3JUG12uTWWoR" Content-Disposition: inline In-Reply-To: X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -3.75 X-Spam-Score: -3.75 X-Migadu-Queue-Id: DF9AB10C8F X-TUID: 5E9LaFcePm2m --YpBa3JUG12uTWWoR Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Patch applied with a couple of helper patches. Some comments inline. On Sat, Nov 18, 2023 at 05:51:09PM +0100, Ekaitz Zarraga wrote: > Hi, >=20 > Following Efraim's suggestion I arranged a new patch around the tuning > option. I needed to patch Zig itself to use baseline cpu by default, which > is safer in general for us. >=20 > If anyone need a more specific cpu, can use the tuning option to choose i= t. >=20 > Maybe I should split the changes in Zig and the tuning system, but if I do > they wont appear together, and they mostly only make sense if applied at > once. I split the patch and applied the one adjusting zig to use -Dcpu=3Dbaseline first. > Please let me know if you like this one better. >=20 > Hope it's cool. >=20 > Cheers, > Ekaitz > From 03616b9764278e05d74f8e8bf5d65b043603a437 Mon Sep 17 00:00:00 2001 > Message-ID: <03616b9764278e05d74f8e8bf5d65b043603a437.1700325640.git.ekai= tz@elenq.tech> > From: Ekaitz Zarraga > Date: Sat, 18 Nov 2023 17:29:07 +0100 > Subject: [PATCH] gnu: zig: Make compiler tunable. >=20 > In order to make Zig tunable, we have to make sure by default it does > the right thing, that is use the `baseline` CPU instead of the `native` > one because the tuning system only adds an extra flag to the compiler > command line execution. >=20 > * gnu/packages/patches/zig-use-baseline-cpu-by-default.patch: Add file. > * gnu/packages/zig.scm(zig-0.10.1): Apply patch above. > * guix/transformations.scm(tuning-compiler): Add support for zig. Missing a change for gnu/local.mk > Change-Id: I40bd28071c97c0dd0a907c704072b52b26d2de28 > --- > .../zig-use-baseline-cpu-by-default.patch | 36 +++++++++++++++++++ > gnu/packages/zig.scm | 3 +- > guix/transformations.scm | 22 ++++++++---- > 3 files changed, 54 insertions(+), 7 deletions(-) > create mode 100644 gnu/packages/patches/zig-use-baseline-cpu-by-default.= patch >=20 > 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 > +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=3Dwhatever` 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=3Dbaseline` 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=3Dbaseline` flag in the zig-build-system and we c= an > +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 =3D std.mem; > + /// `null` means native. > + cpu_arch: ?Target.Cpu.Arch =3D null, > +=20 > +-cpu_model: CpuModel =3D CpuModel.determined_by_cpu_arch, > ++cpu_model: CpuModel =3D CpuModel.baseline, > +=20 > + /// Sparse set of CPU features to add to the set from `cpu_model`. > + cpu_features_add: Target.Cpu.Feature.Set =3D Target.Cpu.Feature.Set.emp= ty, > +--=20 > +2.41.0 > + > diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm > index dcca9a1121..82b83f44c2 100644 > --- a/gnu/packages/zig.scm > +++ b/gnu/packages/zig.scm > @@ -42,7 +42,8 @@ (define-public zig-0.10 > (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-Dcpu-baseline-by-default.patch"= )))) > (build-system cmake-build-system) > (inputs > (list clang-15 ; Clang propagates llvm. > diff --git a/guix/transformations.scm b/guix/transformations.scm > index 9cba6bedab..8964feb046 100644 > --- a/guix/transformations.scm > +++ b/guix/transformations.scm > @@ -439,7 +439,8 @@ (define tuning-compiler > actual compiler." > (define wrapper > #~(begin > - (use-modules (ice-9 match)) > + (use-modules (ice-9 match) > + (ice-9 string-fun)) > =20 > (define psabi #$(gcc-architecture->micro-architecture-level > micro-architecture)) > @@ -486,11 +487,20 @@ (define tuning-compiler > (apply > execl next > (append (cons next arguments) > - (if (and (search-next "go") > + (cond > + ((and (search-next "go") > (string=3D? next (search-next "go"))) > - '() > - (list (string-append "-march=3D" > - #$micro-architecture))))= ))))))) > + '()) > + ((and (search-next "zig") > + (string=3D? next (search-next "zig")) Indentation is off, the and should end with string=3D? > + (list (string-append This I changed to `(,(string-append, otherwise it complains about receiving a list instead of a string. > + ;; https://issues.guix.gnu.org/67075= #3 > + "-Dcpu=3D" > + (string-replace-substring > + #$micro-architecture "-" "_"))))) > + (else > + (list (string-append "-march=3D" > + #$micro-architecture)))))))))))) > =20 > (define program > (program-file (string-append "tuning-compiler-wrapper-" micro-arch= itecture) > @@ -508,7 +518,7 @@ (define tuning-compiler > (symlink #$program > (string-append bin "/" pro= gram))) > '("cc" "gcc" "clang" "g++" "c++" "cla= ng++" > - "go"))))))) > + "go" "zig"))))))) > =20 > (define (build-system-with-tuning-compiler bs micro-architecture) > "Return a variant of BS, a build system, that ensures that the compile= r that >=20 > base-commit: a514973413dc8179100ef8f0fcf41f5ac38c982f > --=20 > 2.41.0 >=20 --=20 Efraim Flashner =D7=A8=D7=A0=D7=A9=D7=9C=D7=A4 = =D7=9D=D7=99=D7=A8=D7=A4=D7=90 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --YpBa3JUG12uTWWoR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmVsN9MACgkQQarn3Mo9 g1FmJg//XYv0thJ4Txr3AlGN8OgfcW3Ov/spWXgNvVavtkDDvSAwcIICfKVKip8C vlYfr0HjmNAdIvKXpdjFF8BRJTSehYDyqATVHL+nhY3etPcxbaY1Yvmw9WBiFOq3 mHxi+GXscAIARCuoXtJqgLc7ikKWJvc3vHUn7LGaX6PJL88FJhGSyW68QgSKgFIG Eu2u1+TtxLk1IdyEepPPck8NCX1SHACirKpNxdxGpTB0im3/AlZCOuT+gUVJa4LY NoQOcn8lZFaYmeW7sbIurpSysBDXUpXHTL1K0W39FDwAd/y0UV1i5QEbwpcsXYSr fcvUrrW2Bnypo9ZmlJDGH36WJQIKBhJosyUTTa6vMyMd1cmVpyeh+gCBsFQZSZrP mvNkhA9PLT20xSD5P76CbI9y0Ige7bgBE3EnHOqJeH1lCg8bUpZEXHDu9wiqIEdV tBhgCHAN/FzsNK5pHYiBksYOUdAkFJgFrtavpopKxvt7ITQ+VH4TxWKxTBhutEYM R+wK/Tz/5Rc7vGQ3id/+CsW54OqskJWnCjj/TNePUVFmdhiNsbWBXoJhUtNXxoz+ cRKYgNeLCYUWzUgyAvn4Xg1uQJX94BesT31oIiOA9JusRVlv7jGoTFQt7qbcNRly k6oNatI7yfKLAZudiER1eAIb+6k1sbg3RuWVOaLgD0qC+5UEyts= =wF2x -----END PGP SIGNATURE----- --YpBa3JUG12uTWWoR--