* [gentoo-dev] [PATCH 1/2] toolchain-funcs.eclass: Fix tc-is-lto not to leave stray files in T
@ 2024-08-05 14:08 Michał Górny
2024-08-05 14:08 ` [gentoo-dev] [PATCH 2/2] eclass/tests/toolchain-funcs.sh: Cover tc-is-lto Michał Górny
0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2024-08-05 14:08 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-dev] [PATCH 2/2] eclass/tests/toolchain-funcs.sh: Cover tc-is-lto
2024-08-05 14:08 [gentoo-dev] [PATCH 1/2] toolchain-funcs.eclass: Fix tc-is-lto not to leave stray files in T Michał Górny
@ 2024-08-05 14:08 ` Michał Górny
0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2024-08-05 14:08 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/tests/toolchain-funcs.sh | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index ee10ddf50c1e..6bfb00ff6bcb 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -210,6 +210,16 @@ if type -P gcc &>/dev/null; then
tbegin "tc-get-c-rtlib (gcc)"
[[ $(CC=gcc tc-get-c-rtlib) == libgcc ]]
tend $?
+
+ tbegin "tc-is-lto (gcc, -fno-lto)"
+ CC=gcc CFLAGS=-fno-lto tc-is-lto
+ [[ $? -eq 1 ]]
+ tend $?
+
+ tbegin "tc-is-lto (gcc, -flto)"
+ CC=gcc CFLAGS=-flto tc-is-lto
+ [[ $? -eq 0 ]]
+ tend $?
fi
if type -P clang &>/dev/null; then
@@ -232,6 +242,16 @@ if type -P clang &>/dev/null; then
[[ $(CC=clang CFLAGS="--rtlib=${rtlib}" tc-get-c-rtlib) == ${rtlib} ]]
tend $?
done
+
+ tbegin "tc-is-lto (clang, -fno-lto)"
+ CC=clang CFLAGS=-fno-lto tc-is-lto
+ [[ $? -eq 1 ]]
+ tend $?
+
+ tbegin "tc-is-lto (clang, -flto)"
+ CC=clang CFLAGS=-flto tc-is-lto
+ [[ $? -eq 0 ]]
+ tend $?
fi
texit
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-05 14:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-05 14:08 [gentoo-dev] [PATCH 1/2] toolchain-funcs.eclass: Fix tc-is-lto not to leave stray files in T Michał Górny
2024-08-05 14:08 ` [gentoo-dev] [PATCH 2/2] eclass/tests/toolchain-funcs.sh: Cover tc-is-lto Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox