🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.gentoo.dev
4 messages
4 total messages Started by Violet Purcell Thu, 05 Nov 2026 17:20
[gentoo-dev] [PATCH 1/4] eclass/zig.eclass: Update libc info generation for 0.17
#107
Author: Violet Purcell
Date: Thu, 05 Nov 2026 17:20
129 lines
5707 bytes
From: Eric Joldasov <bratishkaerik@landless-city.net>

Extract libc info generation to separate function.

Add new fields for zig_libc.txt as per latest upstream changes:
* https://codeberg.org/ziglang/zig/pulls/36951
* https://codeberg.org/ziglang/zig/pulls/36942

Co-Authored-By: Violet Purcell <vi@vimproved.dev>
Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
Signed-off-by: Violet Purcell <vi@vimproved.dev>
---
 eclass/zig.eclass | 87 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 68 insertions(+), 19 deletions(-)

diff --git a/eclass/zig.eclass b/eclass/zig.eclass
index 1c577c05a996..305d21a57653 100644
--- a/eclass/zig.eclass
+++ b/eclass/zig.eclass
@@ -54,7 +54,7 @@ case ${EAPI} in
 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
-inherit multiprocessing zig-utils
+inherit multiprocessing toolchain-funcs zig-utils
 
 # @ECLASS_VARIABLE: ZIG_OPTIONAL
 # @PRE_INHERIT
@@ -244,6 +244,72 @@ zig_get_jobs() {
 	fi
 }
 
