Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -441,6 +441,13 @@ add_definitions(-DCLANG_ENABLE_STATIC_ANALYZER) endif() +set(OPENMP_DEFAULT_LIB "" CACHE STRING + "OpenMP library used with -fopenmp.") + +if( OPENMP_DEFAULT_LIB ) + add_definitions( -DOPENMP_DEFAULT_LIB="${OPENMP_DEFAULT_LIB} " ) +endif() + # Clang version information set(CLANG_EXECUTABLE_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}" CACHE STRING Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -6279,16 +6279,23 @@ Args.AddAllArgs(CmdArgs, options::OPT_L); LibOpenMP UsedOpenMPLib = LibUnknown; - if (const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ)) { - UsedOpenMPLib = llvm::StringSwitch(A->getValue()) + auto OpenMPStringToVersion = [](StringRef OpenMPString) { + return llvm::StringSwitch(OpenMPString) .Case("libgomp", LibGOMP) .Case("libiomp5", LibIOMP5) .Default(LibUnknown); + }; + if (const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ)) { + UsedOpenMPLib = OpenMPStringToVersion(A->getValue()); if (UsedOpenMPLib == LibUnknown) getToolChain().getDriver().Diag(diag::err_drv_unsupported_option_argument) << A->getOption().getName() << A->getValue(); } else if (Args.hasArg(options::OPT_fopenmp)) { +#if defined(OPENMP_DEFAULT_LIB) + UsedOpenMPLib = OpenMPStringToVersion(OPENMP_DEFAULT_LIB); +#else UsedOpenMPLib = LibIOMP5; +#endif } switch (UsedOpenMPLib) { case LibGOMP: