[PATCH] D141862: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-19 Thread Xing Xue via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
xingxue marked an inline comment as done.
Closed by commit rGb05fa4faf64d: [clang][driver][AIX] Add OpenMP runtime if 
-fopenmp specified (authored by xingxue).

Changed prior to commit:
  https://reviews.llvm.org/D141862?vs=490167=490563#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141862/new/

https://reviews.llvm.org/D141862

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1016,3 +1016,68 @@
 // CHECK-LD64-SHARED-EXPFULL: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-SHARED-EXPFULL: "-lm"
 // CHECK-LD64-SHARED-EXPFULL: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp to use default OpenMP runtime libomp.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp \
+// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s
+// CHECK-FOPENMP-NOT: warning:
+// CHECK-FOPENMP: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-FOPENMP: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-FOPENMP: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-FOPENMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-FOPENMP-NOT: "-bnso"
+// CHECK-FOPENMP: "-b32"
+// CHECK-FOPENMP: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-FOPENMP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-FOPENMP: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-FOPENMP-NOT: "-lc++"
+// CHECK-FOPENMP-NOT: "-lc++abi"
+// CHECK-FOPENMP: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-FOPENMP-NOT: "--as-needed"
+// CHECK-FOPENMP: "-lunwind"
+// CHECK-FOPENMP-NOT: "--no-as-needed"
+// CHECK-FOPENMP-NOT: "-lm"
+// CHECK-FOPENMP-OMP: "-lomp"
+// CHECK-FOPENMP-IOMP5:   "-liomp5"
+// CHECK-FOPENMP-GOMP:"-lgomp"
+// CHECK-FOPENMP: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libomp to specify libomp explicitly.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp=libomp \
+// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libiomp5 to specify libgomp explicitly.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp=libiomp5 \
+// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-IOMP5 %s
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libgomp to specify libgomp explicitly.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp=libgomp \
+// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-GOMP %s
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. -fopenmp=libfoo results an error.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:-fopenmp=libfoo \
+// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
+// CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,25 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+// Add OpenMP runtime if -fopenmp is specified.
+if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+ options::OPT_fno_openmp, false)) {
+  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
+CmdArgs.push_back("-lomp");
+break;
+  case Driver::OMPRT_IOMP5:
+CmdArgs.push_back("-liomp5");
+break;
+  case Driver::OMPRT_GOMP:
+CmdArgs.push_back("-lgomp");
+break;
+  case Driver::OMPRT_Unknown:
+// Already diagnosed.
+break;
+  }
+}
+
 // Support POSIX threads if "-pthreads" or "-pthread" is 

[PATCH] D141862: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-19 Thread Xing Xue via Phabricator via cfe-commits
xingxue added inline comments.



Comment at: clang/test/Driver/aix-ld.c:1027
+// RUN:-fopenmp \
+// RUN:   | FileCheck --check-prefix=CHECK-FOPENMP-OMP %s
+// CHECK-FOPENMP-OMP-NOT: warning:

daltenty wrote:
> nit: since the output for these tests are really the same, apart from one 
> line with the library name, we could use two prefixes, a common one and a 
> specific one to avoid repetition:
> ```
> // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s
> ```
> 
> and then the CHECK block can go something like this:
> ```
> ...
> // CHECK-FOPENMP-NOT: "-lm"
> // CHECK-FOPENMP-OMP: "-lomp"
> // CHECK-FOPENMP-IOMP5:  "-liomp5"
> // CHECK-FOPENMP-GOMP:   "-lgomp
> // CHECK-FOPENMP: "-lc"
> ...
> ```
Good suggestion, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141862/new/

https://reviews.llvm.org/D141862

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141862: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-19 Thread David Tenty via Phabricator via cfe-commits
daltenty accepted this revision.
daltenty added a comment.
This revision is now accepted and ready to land.

Some minor nits about how we can shorten the test, but otherwise LGTM




Comment at: clang/test/Driver/aix-ld.c:1027
+// RUN:-fopenmp \
+// RUN:   | FileCheck --check-prefix=CHECK-FOPENMP-OMP %s
+// CHECK-FOPENMP-OMP-NOT: warning:

nit: since the output for these tests are really the same, apart from one line 
with the library name, we could use two prefixes, a common one and a specific 
one to avoid repetition:
```
// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s
```

