Author: Alison Zhang Date: 2026-05-21T14:58:44-04:00 New Revision: d5ba663c28ec6374f02e630f79459d4ef639f51c
URL: https://github.com/llvm/llvm-project/commit/d5ba663c28ec6374f02e630f79459d4ef639f51c DIFF: https://github.com/llvm/llvm-project/commit/d5ba663c28ec6374f02e630f79459d4ef639f51c.diff LOG: [AIX][clang][compiler_rt] rename libatomic archive to libclang_rt (#197485) This PR implements the following on AIX to avoid conflicts between LLVM libatomic and the GNU libatomic in the AIX toolbox as they share the same library name: - Updates the clang driver to use `-lcompiler_rt` instead of `-latomic` - Renames the compiler-rt archive from `libatomic.a` to `libcompiler_rt.a` Only the archive and not the shared object (`libatomic.so.1`) is renamed because renaming one component is enough to distinguish between the LLVM and GNU libatomic libraries. This also allows us to add additional shared objects to the `libcompiler_rt.a` archive in the future if needed. Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/AIX.cpp clang/test/Driver/fprofile-update.c compiler-rt/lib/builtins/CMakeLists.txt Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a9017f44058be..a490dc5469a27 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -771,6 +771,10 @@ 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``, 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. NetBSD Support ^^^^^^^^^^^^^^ diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 21d61a60224cb..511eb3757456b 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -978,7 +978,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" diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 3fa21578c86ad..3d18bdd8a80af 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -1137,10 +1137,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() _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
