Author: Joseph Huber Date: 2023-01-24T17:01:35-06:00 New Revision: dc60f7aa0435a4e4778cfbf22f4fcb52c97427c0
URL: https://github.com/llvm/llvm-project/commit/dc60f7aa0435a4e4778cfbf22f4fcb52c97427c0 DIFF: https://github.com/llvm/llvm-project/commit/dc60f7aa0435a4e4778cfbf22f4fcb52c97427c0.diff LOG: [OpenMP] Unconditionally link the OpenMP device RTL static library Currently we have two versions of the static library. One is built as individual bitcode files and linked via `-mlink-builtin-bitcode`. The other is built as a single static archive `omptarget.devicertl.a` and is linked via `-lomptarget.devicertl` and handled by the linker wrapper during LTO. We use the former in the case that we are not performing LTO, because linking the library late wouldn't allow us to optimize the runtime library effectively. The support in D142484 allows us to unconditionally link this library, so it will only be pulled in if needed. That is, if we linked already via `-mlink-builtin-bitcode` then we will not pull in the static library even if it's linked on the command line. Depends on D142484 Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D142486 Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/openmp-offload-gpu.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 822a60c151ff0..0883631dfe98f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -873,8 +873,7 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, if (IsOffloadingHost) CmdArgs.push_back("-lomptarget"); - if (IsOffloadingHost && TC.getDriver().isUsingLTO(/* IsOffload */ true) && - !Args.hasArg(options::OPT_nogpulib)) + if (IsOffloadingHost && !Args.hasArg(options::OPT_nogpulib)) CmdArgs.push_back("-lomptarget.devicertl"); addArchSpecificRPath(TC, Args, CmdArgs); diff --git a/clang/test/Driver/openmp-offload-gpu.c b/clang/test/Driver/openmp-offload-gpu.c index b1e1954a93594..da8ebd6ac5624 100644 --- a/clang/test/Driver/openmp-offload-gpu.c +++ b/clang/test/Driver/openmp-offload-gpu.c @@ -341,6 +341,11 @@ // CHECK-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 \ +// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LTO-LIBRARY %s + +// CHECK-NO-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl + // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \ // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LIBRARY %s _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits