GNU bug report logs - #62105
[PATCH] gnu: zig: make zig build for a baseline cpu

Previous Next

Package: guix-patches;

Reported by: Ekaitz Zarraga <ekaitz <at> elenq.tech>

Date: Fri, 10 Mar 2023 22:02:02 UTC

Severity: normal

Tags: patch

Done: Liliana Marie Prikler <liliana.prikler <at> gmail.com>

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 62105 in the body.
You can then email your comments to 62105 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#62105; Package guix-patches. (Fri, 10 Mar 2023 22:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ekaitz Zarraga <ekaitz <at> elenq.tech>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 10 Mar 2023 22:02:02 GMT) Full text and rfc822 format available.

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

From: Ekaitz Zarraga <ekaitz <at> elenq.tech>
To: "guix-patches <at> gnu.org" <guix-patches <at> gnu.org>
Subject: [PATCH] gnu: zig: make zig build for a baseline cpu
Date: Fri, 10 Mar 2023 22:01:12 +0000
This patch fixes a `Illegal instruction` issue when running Zig.
It happens because Zig compiles with optimizations for the current
machine, which may add instructions that are not compatible with
some target machines. This flag makes it build for a baseline cpu.

Tested with:

qemu-x86_64 -cpu Broadwell-v2 /gnu/store/zzi23y4mab8zl58hdd740xz3814vy24w-zig-0.10.1/bin/zig build

And:
qemu-x86_64 -cpu Broadwell-v4 /gnu/store/zzi23y4mab8zl58hdd740xz3814vy24w-zig-0.10.1/bin/zig build

It worked.
It follows what Arch does:
https://github.com/archlinux/svntogit-community/blob/31055e6750a5672ebbd85114fe7a93163f8af575/trunk/PKGBUILD#L30
And NixOS:
https://github.com/NixOS/nixpkgs/pull/215994/commits/26b9a2f4a1a53e6763aa83590aad0fce5013a458

Hope this helps.
Best,
Ekaitz


---

From 8dbb801ba7df6cc64c003e8f1739117c8dda6a75 Mon Sep 17 00:00:00 2001
From: Ekaitz Zarraga <ekaitz <at> elenq.tech>
Date: Fri, 10 Mar 2023 22:52:19 +0100
Subject: [PATCH] gnu: zig: make zig build for a baseline cpu

* gnu/packages/zig.scm(zig-0.10): Add -DZIG_TARGET_MCPU=baseline
  configure flag.
---
 gnu/packages/zig.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index 5414b5ba6e..2c89343cb1 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -56,6 +56,7 @@ (define-public zig-0.10
                    '(string-append "-DZIG_TARGET_TRIPLE="
                                    (%current-target-system))
                    '())
+             (string-append "-DZIG_TARGET_MCPU=baseline")
              (string-append "-DZIG_LIB_DIR=" (assoc-ref %outputs "out")
                             "/lib/zig"))
        #:validate-runpath? #f       ; TODO: zig binary can't find ld-linux.
--
2.39.1




Information forwarded to guix-patches <at> gnu.org:
bug#62105; Package guix-patches. (Sat, 11 Mar 2023 10:15:02 GMT) Full text and rfc822 format available.

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

From: pukkamustard <pukkamustard <at> posteo.net>
To: Ekaitz Zarraga <ekaitz <at> elenq.tech>
Cc: 62105 <at> debbugs.gnu.org
Subject: Re: [bug#62105] [PATCH] gnu: zig: make zig build for a baseline cpu
Date: Sat, 11 Mar 2023 10:10:42 +0000
I managed to build Zig with your patch applied. From what I understand
this is a good fix to the issue.

lgtm and thanks!

-pukkamustard


Ekaitz Zarraga <ekaitz <at> elenq.tech> writes:

> This patch fixes a `Illegal instruction` issue when running Zig.
> It happens because Zig compiles with optimizations for the current
> machine, which may add instructions that are not compatible with
> some target machines. This flag makes it build for a baseline cpu.
>
> Tested with:
>
> qemu-x86_64 -cpu Broadwell-v2 /gnu/store/zzi23y4mab8zl58hdd740xz3814vy24w-zig-0.10.1/bin/zig build
>
> And:
> qemu-x86_64 -cpu Broadwell-v4 /gnu/store/zzi23y4mab8zl58hdd740xz3814vy24w-zig-0.10.1/bin/zig build
>
> It worked.
> It follows what Arch does:
> https://github.com/archlinux/svntogit-community/blob/31055e6750a5672ebbd85114fe7a93163f8af575/trunk/PKGBUILD#L30
> And NixOS:
> https://github.com/NixOS/nixpkgs/pull/215994/commits/26b9a2f4a1a53e6763aa83590aad0fce5013a458
>
> Hope this helps.
> Best,
> Ekaitz
>
>
> ---
>
> From 8dbb801ba7df6cc64c003e8f1739117c8dda6a75 Mon Sep 17 00:00:00 2001
> From: Ekaitz Zarraga <ekaitz <at> elenq.tech>
> Date: Fri, 10 Mar 2023 22:52:19 +0100
> Subject: [PATCH] gnu: zig: make zig build for a baseline cpu
>
> * gnu/packages/zig.scm(zig-0.10): Add -DZIG_TARGET_MCPU=baseline
>   configure flag.
> ---
>  gnu/packages/zig.scm | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
> index 5414b5ba6e..2c89343cb1 100644
> --- a/gnu/packages/zig.scm
> +++ b/gnu/packages/zig.scm
> @@ -56,6 +56,7 @@ (define-public zig-0.10
>                     '(string-append "-DZIG_TARGET_TRIPLE="
>                                     (%current-target-system))
>                     '())
> +             (string-append "-DZIG_TARGET_MCPU=baseline")
>               (string-append "-DZIG_LIB_DIR=" (assoc-ref %outputs "out")
>                              "/lib/zig"))
>         #:validate-runpath? #f       ; TODO: zig binary can't find ld-linux.





Information forwarded to guix-patches <at> gnu.org:
bug#62105; Package guix-patches. (Sun, 12 Mar 2023 08:35:02 GMT) Full text and rfc822 format available.

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

From: Ekaitz Zarraga <liliana.prikler <at> gmail.com>
To: 62105 <at> debbugs.gnu.org
Cc: Ekaitz Zarraga <ekaitz <at> elenq.tech>
Subject: [PATCH v2] gnu: zig: Build against a baseline CPU.
Date: Fri, 10 Mar 2023 22:52:19 +0100
* gnu/packages/zig.scm (zig-0.10)[#:configure-flags]: Add
“-DZIG_TARGET_MCPU=baseline”.

Signed-off-by: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
---
Hi Ekaitz,

Since this patch didn't cleanly apply with ‘git am’, I ran it through
format-patch once again and also edited the commit message.
If CI succeeds, I'll push it as-is on the 19th.

Cheers,
Liliana

 gnu/packages/zig.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index 5414b5ba6e..2c89343cb1 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -56,6 +56,7 @@ (define-public zig-0.10
                    '(string-append "-DZIG_TARGET_TRIPLE="
                                    (%current-target-system))
                    '())
+             (string-append "-DZIG_TARGET_MCPU=baseline")
              (string-append "-DZIG_LIB_DIR=" (assoc-ref %outputs "out")
                             "/lib/zig"))
        #:validate-runpath? #f       ; TODO: zig binary can't find ld-linux.
-- 
2.39.1





Information forwarded to guix-patches <at> gnu.org:
bug#62105; Package guix-patches. (Sun, 12 Mar 2023 10:02:02 GMT) Full text and rfc822 format available.

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

From: Ekaitz Zarraga <ekaitz <at> elenq.tech>
To: Ekaitz Zarraga <liliana.prikler <at> gmail.com>
Cc: 62105 <at> debbugs.gnu.org
Subject: Re: [PATCH v2] gnu: zig: Build against a baseline CPU.
Date: Sun, 12 Mar 2023 10:01:17 +0000
Thank you Liliana, and sorry for the inconvenience.



------- Original Message -------
On Friday, March 10th, 2023 at 9:52 PM, Ekaitz Zarraga <liliana.prikler <at> gmail.com> wrote:


> * gnu/packages/zig.scm (zig-0.10)[#:configure-flags]: Add
> “-DZIG_TARGET_MCPU=baseline”.
> 
> Signed-off-by: Liliana Marie Prikler liliana.prikler <at> gmail.com
> 
> ---
> Hi Ekaitz,
> 
> Since this patch didn't cleanly apply with ‘git am’, I ran it through
> format-patch once again and also edited the commit message.
> If CI succeeds, I'll push it as-is on the 19th.
> 
> Cheers,
> Liliana
> 
> gnu/packages/zig.scm | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
> index 5414b5ba6e..2c89343cb1 100644
> --- a/gnu/packages/zig.scm
> +++ b/gnu/packages/zig.scm
> @@ -56,6 +56,7 @@ (define-public zig-0.10
> '(string-append "-DZIG_TARGET_TRIPLE="
> (%current-target-system))
> '())
> + (string-append "-DZIG_TARGET_MCPU=baseline")
> (string-append "-DZIG_LIB_DIR=" (assoc-ref %outputs "out")
> "/lib/zig"))
> #:validate-runpath? #f ; TODO: zig binary can't find ld-linux.
> --
> 2.39.1




Reply sent to Liliana Marie Prikler <liliana.prikler <at> gmail.com>:
You have taken responsibility. (Sun, 19 Mar 2023 08:29:02 GMT) Full text and rfc822 format available.

Notification sent to Ekaitz Zarraga <ekaitz <at> elenq.tech>:
bug acknowledged by developer. (Sun, 19 Mar 2023 08:29:02 GMT) Full text and rfc822 format available.

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

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Ekaitz Zarraga <ekaitz <at> elenq.tech>
Cc: 62105-done <at> debbugs.gnu.org
Subject: Re: [PATCH v2] gnu: zig: Build against a baseline CPU.
Date: Sun, 19 Mar 2023 09:28:12 +0100
Am Sonntag, dem 12.03.2023 um 10:01 +0000 schrieb Ekaitz Zarraga:
> Thank you Liliana, and sorry for the inconvenience.
No problem.

Pushed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 16 Apr 2023 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 10 days ago.

Previous Next


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