Author: Xing Xue Date: 2023-01-19T12:46:22-05:00 New Revision: b05fa4faf64d6c6811bbecead13dc7c23ac43aca
URL: https://github.com/llvm/llvm-project/commit/b05fa4faf64d6c6811bbecead13dc7c23ac43aca DIFF: https://github.com/llvm/llvm-project/commit/b05fa4faf64d6c6811bbecead13dc7c23ac43aca.diff LOG: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified Summary: This patch adds OpenMP runtime to the linker command line if -fopenmp is specifed for AIX. Reviewed by: daltenty Differential Revision: https://reviews.llvm.org/D141862 Added: Modified: clang/lib/Driver/ToolChains/AIX.cpp clang/test/Driver/aix-ld.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp index 5f893ba6e8918..abbd3ef6c68f3 100644 --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -243,6 +243,25 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA, 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"); diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c index 42631f4c59eee..ddf3ae7a2ecb4 100644 --- a/clang/test/Driver/aix-ld.c +++ b/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:0x10000000" "-bpD:0x20000000" +// 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=' _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits