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 (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 357BB158020 for ; Sun, 16 Oct 2022 17:08:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6DAC8E0D24; Sun, 16 Oct 2022 17:08:25 +0000 (UTC) Received: from smtp.gentoo.org (smtp.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 28E27E0D20 for ; Sun, 16 Oct 2022 17:08:25 +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 2/2] llvm.org.eclass: Fix LLVM tool paths to prevent overriding them Date: Sun, 16 Oct 2022 19:08:16 +0200 Message-Id: <20221016170816.1421946-2-mgorny@gentoo.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221016170816.1421946-1-mgorny@gentoo.org> References: <20221016170816.1421946-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: de2aa6ab-6f9e-4380-a453-7045935e3b17 X-Archives-Hash: 6e4ab200c915c0db08258925e5e896f5 Fix the LLVM tool path in variables such as AR, LD, etc. to their current locations prior to manipulating PATH, in order to prevent llvm.eclass from overriding them. Otherwise, a package requiring older LLVM libraries could force older tool versions, possibly incompatible with the object files produced by a newer clang version. Signed-off-by: Michał Górny --- eclass/llvm.eclass | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass index 39299d06dbe9..16596ec2ea66 100644 --- a/eclass/llvm.eclass +++ b/eclass/llvm.eclass @@ -214,6 +214,30 @@ llvm_fix_clang_version() { ${shopt_save} } +# @FUNCTION: llvm_fix_tool_path +# @USAGE: ... +# @DESCRIPTION: +# Fix the LLVM tools referenced in the specified variables to their +# current location, to prevent PATH alterations from forcing older +# versions being used. +llvm_fix_tool_path() { + debug-print-function ${FUNCNAME} "${@}" + + local shopt_save=$(shopt -p -o noglob) + set -f + local var + for var; do + local split=( ${!var} ) + local path=$(type -P ${split[0]} 2>/dev/null) + # if it resides in one of the LLVM prefixes, it's an LLVM tool! + if [[ ${path} == "${BROOT}/usr/lib/llvm"* ]]; then + split[0]=${path} + declare -g "${var}=${split[*]}" + fi + done + ${shopt_save} +} + # @FUNCTION: llvm_pkg_setup # @DESCRIPTION: # Prepend the appropriate executable directory for the newest @@ -233,6 +257,9 @@ llvm_pkg_setup() { if [[ ${MERGE_TYPE} != binary ]]; then llvm_fix_clang_version CC CPP CXX + # keep in sync with profiles/features/llvm/make.defaults! + llvm_fix_tool_path ADDR2LINE AR AS LD NM OBJCOPY OBJDUMP RANLIB + llvm_fix_tool_path READELF STRINGS STRIP local llvm_path=$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin local IFS=: -- 2.38.0