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 4EF83158020 for ; Wed, 19 Oct 2022 11:53:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ECED1E0882; Wed, 19 Oct 2022 11:53:48 +0000 (UTC) Received: from smtp.gentoo.org (mail.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 D36ADE0882 for ; Wed, 19 Oct 2022 11:53:48 +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 DF557340EB0 for ; Wed, 19 Oct 2022 11:53:47 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 295BD624 for ; Wed, 19 Oct 2022 11:53:46 +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: <1666180404.64a5154944610c040453e46284a20b9c2bde4d0e.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/llvm.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 64a5154944610c040453e46284a20b9c2bde4d0e X-VCS-Branch: master Date: Wed, 19 Oct 2022 11:53:46 +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: 95645d8d-08ef-4042-8c83-abd2e14c64e5 X-Archives-Hash: 80744d474c8d010d0012f14d847ea12d commit: 64a5154944610c040453e46284a20b9c2bde4d0e Author: Michał Górny gentoo org> AuthorDate: Sun Oct 16 12:26:44 2022 +0000 Commit: Michał Górny gentoo org> CommitDate: Wed Oct 19 11:53:24 2022 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=64a51549 llvm.eclass: Fix LLVM tool paths to prevent overriding them 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. Closes: https://github.com/gentoo/gentoo/pull/27803 Signed-off-by: Michał Górny gentoo.org> 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=: