[compiler-rt] [clang] [AIX] Undefine __STDC_NO_ATOMICS__ to enable c11 atomics functionality (PR #76025)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 20 00:42:29 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kai Luo (bzEq)
<details>
<summary>Changes</summary>
This is copied from https://reviews.llvm.org/D109139.
`__STDC_NO_ATOMICS__` is predefined to indicate clang on AIX doesn't support `_Atomic` and not shipped with `stdatomic.h` yet. Actually `_Atomic` is already supported. For `stdatomic.h`, clang has implemented one in `clang/lib/Headers/stdatomic.h`.
For missing libc implementations,
```
atomic_flag_test_and_set
atomic_flag_test_and_set_explicit
atomic_flag_clear
atomic_flag_clear_explicit
atomic_thread_fence
atomic_signal_fence
```
Provide them via compiler-rt.
---
Full diff: https://github.com/llvm/llvm-project/pull/76025.diff
3 Files Affected:
- (modified) clang/lib/Basic/Targets/OSTargets.h (+1-3)
- (modified) clang/test/Preprocessor/init-ppc.c (-2)
- (modified) compiler-rt/lib/builtins/CMakeLists.txt (+1-1)
``````````diff
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..f76afad947cb7f 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -645,10 +645,8 @@ class AIXTargetInfo : public OSTargetInfo<Target> {
Builder.defineMacro("__TOS_AIX__");
Builder.defineMacro("__HOS_AIX__");
- if (Opts.C11) {
- Builder.defineMacro("__STDC_NO_ATOMICS__");
+ if (Opts.C11)
Builder.defineMacro("__STDC_NO_THREADS__");
- }
if (Opts.EnableAIXExtendedAltivecABI)
Builder.defineMacro("__EXTABI__");
diff --git a/clang/test/Preprocessor/init-ppc.c b/clang/test/Preprocessor/init-ppc.c
index 3fb642af9d7420..8cdb2c6d3d350d 100644
--- a/clang/test/Preprocessor/init-ppc.c
+++ b/clang/test/Preprocessor/init-ppc.c
@@ -756,11 +756,9 @@
// RUN: %clang_cc1 -x c -std=c11 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-STDC %s
// RUN: %clang_cc1 -x c -std=gnu11 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-STDC %s
// RUN: %clang_cc1 -x c -std=c17 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-STDC %s
-// PPC-AIX-STDC:#define __STDC_NO_ATOMICS__ 1
// PPC-AIX-STDC:#define __STDC_NO_THREADS__ 1
// RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-STDC-N %s
-// PPC-AIX-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1
// PPC-AIX-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -mlong-double-64 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-LD64 %s
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index e5b52db175d960..f57cd36eccd453 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -243,7 +243,7 @@ if(COMPILER_RT_HAS_ATOMIC_KEYWORD AND NOT COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN)
)
endif()
-if(APPLE)
+if(APPLE OR OS_NAME MATCHES "AIX")
set(GENERIC_SOURCES
${GENERIC_SOURCES}
atomic_flag_clear.c
``````````
</details>
https://github.com/llvm/llvm-project/pull/76025
More information about the cfe-commits
mailing list