[clang] [compiler-rt] [AIX][clang][compiler_rt] rename libatomic archive to libclang_rt (PR #197485)
Alison Zhang via cfe-commits
cfe-commits at lists.llvm.org
Thu May 14 08:52:43 PDT 2026
https://github.com/azhan92 updated https://github.com/llvm/llvm-project/pull/197485
>From ef0caa43e295e1ad0267286c4f42f27e561a8dca Mon Sep 17 00:00:00 2001
From: Alison Zhang <alisonzhang at ibm.com>
Date: Wed, 13 May 2026 11:22:04 -0400
Subject: [PATCH 1/5] Replace -latomic with -lcompiler_rt in driver
---
clang/lib/Driver/ToolChain.cpp | 5 ++++-
clang/lib/Driver/ToolChains/AIX.cpp | 2 +-
clang/test/Driver/fprofile-update.c | 4 ++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 98936b25ce650..40c19614d2ba1 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -971,7 +971,10 @@ void ToolChain::addFortranRuntimeLibs(const ArgList &Args,
if ((OMPRuntime == Driver::OMPRT_OMP &&
RuntimeLib == ToolChain::RLT_Libgcc) &&
!getTriple().isKnownWindowsMSVCEnvironment()) {
- CmdArgs.push_back("-latomic");
+ if (getTriple().isOSAIX())
+ CmdArgs.push_back("-lcompiler_rt");
+ else
+ CmdArgs.push_back("-latomic");
}
}
}
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index e36910f9aaf46..01b2c8ec18a35 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -594,7 +594,7 @@ void AIX::addProfileRTLibs(const llvm::opt::ArgList &Args,
Args.getLastArgNoClaim(options::OPT_fprofile_update_EQ)) {
StringRef Val = A->getValue();
if (Val == "atomic" || Val == "prefer-atomic")
- CmdArgs.push_back("-latomic");
+ CmdArgs.push_back("-lcompiler_rt");
}
}
diff --git a/clang/test/Driver/fprofile-update.c b/clang/test/Driver/fprofile-update.c
index 3313a2c1cb9af..c297b2b4931f8 100644
--- a/clang/test/Driver/fprofile-update.c
+++ b/clang/test/Driver/fprofile-update.c
@@ -18,5 +18,5 @@
// RUN: %clang -### %s --target=powerpc-unknown-aix -fprofile-generate -fprofile-update=prefer-atomic 2>&1 | FileCheck %s --check-prefix=AIX
// RUN: %clang -### %s --target=powerpc-unknown-aix -fprofile-generate 2>&1 | FileCheck %s --check-prefix=AIX-NOATOMIC
// RUN: %clang -### %s --target=powerpc-unknown-aix -fprofile-generate -fprofile-update=single 2>&1 | FileCheck %s --check-prefix=AIX-NOATOMIC
-// AIX: "-latomic"
-// AIX-NOATOMIC-NOT: "-latomic"
+// AIX: "-lcompiler_rt"
+// AIX-NOATOMIC-NOT: "-lcompiler_rt"
>From a794a1f48e1b6a1c727141476659d031beba2976 Mon Sep 17 00:00:00 2001
From: Alison Zhang <alisonzhang at ibm.com>
Date: Wed, 13 May 2026 13:15:29 -0400
Subject: [PATCH 2/5] Update libatomic in CMakeLists.txt
---
compiler-rt/lib/builtins/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index f0c2f3ea5ee43..56387f4e9b32c 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -1113,10 +1113,10 @@ if(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC)
endif()
endforeach()
# FIXME: On AIX, we have to archive built shared libraries into a static
- # archive, i.e., libatomic.a. Once cmake adds support of such usage for AIX,
+ # archive, i.e., libcompiler_rt.a. Once cmake adds support of such usage for AIX,
# this ad-hoc part can be removed.
if(OS_NAME MATCHES "AIX")
- archive_aix_libatomic(clang_rt.atomic libatomic
+ archive_aix_libatomic(clang_rt.atomic libcompiler_rt
ARCHS ${BUILTIN_SUPPORTED_ARCH}
PARENT_TARGET builtins-standalone-atomic)
endif()
>From 19d6ceb326098b603ca44b90a1e1840948e66b60 Mon Sep 17 00:00:00 2001
From: Alison Zhang <alisonzhang at ibm.com>
Date: Wed, 13 May 2026 15:12:44 -0400
Subject: [PATCH 3/5] Update release notes
---
clang/docs/ReleaseNotes.rst | 2 ++
1 file changed, 2 insertions(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c71f7b173259f..aa135d1558e66 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -715,6 +715,8 @@ AIX Support
(instead of `all`) which only extracts static init from archive members which
would otherwise be referenced.
(See https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command for details).
+- The driver now uses ``-lcompiler_rt`` instead of ``-latomic`` to avoid conflicts
+ with the GNU libatomic library in the AIX toolbox.
NetBSD Support
^^^^^^^^^^^^^^
>From ad91f91c443f4c83b08683c6f890f740db89caab Mon Sep 17 00:00:00 2001
From: Alison Zhang <alisonzhang at ibm.com>
Date: Wed, 13 May 2026 15:27:41 -0400
Subject: [PATCH 4/5] Add detail to release notes
---
clang/docs/ReleaseNotes.rst | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index aa135d1558e66..b73aa4ceaf416 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -716,7 +716,8 @@ AIX Support
would otherwise be referenced.
(See https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command for details).
- The driver now uses ``-lcompiler_rt`` instead of ``-latomic`` to avoid conflicts
- with the GNU libatomic library in the AIX toolbox.
+ between the LLVM libatomic and the GNU libatomic from the AIX toolbox as they share
+ the same library name.
NetBSD Support
^^^^^^^^^^^^^^
>From 032a92e35a505014bed3bfa7b53c00445ad3c58c Mon Sep 17 00:00:00 2001
From: Alison Zhang <alisonzhang at ibm.com>
Date: Thu, 14 May 2026 11:51:59 -0400
Subject: [PATCH 5/5] Update release notes to include compiler-rt change
---
clang/docs/ReleaseNotes.rst | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b73aa4ceaf416..ec375a7e9f879 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -715,7 +715,8 @@ AIX Support
(instead of `all`) which only extracts static init from archive members which
would otherwise be referenced.
(See https://www.ibm.com/docs/en/aix/7.2.0?topic=l-ld-command for details).
-- The driver now uses ``-lcompiler_rt`` instead of ``-latomic`` to avoid conflicts
+- The driver now uses ``-lcompiler_rt`` instead of ``-latomic``, and the compiler-rt
+ archive has been renamed from ``libatomic.a`` to ``libcompiler_rt.a`` to avoid conflicts
between the LLVM libatomic and the GNU libatomic from the AIX toolbox as they share
the same library name.
More information about the cfe-commits
mailing list