]> granicus.if.org Git - clang/commitdiff
[OPENMP] Added option -fopenmp=libiomp5|libgomp
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 6 Mar 2014 05:43:53 +0000 (05:43 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 6 Mar 2014 05:43:53 +0000 (05:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203081 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
include/clang/Driver/Options.td
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
test/OpenMP/linking.c
test/OpenMP/openmp_common.c
test/OpenMP/parallel_ast_print.cpp
test/OpenMP/parallel_default_messages.cpp
test/OpenMP/parallel_firstprivate_messages.cpp
test/OpenMP/parallel_if_messages.cpp
test/OpenMP/parallel_messages.cpp
test/OpenMP/parallel_private_messages.cpp
test/OpenMP/parallel_shared_messages.cpp
test/OpenMP/predefined_macro.c
test/OpenMP/simd_ast_print.cpp
test/OpenMP/simd_misc_messages.c
test/OpenMP/threadprivate_ast_print.cpp
test/OpenMP/threadprivate_messages.cpp

index 4b90e43754ffd1eb310f3b21c637cde1b243b959..2a48e6f41952563d88b310619e1f70cb65392bc4 100644 (file)
@@ -741,7 +741,8 @@ def fno_objc_nonfragile_abi : Flag<["-"], "fno-objc-nonfragile-abi">, Group<f_Gr
 
 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 : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>;
+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 abc8f7dc9af6d2ffe355b6d7b4b4fdd99e6e62a2..70c06466bfd153532ffcb39360ccc21d1e86167b 100644 (file)
@@ -5190,6 +5190,12 @@ void darwin::Link::AddLinkArgs(Compilation &C,
   Args.AddLastArg(CmdArgs, options::OPT_Mach);
 }
 
+enum LibOpenMP {
+  LibUnknown,
+  LibGOMP,
+  LibIOMP5
+};
+
 void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
                                 const InputInfo &Output,
                                 const InputInfoList &Inputs,
@@ -5241,9 +5247,28 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
-  if (Args.hasArg(options::OPT_fopenmp))
-    // This is more complicated in gcc...
+  LibOpenMP UsedOpenMPLib = LibUnknown;
+  if (Args.hasArg(options::OPT_fopenmp)) {
+    UsedOpenMPLib = LibGOMP;
+  } else if (const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ)) {
+    UsedOpenMPLib = llvm::StringSwitch<LibOpenMP>(A->getValue())
+        .Case("libgomp",  LibGOMP)
+        .Case("libiomp5", LibIOMP5)
+        .Default(LibUnknown);
+    if (UsedOpenMPLib == LibUnknown)
+      getToolChain().getDriver().Diag(diag::err_drv_unsupported_option_argument)
+        << A->getOption().getName() << A->getValue();
+  }
+  switch (UsedOpenMPLib) {
+  case LibGOMP:
     CmdArgs.push_back("-lgomp");
+    break;
+  case LibIOMP5:
+    CmdArgs.push_back("-liomp5");
+    break;
+  case LibUnknown:
+    break;
+  }
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   
@@ -6856,19 +6881,36 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
       if (Args.hasArg(options::OPT_static))
         CmdArgs.push_back("--start-group");
 
-      bool OpenMP = Args.hasArg(options::OPT_fopenmp);
-      if (OpenMP) {
+      LibOpenMP UsedOpenMPLib = LibUnknown;
+      if (Args.hasArg(options::OPT_fopenmp)) {
+        UsedOpenMPLib = LibGOMP;
+      } else if (const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ)) {
+        UsedOpenMPLib = llvm::StringSwitch<LibOpenMP>(A->getValue())
+            .Case("libgomp",  LibGOMP)
+            .Case("libiomp5", LibIOMP5)
+            .Default(LibUnknown);
+        if (UsedOpenMPLib == LibUnknown)
+          D.Diag(diag::err_drv_unsupported_option_argument)
+            << A->getOption().getName() << A->getValue();
+      }
+      switch (UsedOpenMPLib) {
+      case LibGOMP:
         CmdArgs.push_back("-lgomp");
 
         // 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");
+        break;
+      case LibIOMP5:
+        CmdArgs.push_back("-liomp5");
+        break;
+      case LibUnknown:
+        break;
       }
-
       AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
       if (Args.hasArg(options::OPT_pthread) ||
-          Args.hasArg(options::OPT_pthreads) || OpenMP)
+          Args.hasArg(options::OPT_pthreads) || UsedOpenMPLib == LibGOMP)
         CmdArgs.push_back("-lpthread");
 
       CmdArgs.push_back("-lc");
index f8cb938866154ca0ad30c7325e2e9c59bb8471f5..d28af7c469fa365467c8dd09523689bbc761c6e9 100644 (file)
@@ -1431,8 +1431,12 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
     Opts.setMSPointerToMemberRepresentationMethod(InheritanceModel);
   }
 
-  // Check if -fopenmp is specified.
-  Opts.OpenMP = Args.hasArg(OPT_fopenmp);
+  // Check if -fopenmp= is specified.
+  if (const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ)) {
+    Opts.OpenMP = llvm::StringSwitch<bool>(A->getValue())
+        .Case("libiomp5", true)
+        .Default(false);
+  }
 
   // Record whether the __DEPRECATED define was requested.
   Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
index 31fd57de9267e7880ee6aad74021ca17c9e8e533..586e4606d100fef870ea23196b1906589058d344 100644 (file)
@@ -1,5 +1,5 @@
 // Test the that the driver produces reasonable linker invocations with
