From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7308C1581F0 for ; Wed, 08 Jan 2025 06:33:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 25F2DE0821; Wed, 08 Jan 2025 06:33:41 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DEBBEE07D7 for ; Wed, 08 Jan 2025 06:33:40 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C636C340C7F for ; Wed, 08 Jan 2025 06:33:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 025721D3B for ; Wed, 08 Jan 2025 06:33:38 +0000 (UTC) From: "Joonas Niilola" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Joonas Niilola" Message-ID: <1736317979.33f22ac2fd51aa5ad16ffd1840f0349ad8a2984f.juippis@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/zig-utils.eclass X-VCS-Directories: eclass/ X-VCS-Committer: juippis X-VCS-Committer-Name: Joonas Niilola X-VCS-Revision: 33f22ac2fd51aa5ad16ffd1840f0349ad8a2984f X-VCS-Branch: master Date: Wed, 08 Jan 2025 06:33:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 52147fac-db55-4706-b737-1995ae402958 X-Archives-Hash: a6f0e7c17eb2e8d422b4f831dfa41d67 commit: 33f22ac2fd51aa5ad16ffd1840f0349ad8a2984f Author: sin-ack protonmail com> AuthorDate: Thu Jan 2 15:59:57 2025 +0000 Commit: Joonas Niilola gentoo org> CommitDate: Wed Jan 8 06:32:59 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=33f22ac2 zig-utils.eclass: add ZIG_NEEDS_LLVM variable If set to a non-empty value, the package will BDEPEND on a Zig package with LLVM enabled. This is currently required for packages that require C/C++ source files to be compiled with Zig. There's some special logic required to detect which Zig binary we should actually use, because we may have dev-lang/zig[-llvm] installed with dev-lang/zig-bin (in which case we would need to pick zig-bin over zig). Tested in a clean stage3 chroot with dev-lang/zig[-llvm] and dev-lang/zig-bin installed, in which case zig-utils.eclass will pick zig-bin over zig. Co-authored-by: Eric Joldasov landless-city.net> Signed-off-by: sin-ack protonmail.com> Signed-off-by: Joonas Niilola gentoo.org> eclass/zig-utils.eclass | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/eclass/zig-utils.eclass b/eclass/zig-utils.eclass index ca72e89ed6ea..5502d997935e 100644 --- a/eclass/zig-utils.eclass +++ b/eclass/zig-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 2024 Gentoo Authors +# Copyright 2024-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: zig-utils.eclass @@ -54,6 +54,14 @@ inherit edo flag-o-matic linux-info # and most likely changed to more common in other eclasses ZIG_MIN/ # ZIG_MAX form. +# @ECLASS_VARIABLE: ZIG_NEEDS_LLVM +# @PRE_INHERIT +# @DEFAULT_UNSET +# @DESCRIPTION: +# If set to a non-empty value, the package will BDEPEND on a Zig package +# with LLVM enabled. This is currently required for packages that require +# C/C++ source files to be compiled with Zig. + # @ECLASS_VARIABLE: ZIG_OPTIONAL # @PRE_INHERIT # @DEFAULT_UNSET @@ -69,9 +77,15 @@ inherit edo flag-o-matic linux-info # For zig.eclass users: see documentation in zig.eclass # instead. if [[ ! ${ZIG_OPTIONAL} ]]; then + _ZIG_USEDEP="" + if [[ ${ZIG_NEEDS_LLVM} ]]; then + _ZIG_USEDEP="[llvm(+)]" + fi + + # NOTE: zig-bin is always built with LLVM support, so no USE needed. BDEPEND=" || ( - dev-lang/zig:${ZIG_SLOT} + dev-lang/zig:${ZIG_SLOT}${_ZIG_USEDEP} dev-lang/zig-bin:${ZIG_SLOT} ) " @@ -440,6 +454,10 @@ zig-utils_find_installation() { local base_path="${BROOT}/usr/bin" + local -x ZIG_GLOBAL_CACHE_DIR="${T}/zig-detect" + mkdir -p "${ZIG_GLOBAL_CACHE_DIR}" || die + touch "${ZIG_GLOBAL_CACHE_DIR}/empty.zig" || die + local selected_path selected_ver for selected_ver in "${zig_supported_versions[@]}"; do # Check if candidate satisfies ZIG_SLOT condition. @@ -451,6 +469,9 @@ zig-utils_find_installation() { local candidate_path for candidate_path in "${base_path}"/zig{,-bin}-"${selected_ver}"; do if [[ -x "${candidate_path}" ]]; then + if [[ ${ZIG_NEEDS_LLVM} ]]; then + "${candidate_path}" test -fllvm -OReleaseSmall "${ZIG_GLOBAL_CACHE_DIR}/empty.zig" &> /dev/null || continue + fi selected_path="${candidate_path}" break 2 fi