and then the CHECK block can go something like this:
```
...
// CHECK-FOPENMP-NOT: "-lm"
// CHECK-FOPENMP-OMP: "-lomp"
// CHECK-FOPENMP-IOMP5:  "-liomp5"
// CHECK-FOPENMP-GOMP:   "-lgomp
// CHECK-FOPENMP: "-lc"
...
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141862/new/

https://reviews.llvm.org/D141862

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141862: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-18 Thread Xing Xue via Phabricator via cfe-commits
xingxue updated this revision to Diff 490167.
xingxue added a comment.

Addressed comments.

- added test scenarios for option `fopenmp` in `clang/test/Driver/aix-ld.c`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141862/new/

https://reviews.llvm.org/D141862

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1016,3 +1016,76 @@
 // CHECK-LD64-SHARED-EXPFULL: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-SHARED-EXPFULL: "-lm"
 // CHECK-LD64-SHARED-EXPFULL: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp to use default OpenMP runtime libomp.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp \
+// RUN:   | FileCheck --check-prefix=CHECK-FOPENMP-OMP %s
+// CHECK-FOPENMP-OMP-NOT: warning:
+// CHECK-FOPENMP-OMP: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-FOPENMP-OMP: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-FOPENMP-OMP: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-FOPENMP-OMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-FOPENMP-OMP-NOT: "-bnso"
+// CHECK-FOPENMP-OMP: "-b32"
+// CHECK-FOPENMP-OMP: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-FOPENMP-OMP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-FOPENMP-OMP: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-FOPENMP-OMP-NOT: "-lc++"
+// CHECK-FOPENMP-OMP-NOT: "-lc++abi"
+// CHECK-FOPENMP-OMP: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-FOPENMP-OMP-NOT: "--as-needed"
+// CHECK-FOPENMP-OMP: "-lunwind"
+// CHECK-FOPENMP-OMP-NOT: "--no-as-needed"
+// CHECK-FOPENMP-OMP-NOT: "-lm"
+// CHECK-FOPENMP-OMP: "-lomp"
+// CHECK-FOPENMP-OMP: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libomp to specify libomp explicitly.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp=libomp \
+// RUN:   | FileCheck --check-prefix=CHECK-FOPENMP-OMP %s
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libgomp to specify libgomp explicitly.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp=libgomp \
+// RUN:   | FileCheck --check-prefix=CHECK-FOPENMP-GOMP %s
+// CHECK-FOPENMP-GOMP-NOT: warning:
+// CHECK-FOPENMP-GOMP: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-FOPENMP-GOMP: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-FOPENMP-GOMP: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-FOPENMP-GOMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-FOPENMP-GOMP-NOT: "-bnso"
+// CHECK-FOPENMP-GOMP: "-b32"
+// CHECK-FOPENMP-GOMP: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-FOPENMP-GOMP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-FOPENMP-GOMP: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-FOPENMP-GOMP-NOT: "-lc++"
+// CHECK-FOPENMP-GOMP-NOT: "-lc++abi"
+// CHECK-FOPENMP-GOMP: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-FOPENMP-GOMP-NOT: "--as-needed"
+// CHECK-FOPENMP-GOMP: "-lunwind"
+// CHECK-FOPENMP-GOMP-NOT: "--no-as-needed"
+// CHECK-FOPENMP-GOMP-NOT: "-lm"
+// CHECK-FOPENMP-GOMP: "-lgomp"
+// CHECK-FOPENMP-GOMP: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. -fopenmp=libfoo results an error.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:-fopenmp=libfoo \
+// RUN:   | FileCheck --check-prefix=CHECK-FOPENMP-FOO %s
+// CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,25 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+// Add OpenMP runtime if -fopenmp is specified.
+if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+ options::OPT_fno_openmp, false)) {
+  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
+CmdArgs.push_back("-lomp");
+break;
+  case Driver::OMPRT_IOMP5:
+

[PATCH] D141862: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-16 Thread David Tenty via Phabricator via cfe-commits
daltenty added a comment.

Needs a test, I think we should add a couple of `-fopenmp=foo` run lines to 
`clang/test/Driver/aix-ld.c` to verify that the correct linker options are 
produced for each.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141862/new/

https://reviews.llvm.org/D141862

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141862: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-16 Thread Xing Xue via Phabricator via cfe-commits
xingxue created this revision.
xingxue added reviewers: daltenty, cebowleratibm, kkwli0.
xingxue added a project: LLVM.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
xingxue requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

This patch adds OpenMP runtime to the linker command line if `-fopenmp` is 
specifed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141862

Files:
  clang/lib/Driver/ToolChains/AIX.cpp


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,25 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+// Add OpenMP runtime if -fopenmp is specified.
+if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+ options::OPT_fno_openmp, false)) {
+  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
+CmdArgs.push_back("-lomp");
+break;
+  case Driver::OMPRT_IOMP5:
+CmdArgs.push_back("-liomp5");
+break;
+  case Driver::OMPRT_GOMP:
+CmdArgs.push_back("-lgomp");
+break;
+  case Driver::OMPRT_Unknown:
+// Already diagnosed.
+break;
+  }
+}
+
 // Support POSIX threads if "-pthreads" or "-pthread" is present.
 if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
   CmdArgs.push_back("-lpthreads");


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,25 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+// Add OpenMP runtime if -fopenmp is specified.
+if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+ options::OPT_fno_openmp, false)) {
+  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
+CmdArgs.push_back("-lomp");
+break;
+  case Driver::OMPRT_IOMP5:
+CmdArgs.push_back("-liomp5");
+break;
+  case Driver::OMPRT_GOMP:
+CmdArgs.push_back("-lgomp");
+break;
+  case Driver::OMPRT_Unknown:
+// Already diagnosed.
+break;
+  }
+}
+
 // Support POSIX threads if "-pthreads" or "-pthread" is present.
 if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
   CmdArgs.push_back("-lpthreads");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits