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 7CE5115812D for ; Mon, 30 Dec 2024 11:35:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 00D47E0823; Mon, 30 Dec 2024 11:35:07 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (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 pigeon.gentoo.org (Postfix) with ESMTPS id D12A2E081A for ; Mon, 30 Dec 2024 11:35:06 +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 CA62E33BF29 for ; Mon, 30 Dec 2024 11:35:05 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 31F4E190F for ; Mon, 30 Dec 2024 11:35:04 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1735558350.c774f99101c5c940c92fea36061e838ce7514c3e.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/llvm-r2.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: c774f99101c5c940c92fea36061e838ce7514c3e X-VCS-Branch: master Date: Mon, 30 Dec 2024 11:35:04 +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: 508548e4-6784-48f3-b71a-e217e7b089bb X-Archives-Hash: 8dc19ea8ed1a11a195dff3ec7b46ec78 commit: c774f99101c5c940c92fea36061e838ce7514c3e Author: Michał Górny gentoo org> AuthorDate: Mon Dec 16 10:24:07 2024 +0000 Commit: Michał Górny gentoo org> CommitDate: Mon Dec 30 11:32:30 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c774f991 llvm-r2.eclass: Add llvm_chost_setup, set CMake path variables 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 gentoo.org> 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 }