[PATCH] [OPENMP] Added option -fopenmp=libiomp5

Alexey Bataev a.bataev at hotmail.com
Thu Feb 27 03:24:50 PST 2014


  Full patch rework.

Hi gribozavr, doug.gregor, hfinkel, cbergstrom, fraggamuffin,

http://llvm-reviews.chandlerc.com/D2841

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2841?vs=7240&id=7393#toc

Files:
  test/OpenMP/parallel_ast_print.cpp
  test/OpenMP/simd_ast_print.cpp
  test/OpenMP/threadprivate_ast_print.cpp
  test/OpenMP/linking.c
  include/clang/Driver/Options.td
  lib/Frontend/CompilerInvocation.cpp
  lib/Driver/Tools.cpp

Index: test/OpenMP/parallel_ast_print.cpp
===================================================================
--- test/OpenMP/parallel_ast_print.cpp
+++ test/OpenMP/parallel_ast_print.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
 // expected-no-diagnostics
 
 #ifndef HEADER
Index: test/OpenMP/simd_ast_print.cpp
===================================================================
--- test/OpenMP/simd_ast_print.cpp
+++ test/OpenMP/simd_ast_print.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
 // expected-no-diagnostics
 
 #ifndef HEADER
Index: test/OpenMP/threadprivate_ast_print.cpp
===================================================================
--- test/OpenMP/threadprivate_ast_print.cpp
+++ test/OpenMP/threadprivate_ast_print.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print
 // expected-no-diagnostics
 
 #ifndef HEADER
Index: test/OpenMP/linking.c
===================================================================
--- test/OpenMP/linking.c
+++ test/OpenMP/linking.c
@@ -1,5 +1,5 @@
 // Test the that the driver produces reasonable linker invocations with
-// -fopenmp.
+// -fopenmp or -fopenmp=libiomp5.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -fopenmp -target i386-unknown-linux \
@@ -14,3 +14,26 @@
 // CHECK-LD-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD-64: "-lgomp" "-lrt" "-lgcc"
 // CHECK-LD-64: "-lpthread" "-lc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -fopenmp=libiomp5 -target i386-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-IOMP5-LD-32 %s
+// CHECK-IOMP5-LD-32: "{{.*}}ld{{(.exe)?}}"
+// CHECK-IOMP5-LD-32: "-liomp5"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -fopenmp=libiomp5 -target x86_64-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-IOMP5-LD-64 %s
+// CHECK-IOMP5-LD-64: "{{.*}}ld{{(.exe)?}}"
+// CHECK-IOMP5-LD-64: "-liomp5"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -fopenmp=lib -target i386-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-LIB-LD-32 %s
+// CHECK-LIB-LD-32: error: unsupported argument 'lib' to option 'fopenmp='
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -fopenmp=lib -target x86_64-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-LIB-LD-64 %s
+// CHECK-LIB-LD-64: error: unsupported argument 'lib' to option 'fopenmp='
+//
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -739,6 +739,7 @@
 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]>;
+def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>, Flags<[CC1Option]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Group<f_Group>;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, Group<f_Group>;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1430,8 +1430,9 @@
     Opts.setMSPointerToMemberRepresentationMethod(InheritanceModel);
   }
 
-  // Check if -fopenmp is specified.
-  Opts.OpenMP = Args.hasArg(OPT_fopenmp);
+  // Check if -fopenmp= is specified.
+  Opts.OpenMP =  Args.hasArg(options::OPT_fopenmp) ||
+                 Args.hasArg(options::OPT_fopenmp_EQ);
 
   // Record whether the __DEPRECATED define was requested.
   Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5234,9 +5234,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
-  if (Args.hasArg(options::OPT_fopenmp))
+  if (Args.hasArg(options::OPT_fopenmp)) {
     // This is more complicated in gcc...
     CmdArgs.push_back("-lgomp");
+  } else if (const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ)) {
+    if (StringRef(A->getValue()) == "libiomp5")
+      CmdArgs.push_back("-liomp5");
+    else
+      getToolChain().getDriver().Diag(diag::err_drv_unsupported_option_argument)
+        << A->getOption().getName() << A->getValue();
+  }
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   
@@ -6831,6 +6838,12 @@
         // FIXME: Exclude this for platforms with libgomp that don't require
         // librt. Most modern Linux platforms require it, but some may not.
         CmdArgs.push_back("-lrt");
+      } else if (const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ)) {
+        if (StringRef(A->getValue()) == "libiomp5")
+          CmdArgs.push_back("-liomp5");
+        else
+          D.Diag(diag::err_drv_unsupported_option_argument)
+            << A->getOption().getName() << A->getValue();
       }
 
       AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2841.2.patch
Type: text/x-patch
Size: 6131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140227/31120198/attachment.bin>


More information about the cfe-commits mailing list