[libcxx-commits] [libcxx] [libc++] Use libm implementations in exp for complex numbers (PR #165457)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 29 06:17:33 PDT 2025
================
@@ -103,6 +103,31 @@ endif()
check_symbol_exists(__PICOLIBC__ "string.h" PICOLIBC)
+# Check for the existence of <complex.h> complex math functions.
+# This is necessary even though libcxx uses the builtin versions
+# of these functions, because if the builtin cannot be used, a reference
+# to the library function is emitted. Using compiler builtins for these
+# functions requires corresponding C99 library functions to be present.
+
+cmake_push_check_state()
+list(APPEND CMAKE_REQUIRED_LIBRARIES m)
+check_c_source_compiles("
+#include <complex.h>
+typedef __complex__ float float_type;
+typedef __complex__ double double_type;
+typedef __complex__ long double ld_type;
+volatile float_type tmpf;
+volatile double_type tmpd;
+volatile ld_type tmpld;
+int main(void) {
+ tmpf = cexpf(tmpf);
+ tmpd = cexp(tmpd);
+ tmpld = cexpl(tmpld);
+ return 0;
+}
+" C_SUPPORTS_C99_COMPLEX)
+cmake_pop_check_state()
+
----------------
philnik777 wrote:
We generally try to avoid these kinds of shenanigans. Why is this required?
https://github.com/llvm/llvm-project/pull/165457
More information about the libcxx-commits
mailing list