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) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 25EC8159C9B for ; Mon, 5 Aug 2024 14:08:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 029FAE2A53; Mon, 5 Aug 2024 14:08:25 +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 9C1B8E2A4E for ; Mon, 5 Aug 2024 14:08:24 +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 1/2] toolchain-funcs.eclass: Fix tc-is-lto not to leave stray files in T Date: Mon, 5 Aug 2024 16:08:17 +0200 Message-ID: <20240805140818.1007067-1-mgorny@gentoo.org> X-Mailer: git-send-email 2.45.2 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: 9c5c52b5-ac77-4038-81c9-fad94fe0288d X-Archives-Hash: 3b5d57ec6d0fed5917cc1415e1af8d57 Fix tc-is-lto function to remove the temporary file after testing. Besides being cleaner, this fixes a permission problem when using Paludis and tc-is-lto is used both in pkg_setup() (which creates the temporary file owned by root) and src_*() phase (which attempts to rewrite it as a regular user). Thanks to negril for the report! Signed-off-by: Michał Górny --- eclass/toolchain-funcs.eclass | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index cde84e6f34c8..e73af9772938 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -1234,6 +1234,7 @@ tc-get-build-ptr-size() { # @RETURN: Shell true if we are using LTO, shell false otherwise tc-is-lto() { local f="${T}/test-lto.o" + local ret=1 case $(tc-get-compiler-type) in clang) @@ -1241,14 +1242,15 @@ tc-is-lto() { # If LTO is used, clang will output bytecode and llvm-bcanalyzer # will run successfully. Otherwise, it will output plain object # file and llvm-bcanalyzer will exit with error. - llvm-bcanalyzer "${f}" &>/dev/null && return 0 + llvm-bcanalyzer "${f}" &>/dev/null && ret=0 ;; gcc) $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<<"" || die - [[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && return 0 + [[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && ret=0 ;; esac - return 1 + rm -f "${f}" || die + return "${ret}" } fi -- 2.45.2