commit:     6586ae03e438478e8c2db09b2355b519043c2760
Author:     sin-ack <sin-ack <AT> protonmail <DOT> com>
AuthorDate: Fri Feb 14 19:46:57 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Feb 16 16:24:54 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6586ae03

dev-lang/zig: guard `stage3` calls when cross-compiling

They can't be run when cross-compiling unless user has qemu static-usr
enabled and used, which we can't check in ebuild. Therefore, we need to
also disallow docs building when cross-compiling for the time being.

Signed-off-by: Eric Joldasov <bratishkaerik <AT> landless-city.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/zig/zig-0.13.0-r3.ebuild | 14 +++++++++++---
 dev-lang/zig/zig-9999.ebuild      | 14 +++++++++++---
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/dev-lang/zig/zig-0.13.0-r3.ebuild 
b/dev-lang/zig/zig-0.13.0-r3.ebuild
index 5d982900f831..97bcdb764771 100644
--- a/dev-lang/zig/zig-0.13.0-r3.ebuild
+++ b/dev-lang/zig/zig-0.13.0-r3.ebuild
@@ -99,6 +99,11 @@ pkg_setup() {
                llvm-r1_pkg_setup
        fi
 
+       # Requires running stage3 which is built for cross-target.
+       if use doc && tc-is-cross-compiler; then
+               die "USE=doc is not yet supported when cross-compiling"
+       fi
+
        check-reqs_pkg_setup
 }
 
@@ -204,10 +209,13 @@ src_compile() {
        cd "${BUILD_DIR}" || die
        ZIG_EXE="./zig2" zig_src_compile --prefix "${BUILD_DIR}/stage3/"
 
-       ./stage3/bin/zig env || die "Zig compilation failed"
+       # Requires running stage3 which is built for cross-target.
+       if ! tc-is-cross-compiler; then
+               ./stage3/bin/zig env || die "Zig compilation failed"
 
-       if use doc; then
-               ZIG_EXE="./stage3/bin/zig" zig_src_compile langref --prefix 
"${S}/docgen/"
+               if use doc; then
+                       ZIG_EXE="./stage3/bin/zig" zig_src_compile langref 
--prefix "${S}/docgen/"
+               fi
        fi
 }
 

diff --git a/dev-lang/zig/zig-9999.ebuild b/dev-lang/zig/zig-9999.ebuild
index dda68889ca43..6b440c6bb88b 100644
--- a/dev-lang/zig/zig-9999.ebuild
+++ b/dev-lang/zig/zig-9999.ebuild
@@ -92,6 +92,11 @@ pkg_setup() {
                llvm-r1_pkg_setup
        fi
 
+       # Requires running stage3 which is built for cross-target.
+       if use doc && tc-is-cross-compiler; then
+               die "USE=doc is not yet supported when cross-compiling"
+       fi
+
        check-reqs_pkg_setup
 }
 
@@ -197,10 +202,13 @@ src_compile() {
        cd "${BUILD_DIR}" || die
        ZIG_EXE="./zig2" zig_src_compile --prefix "${BUILD_DIR}/stage3/"
 
-       ./stage3/bin/zig env || die "Zig compilation failed"
+       # Requires running stage3 which is built for cross-target.
+       if ! tc-is-cross-compiler; then
+               ./stage3/bin/zig env || die "Zig compilation failed"
 
-       if use doc; then
-               ZIG_EXE="./stage3/bin/zig" zig_src_compile langref --prefix 
"${S}/docgen/"
+               if use doc; then
+                       ZIG_EXE="./stage3/bin/zig" zig_src_compile langref 
--prefix "${S}/docgen/"
+               fi
        fi
 }
 

Reply via email to