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