summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRepository mirror & CI <repomirrorci@gentoo.org>2023-12-26 14:17:51 +0000
committerRepository mirror & CI <repomirrorci@gentoo.org>2023-12-26 14:17:51 +0000
commitbeec6994e692dd65175a3f61713d9c00f87f908b (patch)
tree37cf23c1fb5734febf8b29a2bd9c9133c13a628b
parent2023-12-26 13:16:56 UTC (diff)
parenttoolchain-funcs.eclass: Add tc-is-lto function (diff)
downloadgentoo-beec6994e692dd65175a3f61713d9c00f87f908b.tar.gz
gentoo-beec6994e692dd65175a3f61713d9c00f87f908b.tar.bz2
gentoo-beec6994e692dd65175a3f61713d9c00f87f908b.zip
Merge updates from master
-rw-r--r--eclass/toolchain-funcs.eclass21
1 files changed, 21 insertions, 0 deletions
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 5da93063866b..cde84e6f34c8 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -1230,4 +1230,25 @@ tc-get-build-ptr-size() {
die "Could not determine CBUILD pointer size"
}
+# @FUNCTION: tc-is-lto
+# @RETURN: Shell true if we are using LTO, shell false otherwise
+tc-is-lto() {
+ local f="${T}/test-lto.o"
+
+ case $(tc-get-compiler-type) in
+ clang)
+ $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<<"" || die
+ # 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
+ ;;
+ gcc)
+ $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<<"" || die
+ [[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && return 0
+ ;;
+ esac
+ return 1
+}
+
fi