summaryrefslogtreecommitdiff
path: root/eclass/toolchain-funcs.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-10-11 01:37:01 +0100
committerV3n3RiX <venerix@koprulu.sector>2022-10-11 01:37:01 +0100
commit179be85ade6b2b47bf362865b5c375969ab5ddc8 (patch)
tree073bcd19b7e1bb84acd2f683936671ee88860970 /eclass/toolchain-funcs.eclass
parent948f9476d6a417da6048d4291bf36b0507293d63 (diff)
gentoo auto-resync : 11:10:2022 - 01:37:00
Diffstat (limited to 'eclass/toolchain-funcs.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 48bf11606c4a..32e446cb2368 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -1173,4 +1173,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) ${CXXFLAGS} ${CPPFLAGS} -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) ${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