diff options
author | 2022-10-07 17:22:01 +0200 | |
---|---|---|
committer | 2022-10-10 22:52:35 +0200 | |
commit | 96ddadb40ddba1bfdba68ff8f2fd889cfd004f03 (patch) | |
tree | 38c8a573ea589e7ca9cf94a53c316b0459dcc12b /eclass/toolchain-funcs.eclass | |
parent | toolchain-funcs.eclass: Add tc-get-cxx-stdlib() to get C++ stdlib (diff) | |
download | gentoo-96ddadb40ddba1bfdba68ff8f2fd889cfd004f03.tar.gz gentoo-96ddadb40ddba1bfdba68ff8f2fd889cfd004f03.tar.bz2 gentoo-96ddadb40ddba1bfdba68ff8f2fd889cfd004f03.zip |
toolchain-funcs.eclass: Add tc-get-c-rtlib() to get CC runtime
Add a new tc-get-c-rtlib() that attempts to get the runtime used
by the current C compiler. Currently it supports compiler-rt
and libgcc.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/toolchain-funcs.eclass')
-rw-r--r-- | eclass/toolchain-funcs.eclass | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index 92494158201e..32e446cb2368 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -1209,4 +1209,32 @@ tc-get-cxx-stdlib() { return 0 } +# @FUNCTION: tc-get-c-rtlib +# @DESCRIPTION: +# Attempt to identify the runtime used by the C/C++ compiler. +# If the runtime is identifed, the function returns 0 and prints one +# of the following: +# +# - ``compiler-rt`` for ``sys-libs/compiler-rt`` +# - ``libgcc`` for ``sys-devel/gcc``'s libgcc +# +# If the runtime is not recognized, the function returns 1. +tc-get-c-rtlib() { + local res=$( + $(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} \ + -print-libgcc-file-name 2>/dev/null + ) + + case ${res} in + *libclang_rt*) + echo compiler-rt;; + *libgcc*) + echo libgcc;; + *) + return 1;; + esac + + return 0 +} + fi |