summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2022-10-07 17:02:28 +0200
committerMichał Górny <mgorny@gentoo.org>2022-10-10 22:52:34 +0200
commit2170307e8e09491f88b0c5f41d42aa096d1b3632 (patch)
tree0efac14aa0c744ce277b77bcbd1f1cf30025822a /eclass/tests
parentdev-cpp/tbb: drop 2021.4.0, 2021.6.0 (diff)
downloadgentoo-2170307e8e09491f88b0c5f41d42aa096d1b3632.tar.gz
gentoo-2170307e8e09491f88b0c5f41d42aa096d1b3632.tar.bz2
gentoo-2170307e8e09491f88b0c5f41d42aa096d1b3632.zip
toolchain-funcs.eclass: Add tc-get-cxx-stdlib() to get C++ stdlib
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 <mgorny@gentoo.org>
Diffstat (limited to 'eclass/tests')
-rwxr-xr-xeclass/tests/toolchain-funcs.sh22
1 files changed, 22 insertions, 0 deletions
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="-stdlib=invalid" tc-get-cxx-stdlib
+ tend $?
+fi
+
texit