summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorAlexey Sokolov <alexey+gentoo@asokolov.org>2023-09-11 23:56:18 +0100
committerSam James <sam@gentoo.org>2023-09-12 00:33:12 +0100
commit71b917e9f7a969a319d49ae34be09550f2530139 (patch)
treef74e6b89a863f4d40b92f02199be2d9f2ce6c1ed /eclass
parentscripts/bootstrap-prefix: bump bootstrap snapshot (diff)
downloadprefix-71b917e9f7a969a319d49ae34be09550f2530139.tar.gz
prefix-71b917e9f7a969a319d49ae34be09550f2530139.tar.bz2
prefix-71b917e9f7a969a319d49ae34be09550f2530139.zip
eclass/toolchain-funcs.eclass: add missing functions
Copied straight from ::gentoo's version of this file Bug: https://bugs.gentoo.org/758167 Signed-off-by: Alexey Sokolov <alexey+gentoo@asokolov.org> Closes: https://github.com/gentoo/prefix/pull/32 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/toolchain-funcs.eclass64
1 files changed, 64 insertions, 0 deletions
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index b86a9682b1..1c7a34bd82 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -1186,4 +1186,68 @@ gen_usr_ldscript() {
done
}
+# @FUNCTION: tc-get-cxx-stdlib
+# @DESCRIPTION:
+# Attempt to identify the C++ standard library used by the compiler.
+# If the library is identified, the function returns 0 and prints one
+# of the following:
+#
+# - ``libc++`` for ``sys-libs/libcxx``
+# - ``libstdc++`` for ``sys-devel/gcc``'s libstdc++
+#
+# If the library is not recognized, the function returns 1.
+tc-get-cxx-stdlib() {
+ local code='#include <ciso646>
+
+#if defined(_LIBCPP_VERSION)
+ HAVE_LIBCXX
+#elif defined(__GLIBCXX__)
+ HAVE_LIBSTDCPP
+#endif
+'
+ local res=$(
+ $(tc-getCXX) ${CPPFLAGS} ${CXXFLAGS} -x c++ -E -P - \
+ <<<"${code}" 2>/dev/null
+ )
+
+ case ${res} in
+ *HAVE_LIBCXX*)
+ echo libc++;;
+ *HAVE_LIBSTDCPP*)
+ echo libstdc++;;
+ *)
+ return 1;;
+ esac
+
+ 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) ${CPPFLAGS} ${CFLAGS} ${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