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 432541580FD for ; Sat, 21 Dec 2024 16:02:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2D0DAE09DC; Sat, 21 Dec 2024 16:01:05 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.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 E366DE09D6 for ; Sat, 21 Dec 2024 16:01:04 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 06/11] llvm-r2.eclass: Add llvm_chost_setup, set CMake path variables Date: Sat, 21 Dec 2024 16:48:39 +0100 Message-ID: <20241221160053.780079-7-mgorny@gentoo.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221160053.780079-1-mgorny@gentoo.org> References: <20241221160053.780079-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: e3990c4c-2ac2-4536-8e08-b22134f1903b X-Archives-Hash: a303f7b6c2abc7834cc0f057c4b7e460 Add a llvm_chost_setup function that handles CHOST-specific setup. Initially, this means setting CMake variables that control `find_package()` lookups. Signed-off-by: Michał Górny --- eclass/llvm-r2.eclass | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/eclass/llvm-r2.eclass b/eclass/llvm-r2.eclass index 93c16e75be83..91e841821331 100644 --- a/eclass/llvm-r2.eclass +++ b/eclass/llvm-r2.eclass @@ -248,16 +248,35 @@ llvm_cbuild_setup() { llvm_prepend_path -b "${LLVM_SLOT}" } -# @FUNCTION: llvm-r2_pkg_setup +# @FUNCTION: llvm_chost_setup # @DESCRIPTION: -# Prepend the appropriate executable directory for the selected LLVM -# slot to PATH. +# Set the environment for finding selected LLVM slot installed +# for CHOST. # -# The PATH manipulation is only done for source builds. The function -# is a no-op when installing a binary package. +# This function is meant to be used when the package in question uses +# LLVM compiles against and links to LLVM. It is called automatically +# by llvm-r2_pkg_setup if LLVM is found installed in ESYSROOT. +llvm_chost_setup() { + debug-print-function ${FUNCNAME} "$@" + + local esysroot_prefix=$(get_llvm_prefix -d) + einfo "Using ${esysroot_prefix} for CHOST LLVM ${LLVM_SLOT}" + [[ -d ${esysroot_prefix} ]] || + die "LLVM ${LLVM_SLOT} not found installed in ESYSROOT (expected: ${esysroot_prefix})" + + # satisfies find_package() in CMake + export LLVM_ROOT="${esysroot_prefix}" + export Clang_ROOT="${esysroot_prefix}" + export LLD_ROOT="${esysroot_prefix}" +} + +# @FUNCTION: llvm-r2_pkg_setup +# @DESCRIPTION: +# Handle all supported setup actions automatically. If LLVM is found +# installed for CBUILD, call llvm_cbuild_setup. If it is found +# installed for CHOST, call llvm_chost_setup. # -# If any other behavior is desired, the contents of the function -# should be inlined into the ebuild and modified as necessary. +# This function is a no-op when installing a binary package. # # Note that this function is not exported if LLVM_OPTIONAL is set. # In that case, it needs to be called manually. @@ -270,6 +289,10 @@ llvm-r2_pkg_setup() { if [[ -d $(get_llvm_prefix -b)/bin ]]; then llvm_cbuild_setup fi + + if [[ -d $(get_llvm_prefix -d) ]]; then + llvm_chost_setup + fi fi } -- 2.47.1