From cf3c4e4c108dc54d526b3361db156008c2b0ca62 Mon Sep 17 00:00:00 2001 From: Flatcar Buildbot Date: Mon, 1 Jan 2024 07:13:50 +0000 Subject: [PATCH] eclass/toolchain-funcs: Sync with Gentoo It's from Gentoo commit 2aea6c3ff2181ad96187e456a3307609fd288d4c. --- .../eclass/toolchain-funcs.eclass | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass b/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass index 5da9306386..cde84e6f34 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/toolchain-funcs.eclass +++ b/sdk_container/src/third_party/portage-stable/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