+# @FUNCTION: _zig_write_libc_txt
+# @INTERNAL
+# @USAGE: <output_file_path>
+# @DESCRIPTION:
+# Generates the zig_libc.txt configuration file based on the target C compiler
+# information and writes it to the specified target path.
+_zig_write_libc_txt() {
+	[[ -z ${1} ]] && die "${ECLASS}: ${FUNCNAME}: missing required argument"
+	local output_file="${1}"
+
+	# Sync with the output format of `zig libc`.
+	# TODO maybe add to upstream to use ZON format instead...
+	# Will also help "https://github.com/ziglang/zig/issues/20327",
+	# and hopefully will respect our settings too.
+
+	local cc crt1_path libgcc_path
+	cc="$(tc-getCC)"
+	# Omitted CFLAGS here, because for cases where location changes
+	# (say, multilib with "-m32" flag) Zig does not support them.
+	# So there will be danger of desync-ed object formats.
+	libgcc_path="$("${cc}" --print-libgcc-file-name)"
+	crt1_path="$("${cc}" --print-file-name=crt1.o)"
+
+	# Check if file paths are absolute and files exists
+	if [[ "${libgcc_path}" != /* || ! -f "${libgcc_path}" ]]; then
+		die "${ECLASS}: Failed to provide Zig libc info"
+	fi
+	if [[ "${crt1_path}" != /* || ! -f "${crt1_path}" ]]; then
+		die "${ECLASS}: Failed to provide Zig libc info"
+	fi
+
+	local crtbegin_dir="${libgcc_path%/*}"
+	local crt1_dir="${crt1_path%/*}"
+	# Note: paths from "--libc" are not prepended by "--sysroot" value,
+	# so repeat prefix here.
+	local include_dir="${ESYSROOT}/usr/include"
+
+	# No quotes here, paths are interpreted verbatim.
+	if ver_test "${ZIG_SLOT}" -ge "0.17"; then
+		# https://codeberg.org/ziglang/zig/src/commit/da561521dd78dcde03fc51de8fd64551b368f56d/lib/std/zig/LibCInstallation.zig#L136-L165
+		cat <<- _EOF_ > "${output_file}" || die "Failed to provide Zig libc info"
+			include_dir=${include_dir}
+			sys_include_dir=${include_dir}
+			cc_dir=${crtbegin_dir}
+			crt_dir=${crt1_dir}
+			# Windows with MSVC only.
+			msvc_lib_dir=
+			kernel32_lib_dir=
+			# Darwin only.
+			darwin_sdk_dir=
+		_EOF_
+	else
+		# https://codeberg.org/ziglang/zig/src/tag/0.16.0/lib/std/zig/LibCInstallation.zig#L133-L158
+		cat <<- _EOF_ > "${output_file}" || die "Failed to provide Zig libc info"
+			include_dir=${include_dir}
+			sys_include_dir=${include_dir}
+			crt_dir=${crt1_dir}
+			# Windows with MSVC only.
+			msvc_lib_dir=
+			kernel32_lib_dir=
+			# Haiku only.
+			gcc_dir=
+		_EOF_
+	fi
+}
+
 # @FUNCTION: zig_init_base_args
 # @DESCRIPTION:
 # Stores basic args for future "ezig build" calls in ZBS_ARGS_BASE.
@@ -272,24 +338,7 @@ zig_get_jobs() {
 zig_init_base_args() {
 	[[ "${ZBS_ARGS_BASE}" ]] && return
 
-	# Sync with the output format of `zig libc`.
-	# TODO maybe add to upstream to use ZON format instead...
-	# Will also help "https://github.com/ziglang/zig/issues/20327",
-	# and hopefully will respect our settings too.
-	cat <<- _EOF_ > "${T}/zig_libc.txt" || die "Failed to provide Zig libc info"
-		# Note: they are not prepended by "--sysroot" value,
-		# so repeat it here.
-		# Also, no quotes here, they are interpreted verbatim.
-		include_dir=${ESYSROOT}/usr/include/
-		sys_include_dir=${ESYSROOT}/usr/include/
-		crt_dir=${ESYSROOT}/usr/$(get_libdir)/
-		# Windows with MSVC only.
-		msvc_lib_dir=
-		# Windows with MSVC only.
-		kernel32_lib_dir=
-		# Haiku only.
-		gcc_dir=
-	_EOF_
+	_zig_write_libc_txt "${T}/zig_libc.txt"
 
 	declare -g -a ZBS_ARGS_BASE=(
 		-j$(zig_get_jobs)
-- 
2.56.0
[gentoo-dev] [PATCH 2/4] zig.eclass: set crt{begin,end}_obj in _zig_write_libc_txt
#104
Author: Violet Purcell
Date: Thu, 05 Nov 2026 17:20
39 lines
2786 bytes
These are needed for systems without GCC for zig to find
crtbegin/crtend, as they do not follow a standard naming convention.

Upstream-Bug: https://codeberg.org/ziglang/zig/issues/36919
Signed-off-by: Violet Purcell <vi@vimproved.dev>
---
 eclass/zig.eclass | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/eclass/zig.eclass b/eclass/zig.eclass
index 305d21a57653..e9aa4e59301c 100644
--- a/eclass/zig.eclass
+++ b/eclass/zig.eclass
@@ -281,6 +281,14 @@ _zig_write_libc_txt() {
 	# so repeat prefix here.
 	local include_dir="${ESYSROOT}/usr/include"
 
+	local crtbegin_obj="crtbeginS.o"
+	local crtend_obj="crtendS.o"
+	if [[ "$(tc-get-c-rtlib)" = "compiler-rt" ]]; then
+		local host=${CTARGET:-${CHOST}}
+		crtbegin_obj="clang_rt.crtbegin-${host%%-*}.o"
+		crtend_obj="clang_rt.crtend-${host%%-*}.o"
+	fi
+
 	# No quotes here, paths are interpreted verbatim.
 	if ver_test "${ZIG_SLOT}" -ge "0.17"; then
 		# https://codeberg.org/ziglang/zig/src/commit/da561521dd78dcde03fc51de8fd64551b368f56d/lib/std/zig/LibCInstallation.zig#L136-L165
@@ -289,6 +297,8 @@ _zig_write_libc_txt() {
 			sys_include_dir=${include_dir}
 			cc_dir=${crtbegin_dir}
 			crt_dir=${crt1_dir}
+			crtbegin_obj=${crtbegin_obj}
+			crtend_obj=${crtend_obj}
 			# Windows with MSVC only.
 			msvc_lib_dir=
 			kernel32_lib_dir=
-- 
2.56.0
[gentoo-dev] [PATCH 3/4] zig.eclass: use --save-exact in zig fetch
#105
Author: Violet Purcell
Date: Thu, 05 Nov 2026 17:20
24 lines
2196 bytes
In 0.17.0, zig fetch changed its behavior so that it only copies to
zig-pkgs if the source is in build.zig.zon verbatim. Work around this by
using --save-exact=[name] when fetching.

Signed-off-by: Violet Purcell <vi@vimproved.dev>
---
 eclass/zig.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/zig.eclass b/eclass/zig.eclass
index e9aa4e59301c..0fe921c1f362 100644
--- a/eclass/zig.eclass
+++ b/eclass/zig.eclass
@@ -513,7 +513,7 @@ zig_src_unpack() {
 		touch build.zig || die
 		for zig_dep in "${zig_deps[@]}"; do
 			# Hide now-spammy hash from stdout
-			ezig fetch "${DISTDIR}/${zig_dep}" > /dev/null
+			ezig fetch --save-exact="${zig_dep##-*}" "${DISTDIR}/${zig_dep}" > /dev/null
 		done
 
 		# For 0.17 and later:
-- 
2.56.0
[gentoo-dev] [PATCH 4/4] zig-utils.eclass: add 0.17.1 to supported versions
#106
Author: Violet Purcell
Date: Thu, 05 Nov 2026 17:20
19 lines
1824 bytes
Signed-off-by: Violet Purcell <vi@vimproved.dev>
---
 eclass/zig-utils.eclass | 1 +
 1 file changed, 1 insertion(+)

diff --git a/eclass/zig-utils.eclass b/eclass/zig-utils.eclass
index 8ed9cc55ab9b..b3a7ffc5efaa 100644
--- a/eclass/zig-utils.eclass
+++ b/eclass/zig-utils.eclass
@@ -512,6 +512,7 @@ zig-utils_find_installation() {
 	# Upstream skipped releasing 0.15.0
 	local zig_supported_versions=(
 		"9999"
+		"0.17.1"
 		"0.16.0"
 		"0.15.2"
 		"0.15.1"
-- 
2.56.0
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads