Add a new tc-get-cxx-stdlib() that attempts to get the C++ stdlib
variant used by the current C++ compiler. Currently it supports libc++
and libstdc++ (GCC's stdlib).
Signed-off-by: Michał Górny <
[email protected]>
---
eclass/tests/toolchain-funcs.sh | 22 ++++++++++++++++++++
eclass/toolchain-funcs.eclass | 36 +++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh index 56379b10cded..5a35a44ce018 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -198,4 +198,26 @@ for compiler in gcc clang not-really-a-compiler; do
fi
done
+if type -P gcc &>/dev/null; then
+ tbegin "tc-get-cxx-stdlib (gcc)"
+ [[ $(CXX=g++ tc-get-cxx-stdlib) == libstdc++ ]]
+ tend $?
+fi
+
+if type -P clang &>/dev/null; then
+ for stdlib in libc++ libstdc++; do
+ if clang++ -stdlib=${stdlib} -x c++ -E -P - &>/dev/null \
+ <<<'#include <ciso646>'
+ then
+ tbegin "tc-get-cxx-stdlib (clang, ${stdlib})"
+ [[ $(CXX=clang++ CXXFLAGS="-stdlib=${stdlib}" tc-get-cxx-stdlib) == ${stdlib} ]]
+ tend $?
+ fi
+ done
+
+ tbegin "tc-get-cxx-stdlib (clang, invalid)"
+ ! CXX=clang++ CXXFLAGS="-st