https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/70593
>From 261f571d28b8398be221f3928f93bcee211e26ae Mon Sep 17 00:00:00 2001
From: Brad Smith
Date: Sun, 29 Oct 2023 09:02:12 -0400
Subject: [PATCH] [OpenMP] Add support for Solaris/x86_64
Tested on `amd64-pc-solaris2.11`.
---
clang/lib/Driver/ToolChains/Solaris.cpp | 5 +
clang/test/Driver/fopenmp.c | 19 +++-
openmp/runtime/cmake/LibompHandleFlags.cmake | 2 +-
openmp/runtime/src/kmp.h | 8 +--
openmp/runtime/src/kmp_ftn_entry.h | 2 +-
openmp/runtime/src/kmp_platform.h| 11 --
openmp/runtime/src/kmp_runtime.cpp | 8 ---
openmp/runtime/src/z_Linux_util.cpp | 23 +++-
8 files changed, 62 insertions(+), 16 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 3d5a710842eca44..958ed99c482ed22 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -215,6 +215,11 @@ void solaris::Linker::ConstructJob(Compilation , const
JobAction ,
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
+// Use the static OpenMP runtime with -static-openmp
+bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
+!Args.hasArg(options::OPT_static);
+addOpenMPRuntime(CmdArgs, getToolChain(), Args, StaticOpenMP);
+
if (D.CCCIsCXX()) {
if (getToolChain().ShouldLinkCXXStdlib(Args))
getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
diff --git a/clang/test/Driver/fopenmp.c b/clang/test/Driver/fopenmp.c
index cf04340ebc06ac6..291946923b3ea3d 100644
--- a/clang/test/Driver/fopenmp.c
+++ b/clang/test/Driver/fopenmp.c
@@ -16,6 +16,9 @@
// RUN: %clang -target x86_64-dragonfly -fopenmp=libomp -c %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
// RUN: %clang -target x86_64-dragonfly -fopenmp=libgomp -c %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP
// RUN: %clang -target x86_64-dragonfly -fopenmp=libiomp5 -c %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libomp -c %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libgomp -c %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libiomp5 -c %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
// RUN: %clang -target x86_64-windows-gnu -fopenmp=libomp -c %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
// RUN: %clang -target x86_64-windows-gnu -fopenmp=libgomp -c %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP
// RUN: %clang -target x86_64-windows-gnu -fopenmp=libiomp5 -c %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
@@ -106,6 +109,19 @@
// RUN: %clang -nostdlib -target x86_64-dragonfly -fopenmp=libgomp %s -o %t
-### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
// RUN: %clang -nostdlib -target x86_64-dragonfly -fopenmp=libiomp5 %s -o %t
-### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
//
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libomp %s -o %t -### 2>&1
| FileCheck %s --check-prefix=CHECK-LD-OMP
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libgomp %s -o %t -### 2>&1
| FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libiomp5 %s -o %t -###
2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
+//
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libomp -static-openmp %s
-o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libgomp -static-openmp %s
-o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP
--check-prefix=CHECK-LD-STATIC-GOMP-NO-RT
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libiomp5 -static-openmp %s
-o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+// RUN: %clang -target i386-pc-solaris2.11 -fopenmp=libiomp5 -static
-static-openmp %s -o %t -### 2>&1 | FileCheck %s
--check-prefix=CHECK-LD-STATIC-IOMP5-NO-BDYNAMIC
+//
+// RUN: %clang -nostdlib -target i386-pc-solaris2.11 -fopenmp=libomp %s -o %t
-### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
+// RUN: %clang -nostdlib -target i386-pc-solaris2.11 -fopenmp=libgomp %s -o %t
-### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
+// RUN: %clang -nostdlib -target i386-pc-solaris2.11 -fopenmp=libiomp5 %s -o
%t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
+//
// RUN: %clang -target x86_64-windows-gnu -fopenmp=libomp %s -o %t -### 2>&1 |
FileCheck %s --check-prefix=CHECK-LD-OMP
// RUN: %clang -target x86_64-windows-gnu -fopenmp=libgomp %s -o %t -### 2>&1
| FileCheck %s