Jump to conversation
Unresolved conversations (4)
@nickdesaulniers nickdesaulniers Feb 2, 2024
Argh, sorry for causing confusion here, but I do think we'll benefit in the long run by documenting the state of the world. So some issues we've found: - gcc did not support `_Float128` in C mode until gcc-7, and C++ mode until gcc-13. - gcc defines `__STDC_IEC_60559_BFP__` to `201404L` so we cannot compare `__STDC_IEC_60559_BFP__` to `202311L` (at least doing so won't work for any compiler TODAY). Just having this one check would be ideal, but alas. - clang doesn't support `_Float128`. - glibc will define `__STDC_IEC_60559_BFP__` to `201404L`, so we can't use it to detect compiler support in overlay mode (or not without great pain). So perhaps we can have: ```c // GCC did not support _Float128 in C mode until gcc-7, or C++ mode until g++-13. #if defined(__GNUC__) && !defined(clang) && \ (defined(__cpluscplus) && __GNUC__ >= 13) || \ (!defined(__cplusplus) && __GNUC__ >= 7) #define LIBC_COMPILER_HAS_C23_FLOAT128 #endif // TODO: replace when clang has actual _Float128 support. // https://github.com/llvm/llvm-project/issues/80195 #ifdef __clang__ #define LIBC_COMPILER_HAS_FLOAT128_EXTENSION #endif #ifdef LIBC_COMPILER_HAS_C23_FLOAT128 typedef _Float128 float128; #elif defined(LIBC_COMPILER_HAS_FLOAT128_EXTENSION) typedef __float128 float128; #elif LDBL_MANT_DIG == 113 typedef long double float128; #else #error "no f128 support" #endif ``` I was hopefully naive that we could just have: ```c #if __STDC_IEC_60559_BFP__ < 202311L #error "no _Float128 support" #endif ```
Outdated
libc/include/llvm-libc-types/float128.h
nickdesaulniers lntue
@nickdesaulniers nickdesaulniers Jan 23, 2024
Is there a bug filed against clang upstream that you could link to in a comment here regarding clang support for _Float128? For instance, I suspect `_Float128` is what was standardized, not `__float128`. It would be good to have a TODO in sources to fix this up in the future, or think about how to write it such that newer versions of clang that do support `_Float128` just work.
Outdated
libc/include/llvm-libc-types/float128.h
lntue nickdesaulniers
gchatelet
@nickdesaulniers nickdesaulniers Jan 23, 2024
GCC's preprocessor seems to define `__FLT128_IS_IEC_60559__`, should clang be doing so as well?
Outdated
libc/include/llvm-libc-types/float128.h
lntue nickdesaulniers
@nickdesaulniers nickdesaulniers Jan 16, 2024
This is duplicated from libc/src/__support/macros/properties/compiler.h. Can we simply include that header here?
Outdated
libc/include/llvm-libc-types/float128.h
lntue nickdesaulniers
Resolved conversations (2)
@nickdesaulniers nickdesaulniers Jan 16, 2024
This seems to duplicate logic from libc/src/__support/macros/properties/float.h (`LIBC_COMPILER_HAS_C23_FLOAT128`, `LIBC_COMPILER_HAS_FLOAT128_EXTENSION`, and `LIBC_LONG_DOUBLE_IS_FLOAT128`). Surely we can DRY up the code between the two?
Outdated
libc/include/llvm-libc-types/float128.h
lntue
@nickdesaulniers nickdesaulniers Jan 16, 2024
Why do we need to check for double underscored variants?
Outdated
libc/src/__support/macros/properties/float.h
lntue