From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
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 [thread overview]
Message-ID: <20240805140818.1007067-1-mgorny@gentoo.org> (raw)
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 <mgorny@gentoo.org>
---
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
next reply other threads:[~2024-08-05 14:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-05 14:08 Michał Górny [this message]
2024-08-05 14:08 ` [gentoo-dev] [PATCH 2/2] eclass/tests/toolchain-funcs.sh: Cover tc-is-lto Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240805140818.1007067-1-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox