Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix __float128 only available on Linux for x86_64 #75909

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Conversation

silver-popov
Copy link
Contributor

Hello

It seems that CLang does not support float-128 extension, at least for x86-64 architecture.
For any OS, not only for fuchsia. So, following code causes a compilation error and should be removed.

#if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 500)) &&
(defined(LIBC_TARGET_ARCH_IS_X86_64) &&
!defined(LIBC_TARGET_OS_IS_FUCHSIA))
#define LIBC_COMPILER_HAS_FLOAT128_EXTENSION
#endif

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc label Dec 19, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Dec 19, 2023

@llvm/pr-subscribers-libc

Author: Igor Popov (silver-popov)

Changes

Hello

It seems that CLang does not support float-128 extension, at least for x86-64 architecture.
For any OS, not only for fuchsia. So, following code causes a compilation error and should be removed.

#if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 500)) &&
(defined(LIBC_TARGET_ARCH_IS_X86_64) &&
!defined(LIBC_TARGET_OS_IS_FUCHSIA))
#define LIBC_COMPILER_HAS_FLOAT128_EXTENSION
#endif


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

1 Files Affected:

  • (modified) libc/src/__support/macros/properties/float.h (-5)
diff --git a/libc/src/__support/macros/properties/float.h b/libc/src/__support/macros/properties/float.h
index 756579024cad8b..1953a6b6ef6250 100644
--- a/libc/src/__support/macros/properties/float.h
+++ b/libc/src/__support/macros/properties/float.h
@@ -59,11 +59,6 @@ using float16 = _Float16;
      defined(LIBC_TARGET_ARCH_IS_X86_64))
 #define LIBC_COMPILER_HAS_C23_FLOAT128
 #endif
-#if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 500)) &&  \
-    (defined(LIBC_TARGET_ARCH_IS_X86_64) &&                                    \
-     !defined(LIBC_TARGET_OS_IS_FUCHSIA))
-#define LIBC_COMPILER_HAS_FLOAT128_EXTENSION
-#endif
 
 #if defined(LIBC_COMPILER_HAS_C23_FLOAT128)
 using float128 = _Float128;

@gchatelet
Copy link
Contributor

It seems to me that it does support float128 for x86_64.
https://godbolt.org/z/hqcfnnxc8

Although there is indeed a mistake, the condition should be >= 600 and not >= 500.

@silver-popov
Copy link
Contributor Author

Although there is indeed a mistake, the condition should be >= 600 and not >= 500.

CLang 17 gives the error message:
llvm-project/libc/src/__support/FPUtil/FloatProperties.h:197:41: error: __float128 is not supported on this target

@gchatelet
Copy link
Contributor

Although there is indeed a mistake, the condition should be >= 600 and not >= 500.

CLang 17 gives the error message: llvm-project/libc/src/__support/FPUtil/FloatProperties.h:197:41: error: __float128 is not supported on this target

I don't see this happening : https://godbolt.org/z/vsTbT13P1

Do you have a reproducer? Are you specifying a particular -march or any specific compiler options through LIBC_COMPILE_OPTIONS_DEFAULT or LIBC_COMMON_TUNE_OPTIONS?

@silver-popov
Copy link
Contributor Author

silver-popov commented Dec 19, 2023

I'm specifying LIBC_TARGET_TRIPLE="x86_64-pc-none-eabi"

@silver-popov
Copy link
Contributor Author

silver-popov commented Dec 19, 2023

The environment is MSYS2, CLang64.
Maybe the cause is MSYS2?

@silver-popov
Copy link
Contributor Author

And why float-128 extension was disabled for Fuchsia?

@gchatelet
Copy link
Contributor

The issue seems to be coming from OS support
https://godbolt.org/z/Y94o7KEKx

It is supported for --target=x86_64-pc-linux-eabi but not for --target=x86_64-pc-none-eabi nor --target=x86_64-pc-win32-eabi. So the proper guard should be:

#if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 600)) &&  \
    (defined(LIBC_TARGET_ARCH_IS_X86_64) &&                                    \
     defined(LIBC_TARGET_OS_IS_LINUX) && !defined(LIBC_TARGET_OS_IS_FUCHSIA))
#define LIBC_COMPILER_HAS_FLOAT128_EXTENSION
#endif

@silver-popov silver-popov reopened this Dec 20, 2023
@silver-popov
Copy link
Contributor Author

Compiles successfull. Committed.

@silver-popov silver-popov changed the title Remove wrong float-128 extension for CLang Fix float-128 extension for CLang Dec 20, 2023
@gchatelet gchatelet changed the title Fix float-128 extension for CLang Fix __float128 only available on Linux for x86_64 Dec 20, 2023
@gchatelet gchatelet merged commit 2176af7 into llvm:main Dec 20, 2023
7 checks passed
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.

None yet

3 participants