-// -fopenmp.
+// -fopenmp or -fopenmp=libiomp5|libgomp.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -fopenmp -target i386-unknown-linux \
 // 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=libgomp -target i386-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-GOMP-LD-32 %s
+// CHECK-GOMP-LD-32: "{{.*}}ld{{(.exe)?}}"
+// CHECK-GOMP-LD-32: "-lgomp" "-lrt" "-lgcc"
+// CHECK-GOMP-LD-32: "-lpthread" "-lc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -fopenmp=libgomp -target x86_64-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-GOMP-LD-64 %s
+// CHECK-GOMP-LD-64: "{{.*}}ld{{(.exe)?}}"
+// CHECK-GOMP-LD-64: "-lgomp" "-lrt" "-lgcc"
+// CHECK-GOMP-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='
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -fopenmp -fopenmp=libiomp5 -target i386-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-WARN-32 %s
+// CHECK-LD-WARN-32: warning: argument unused during compilation: '-fopenmp=libiomp5'
+// CHECK-LD-WARN-32: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-WARN-32: "-lgomp" "-lrt" "-lgcc"
+// CHECK-LD-WARN-32: "-lpthread" "-lc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -fopenmp -fopenmp=libiomp5 -target x86_64-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-WARN-64 %s
+// CHECK-LD-WARN-64: warning: argument unused during compilation: '-fopenmp=libiomp5'
+// CHECK-LD-WARN-64: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-WARN-64: "-lgomp" "-lrt" "-lgcc"
+// CHECK-LD-WARN-64: "-lpthread" "-lc"
+//
index 3765f4c5dc14c9f2b71d33973f1b33075f26bdd4..3131b3045b6f4559903661af48516debcebb8b95 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -o - %s
 
 #pragma omp // expected-error {{expected an OpenMP directive}}
 #pragma omp unknown_directive // expected-error {{expected an OpenMP directive}}
index e76a410522e8b6e454392009e0b7ed3697fe539a..bd5171435e5263e2bfea630ff10e23239c3c0962 100644 (file)
@@ -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 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %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 cbc6a73fe35df94512523e1837b32644047825fd..6014cdfd4bcc30cdc56ac37dce7acf5cc040992b 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -o - %s
 
 void foo();
 
index 780059e282bf51eaae324226cfd27915057f94ef..9df45c60e708e709b54fe53f22f82039d968756a 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
 
 void foo() {
 }
index 97096dfae3e8919abb95d8ded861c378f272bf63..1559692a989d675f7afa34966b6f0ac31896b108 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
 
 void foo() {
 }
index 8aee8414f0340728b0ac26fbfc300ae4d2c1cad9..1e0edbc6f80865e429c4c184df4e057e71b8867a 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -std=c++11 -o - %s
 
 void foo() {
 }
index 2037d56daf0c024042df8c6cf798e1d2495f4773..6dc55e55747e0e58133eba540c9a8a744f92333c 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
 
 void foo() {
 }
index 211d392fe04ea39235c693f9e28d876ccf498b65..8363989439be367d7037937168a6d9d96a0c42bb 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
 
 void foo() {
 }
index 3a8118620962b7d53852b83374aa529480dff842..06f98793fb91acc10b2dcd749f1f32af62454ba6 100644 (file)
@@ -1,32 +1,32 @@
-// RUN: %clang_cc1 -fopenmp -verify -DFOPENMP -o - %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -verify -DFOPENMP -o - %s
 // RUN: %clang_cc1 -verify -o - %s
 // expected-no-diagnostics
 #ifdef FOPENMP
-// -fopenmp option is specified
+// -fopenmp=libiomp5 option is specified
 #ifndef _OPENMP
 #error "No _OPENMP macro is defined with -fopenmp option"
 #elsif _OPENMP != 201107
 #error "_OPENMP has incorrect value"
 #endif //_OPENMP
 #else
-// No -fopenmp option is specified
+// No -fopenmp=libiomp5 option is specified
 #ifdef _OPENMP
 #error "_OPENMP macro is defined without -fopenmp option"
 #endif // _OPENMP
 #endif // FOPENMP
 
-// RUN: %clang_cc1 -fopenmp -verify -DFOPENMP -o - %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -verify -DFOPENMP -o - %s
 // RUN: %clang_cc1 -verify -o - %s
 // expected-no-diagnostics
 #ifdef FOPENMP
-// -fopenmp option is specified
+// -fopenmp=libiomp5 option is specified
 #ifndef _OPENMP
 #error "No _OPENMP macro is defined with -fopenmp option"
 #elsif _OPENMP != 201107
 #error "_OPENMP has incorrect value"
 #endif // _OPENMP
 #else
-// No -fopenmp option is specified
+// No -fopenmp=libiomp5 option is specified
 #ifdef _OPENMP
 #error "_OPENMP macro is defined without -fopenmp option"
 #endif // _OPENMP
index 7cdf131b0849e9e8a2b790f13de929cc1d1959ab..fd9668c436315b449b1e36f7f62bacae2523438b 100644 (file)
@@ -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 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %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 90a7bb441e36ecd7693441885110f7a8d74f8cd6..622c4389b5f52feb86fa02c1d2532cae29c408a6 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s
 
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp simd'}}
 #pragma omp simd
index 1cbc0165c3f30ce6bb65e34e52c5eaeb524d5a98..bf3b30550adcf33a543bd47c73b916aeee2757a7 100644 (file)
@@ -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 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print
 // expected-no-diagnostics
 
 #ifndef HEADER
index 943fca51058ceca5ad727e52c67ba01f8a181edf..4e50c6f9d46b474d5173e3eb1a4785c00365429f 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
 
 #pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}}
 #pragma omp threadprivate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}