[clang] [OpenMP][AIX] Add libpthreads for -fopenmp (PR #184629)

via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 4 07:02:40 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-openmp

Author: Xing Xue (xingxue-ibm)

<details>
<summary>Changes</summary>

The compiler uses TLS for thread‑private data, which results in references to symbols such as `__tls_get_addr` in `libpthreads`. Therefore, this PR adds `libpthreads` to the link command when `-fopenmp` is specified.

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


1 Files Affected:

- (modified) clang/lib/Driver/ToolChains/AIX.cpp (+2) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 2078ad57aee18..e7f4792ac5bba 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -310,6 +310,8 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
           // Already diagnosed.
           break;
         }
+        // libpthreads is required for -fopenmp.
+        CmdArgs.push_back("-lpthreads");
       }
 
       // Support POSIX threads if "-pthreads" or "-pthread" is present.

``````````

</details>


https://github.com/llvm/llvm-project/pull/184629


More information about the cfe-commits mailing list