https://github.com/adurang created 
https://github.com/llvm/llvm-project/pull/214497

 On systems with newer glibc (2.41) when compiling with -fopenmp-targets the 
device compilation side fails with:

>     /usr/include/x86_64-linux-gnu/bits/floatn.h:83:52: error: unsupported 
> machine mode '__TC__'
>        83 | typedef _Complex float __cfloat128 __attribute__ ((__mode__ 
> (__TC__)));
>           |                                                    ^
 
 Sema::AddModeAttr already avoids diagnosing a 128-bit `mode` attribute  (e.g. 
__TC__, as used by glibc's __cfloat128) that the target can't represent, but 
only for CUDA and SYCL device compilation. OpenMP target-device compilation for 
targets also lacks a 128-bit float/complex representation so we extend the 
check to cover OpenMPIsTargetDevice as well to avoid the fail.

Assisted by Claude.

>From 4dd92c173b766a6f0f2c8caff108608d00b778fc Mon Sep 17 00:00:00 2001
From: "Duran, Alex" <[email protected]>
Date: Thu, 6 Aug 2026 06:45:42 -0700
Subject: [PATCH 1/2] [clang][sema] Suppress unsupported 128-bit mode attribute
 diagnostic for OpenMP device compilation

On system with newer glibc (2.41) the device compilation side fails with:

/usr/include/x86_64-linux-gnu/bits/floatn.h:83:52: error: unsupported machine 
mode '__TC__'
   83 | typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
      |                                                    ^

Sema::AddModeAttr already avoids diagnosing a 128-bit `mode` attribute
(e.g. __TC__, as used by glibc's __cfloat128) that the target can't
represent, but only for CUDA and SYCL device compilation. OpenMP
target-device compilation for targets also lacks a 128-bit float/complex
representation so we extend the check to cover OpenMPIsTargetDevice as
well to avoid the fail.
---
 clang/lib/Sema/SemaDeclAttr.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 492b125587344..813b7de3e86e6 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5226,7 +5226,8 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo 
&CI,
   if (NewElemTy.isNull()) {
     // Only emit diagnostic on host for 128-bit mode attribute
     if (!(DestWidth == 128 &&
-          (getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice)))
+          (getLangOpts().CUDAIsDevice || getLangOpts().SYCLIsDevice ||
+           getLangOpts().OpenMPIsTargetDevice)))
       Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
     return;
   }

>From 2d6fc7a8a90c970f47c312a83cb5628be08be5fa Mon Sep 17 00:00:00 2001
From: "Duran, Alex" <[email protected]>
Date: Thu, 6 Aug 2026 07:05:24 -0700
Subject: [PATCH 2/2] Add regression test

---
 clang/test/OpenMP/target_device_float128_mode_attr.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 clang/test/OpenMP/target_device_float128_mode_attr.c

diff --git a/clang/test/OpenMP/target_device_float128_mode_attr.c 
b/clang/test/OpenMP/target_device_float128_mode_attr.c
new file mode 100644
index 0000000000000..19bff61bfb0ed
--- /dev/null
+++ b/clang/test/OpenMP/target_device_float128_mode_attr.c
@@ -0,0 +1,11 @@
+// Host-side compilation on x86 (no errors expected).
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple nvptx64 
-fopenmp -x c -fsyntax-only -verify=host %s
+
+// Device-side compilation for targets without 128-bit float/complex support 
(no errors expected).
+// RUN: %clang_cc1 -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu 
-fopenmp -fopenmp-is-target-device -x c -fsyntax-only -verify=device %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple 
x86_64-unknown-linux-gnu -fopenmp -fopenmp-is-target-device -x c -fsyntax-only 
-verify=device %s
+// RUN: %clang_cc1 -triple spirv64 -aux-triple x86_64-unknown-linux-gnu 
-fopenmp -fopenmp-is-target-device -x c -fsyntax-only -verify=device %s
+
+// host-no-diagnostics
+// device-no-diagnostics
+typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to