[PATCH] D53476: [clang-cl] Allowed -fopenmp work and link openmp library from per-runtime library directory

Peiyuan Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 21 01:52:00 PDT 2018


SquallATF created this revision.
Herald added subscribers: cfe-commits, guansong.

clang-cl driver has -fopenmp related code, but -fopenmp not alloewd press to clang-cl driver, this patch fixed it and allowed link to multiarch openmp library.


Repository:
  rC Clang

https://reviews.llvm.org/D53476

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/MSVC.cpp
  test/OpenMP/Inputs/resource_dir/x86_64-msvc-win32/lib/.keep
  test/OpenMP/linking.c


Index: test/OpenMP/linking.c
===================================================================
--- test/OpenMP/linking.c
+++ test/OpenMP/linking.c
@@ -83,11 +83,12 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -fopenmp=libomp -target x86_64-msvc-win32 -rtlib=platform \
+// RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=CHECK-MSVC-LINK-64 %s
 // CHECK-MSVC-LINK-64: link.exe
 // CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcomp.lib
 // CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcompd.lib
-// CHECK-MSVC-LINK-64-SAME: -libpath:{{.+}}/../lib
+// CHECK-MSVC-LINK-64-SAME: -libpath:{{.+[/\\]}}x86_64-msvc-win32{{/|\\\\}}lib
 // CHECK-MSVC-LINK-64-SAME: -defaultlib:libomp.lib
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target x86_64-msvc-win32 -rtlib=platform | FileCheck --check-prefix SIMD-ONLY11 %s
@@ -97,6 +98,7 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -fopenmp=libiomp5 -target x86_64-msvc-win32 -rtlib=platform \
+// RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=CHECK-MSVC-ILINK-64 %s
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target x86_64-msvc-win32 -rtlib=platform | FileCheck --check-prefix SIMD-ONLY11 %s
@@ -106,6 +108,6 @@
 // CHECK-MSVC-ILINK-64: link.exe
 // CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcomp.lib
 // CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcompd.lib
-// CHECK-MSVC-ILINK-64-SAME: -libpath:{{.+}}/../lib
+// CHECK-MSVC-ILINK-64-SAME: -libpath:{{.+[/\\]}}x86_64-msvc-win32{{/|\\\\}}lib
 // CHECK-MSVC-ILINK-64-SAME: -defaultlib:libiomp5md.lib
 //
Index: lib/Driver/ToolChains/MSVC.cpp
===================================================================
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -422,8 +422,9 @@
                    options::OPT_fno_openmp, false)) {
     CmdArgs.push_back("-nodefaultlib:vcomp.lib");
     CmdArgs.push_back("-nodefaultlib:vcompd.lib");
-    CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-                                         TC.getDriver().Dir + "/../lib"));
+    for (const auto &LibPath : TC.getLibraryPaths()) {
+      CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") + LibPath));
+    }
     switch (TC.getDriver().getOpenMPRuntime(Args)) {
     case Driver::OMPRT_OMP:
       CmdArgs.push_back("-defaultlib:libomp.lib");
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1516,11 +1516,11 @@
 
 def fobjc_sender_dependent_dispatch : Flag<["-"], "fobjc-sender-dependent-dispatch">, Group<f_Group>;
 def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group<f_Group>;
-def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>,
+def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, CoreOption, NoArgumentUnused]>,
   HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group<f_Group>, Flags<[NoArgumentUnused]>;
 def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>;
-def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>;
+def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>, Flags<[CoreOption]>;
 def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group<f_Group>,
   Flags<[NoArgumentUnused, HelpHidden]>;
 def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group<f_Group>,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53476.170331.patch
Type: text/x-patch
Size: 3657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181021/288fd75f/attachment-0001.bin>


More information about the cfe-commits mailing list