* [bug#62105] [PATCH] gnu: zig: make zig build for a baseline cpu
@ 2023-03-10 22:01 Ekaitz Zarraga
2023-03-10 21:52 ` [bug#62105] [PATCH v2] gnu: zig: Build against a baseline CPU Ekaitz Zarraga
2023-03-11 10:10 ` [bug#62105] [PATCH] gnu: zig: make zig build for a baseline cpu pukkamustard
0 siblings, 2 replies; 5+ messages in thread
From: Ekaitz Zarraga @ 2023-03-10 22:01 UTC (permalink / raw)
To: 62105
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@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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#62105] [PATCH v2] gnu: zig: Build against a baseline CPU.
2023-03-10 22:01 [bug#62105] [PATCH] gnu: zig: make zig build for a baseline cpu Ekaitz Zarraga
@ 2023-03-10 21:52 ` Ekaitz Zarraga
2023-03-12 10:01 ` Ekaitz Zarraga
2023-03-11 10:10 ` [bug#62105] [PATCH] gnu: zig: make zig build for a baseline cpu pukkamustard
1 sibling, 1 reply; 5+ messages in thread
From: Ekaitz Zarraga @ 2023-03-10 21:52 UTC (permalink / raw)
To: 62105; +Cc: Ekaitz Zarraga
* gnu/packages/zig.scm (zig-0.10)[#:configure-flags]: Add
“-DZIG_TARGET_MCPU=baseline”.
Signed-off-by: Liliana Marie Prikler <liliana.prikler@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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#62105] [PATCH v2] gnu: zig: Build against a baseline CPU.
2023-03-10 21:52 ` [bug#62105] [PATCH v2] gnu: zig: Build against a baseline CPU Ekaitz Zarraga
@ 2023-03-12 10:01 ` Ekaitz Zarraga
2023-03-19 8:28 ` bug#62105: " Liliana Marie Prikler
0 siblings, 1 reply; 5+ messages in thread
From: Ekaitz Zarraga @ 2023-03-12 10:01 UTC (permalink / raw)
To: Ekaitz Zarraga; +Cc: 62105
Thank you Liliana, and sorry for the inconvenience.
------- Original Message -------
On Friday, March 10th, 2023 at 9:52 PM, Ekaitz Zarraga <liliana.prikler@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@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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [bug#62105] [PATCH] gnu: zig: make zig build for a baseline cpu
2023-03-10 22:01 [bug#62105] [PATCH] gnu: zig: make zig build for a baseline cpu Ekaitz Zarraga
2023-03-10 21:52 ` [bug#62105] [PATCH v2] gnu: zig: Build against a baseline CPU Ekaitz Zarraga
@ 2023-03-11 10:10 ` pukkamustard
1 sibling, 0 replies; 5+ messages in thread
From: pukkamustard @ 2023-03-11 10:10 UTC (permalink / raw)
To: Ekaitz Zarraga; +Cc: 62105
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@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@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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-19 8:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 22:01 [bug#62105] [PATCH] gnu: zig: make zig build for a baseline cpu Ekaitz Zarraga
2023-03-10 21:52 ` [bug#62105] [PATCH v2] gnu: zig: Build against a baseline CPU Ekaitz Zarraga
2023-03-12 10:01 ` Ekaitz Zarraga
2023-03-19 8:28 ` bug#62105: " Liliana Marie Prikler
2023-03-11 10:10 ` [bug#62105] [PATCH] gnu: zig: make zig build for a baseline cpu pukkamustard
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).