@@ -35,27 +35,18 @@ static void addDashXForInput(const ArgList &Args, const InputInfo &Input,
35
35
36
36
void Flang::addFortranDialectOptions (const ArgList &Args,
37
37
ArgStringList &CmdArgs) const {
38
- Args.addAllArgs (CmdArgs, {options::OPT_ffixed_form,
39
- options::OPT_ffree_form,
40
- options::OPT_ffixed_line_length_EQ,
41
- options::OPT_fopenmp,
42
- options::OPT_fopenmp_version_EQ,
43
- options::OPT_fopenacc,
44
- options::OPT_finput_charset_EQ,
45
- options::OPT_fimplicit_none,
46
- options::OPT_fno_implicit_none,
47
- options::OPT_fbackslash,
48
- options::OPT_fno_backslash,
49
- options::OPT_flogical_abbreviations,
50
- options::OPT_fno_logical_abbreviations,
51
- options::OPT_fxor_operator,
52
- options::OPT_fno_xor_operator,
53
- options::OPT_falternative_parameter_statement,
54
- options::OPT_fdefault_real_8,
55
- options::OPT_fdefault_integer_8,
56
- options::OPT_fdefault_double_8,
57
- options::OPT_flarge_sizes,
58
- options::OPT_fno_automatic});
38
+ Args.addAllArgs (
39
+ CmdArgs, {options::OPT_ffixed_form, options::OPT_ffree_form,
40
+ options::OPT_ffixed_line_length_EQ, options::OPT_fopenacc,
41
+ options::OPT_finput_charset_EQ, options::OPT_fimplicit_none,
42
+ options::OPT_fno_implicit_none, options::OPT_fbackslash,
43
+ options::OPT_fno_backslash, options::OPT_flogical_abbreviations,
44
+ options::OPT_fno_logical_abbreviations,
45
+ options::OPT_fxor_operator, options::OPT_fno_xor_operator,
46
+ options::OPT_falternative_parameter_statement,
47
+ options::OPT_fdefault_real_8, options::OPT_fdefault_integer_8,
48
+ options::OPT_fdefault_double_8, options::OPT_flarge_sizes,
49
+ options::OPT_fno_automatic});
59
50
}
60
51
61
52
void Flang::addPreprocessingOptions (const ArgList &Args,
@@ -763,6 +754,35 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
763
754
// Add other compile options
764
755
addOtherOptions (Args, CmdArgs);
765
756
757
+ // Forward flags for OpenMP. We don't do this if the current action is an
758
+ // device offloading action other than OpenMP.
759
+ if (Args.hasFlag (options::OPT_fopenmp, options::OPT_fopenmp_EQ,
760
+ options::OPT_fno_openmp, false ) &&
761
+ (JA.isDeviceOffloading (Action::OFK_None) ||
762
+ JA.isDeviceOffloading (Action::OFK_OpenMP))) {
763
+ switch (D.getOpenMPRuntime (Args)) {
764
+ case Driver::OMPRT_OMP:
765
+ case Driver::OMPRT_IOMP5:
766
+ // Clang can generate useful OpenMP code for these two runtime libraries.
767
+ CmdArgs.push_back (" -fopenmp" );
768
+ Args.AddAllArgs (CmdArgs, options::OPT_fopenmp_version_EQ);
769
+
770
+ // FIXME: Clang supports a whole bunch more flags here.
771
+ break ;
772
+ default :
773
+ // By default, if Clang doesn't know how to generate useful OpenMP code
774
+ // for a specific runtime library, we just don't pass the '-fopenmp' flag
775
+ // down to the actual compilation.
776
+ // FIXME: It would be better to have a mode which *only* omits IR
777
+ // generation based on the OpenMP support so that we get consistent
778
+ // semantic analysis, etc.
779
+ const Arg *A = Args.getLastArg (options::OPT_fopenmp_EQ);
780
+ D.Diag (diag::warn_drv_unsupported_openmp_library)
781
+ << A->getSpelling () << A->getValue ();
782
+ break ;
783
+ }
784
+ }
785
+
766
786
// Offloading related options
767
787
addOffloadOptions (C, Inputs, JA, Args, CmdArgs);
768
788
0 commit comments