mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-11-24 23:47:14 -08:00
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>
This commit is contained in:
@@ -202,6 +202,10 @@ if type -P gcc &>/dev/null; then
|
||||
tbegin "tc-get-cxx-stdlib (gcc)"
|
||||
[[ $(CXX=g++ tc-get-cxx-stdlib) == libstdc++ ]]
|
||||
tend $?
|
||||
|
||||
tbegin "tc-get-c-rtlib (gcc)"
|
||||
[[ $(CC=gcc tc-get-c-rtlib) == libgcc ]]
|
||||
tend $?
|
||||
fi
|
||||
|
||||
if type -P clang &>/dev/null; then
|
||||
@@ -218,6 +222,12 @@ if type -P clang &>/dev/null; then
|
||||
tbegin "tc-get-cxx-stdlib (clang, invalid)"
|
||||
! CXX=clang++ CXXFLAGS="-stdlib=invalid" tc-get-cxx-stdlib
|
||||
tend $?
|
||||
|
||||
for rtlib in compiler-rt libgcc; do
|
||||
tbegin "tc-get-c-rtlib (clang, ${rtlib})"
|
||||
[[ $(CC=clang CFLAGS="--rtlib=${rtlib}" tc-get-c-rtlib) == ${rtlib} ]]
|
||||
tend $?
|
||||
done
|
||||
fi
|
||||
|
||||
texit
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user