eclass/toolchain-funcs: Sync with Gentoo

It's from Gentoo commit 2aea6c3ff2181ad96187e456a3307609fd288d4c.
This commit is contained in:
Flatcar Buildbot 2024-01-01 07:13:50 +00:00 committed by Krzesimir Nowak
parent 345c6b2b31
commit cf3c4e4c10

View File

@ -1230,4 +1230,25 @@ tc-get-build-ptr-size() {
die "Could not determine CBUILD pointer 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 fi