Skip to content

Conversation

frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Sep 5, 2025

Currently, GCC can't parse typedef _Complex __float128 cfloat128;, although __typeof__ can be used as a workaround. Reported https://gcc.gnu.org/PR121799 which was later considered as duplicate of https://gcc.gnu.org/PR32187.

Some recent changes exposed it to GCC and then caused CI failure for libc++. This patch adds a workaround for GCC.

Currently, GCC can't parse `typedef _Complex __float128 cfloat128;`,
although `__typeof__` can be used as a workaround. Reported
https://gcc.gnu.org/PR121799.

Some recent changes exposed it to GCC and then caused CI failure for
libc++. This patch adds a workaround for GCC.
@frederick-vs-ja frederick-vs-ja requested a review from c8ef September 5, 2025 04:28
@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner September 5, 2025 04:28
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 5, 2025

@llvm/pr-subscribers-libcxx

@llvm/pr-subscribers-libc

Author: A. Jiang (frederick-vs-ja)

Changes

Currently, GCC can't parse typedef _Complex __float128 cfloat128;, although __typeof__ can be used as a workaround. Reported https://gcc.gnu.org/PR121799.

Some recent changes exposed it to GCC and then caused CI failure for libc++. This patch adds a workaround for GCC.


Full diff: https://github.com/llvm/llvm-project/pull/157010.diff

2 Files Affected:

  • (modified) libc/include/llvm-libc-types/cfloat128.h (+5)
  • (modified) libcxx/include/__config (+2)
diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h
index 25b4cc7345a30..78a3dacd2676c 100644
--- a/libc/include/llvm-libc-types/cfloat128.h
+++ b/libc/include/llvm-libc-types/cfloat128.h
@@ -13,7 +13,12 @@
 
 #ifdef LIBC_TYPES_HAS_CFLOAT128
 #ifndef LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
+#if defined(__GNUC__) && !defined(__clang__)
+// Remove the workaround when https://gcc.gnu.org/PR121799 gets fixed.
+typedef __typeof__(_Complex __float128) cfloat128;
+#else  // ^^^ workaround / no workaround vvv
 typedef _Complex __float128 cfloat128;
+#endif // ^^^ workaround ^^^
 #else
 typedef _Complex long double cfloat128;
 #endif // LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
diff --git a/libcxx/include/__config b/libcxx/include/__config
index c197851f1c8fe..b1dff47b6aafd 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1265,3 +1265,5 @@ typedef __char32_t char32_t;
 #endif // __cplusplus
 
 #endif // _LIBCPP___CONFIG
+
+// triggering CI, will be reverted

#ifdef LIBC_TYPES_HAS_CFLOAT128
#ifndef LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
#if defined(__GNUC__) && !defined(__clang__)
// Remove the workaround when https://gcc.gnu.org/PR121799 gets fixed.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was considered to be duplicate of https://gcc.gnu.org/PR32187 later. Will update the comment once it's confirmed the CI failure due to libc is fixed.

Suggested change
// Remove the workaround when https://gcc.gnu.org/PR121799 gets fixed.
// Remove the workaround when https://gcc.gnu.org/PR32187 gets fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@c8ef c8ef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix!

@c8ef
Copy link
Contributor

c8ef commented Sep 5, 2025

Just out of curiosity, does libc++ already incorporate llvm-libc? I recall seeing an earlier PR that tried to use llvm-libc in APFloat, but it hasn't been merged yet...

@frederick-vs-ja
Copy link
Contributor Author

Just out of curiosity, does libc++ already incorporate llvm-libc?

Yes. Some components provided by libc++'s <charconv> are already relying on llvm-libc.

@frederick-vs-ja frederick-vs-ja removed the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 5, 2025
@frederick-vs-ja frederick-vs-ja merged commit 33a583d into llvm:main Sep 5, 2025
19 checks passed
@frederick-vs-ja frederick-vs-ja deleted the gcc-typdef-complex-__float128 branch September 5, 2025 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants