r192867 - Add support to the Clang driver for forwarding all of gfortran's flags
Chandler Carruth
chandlerc at gmail.com
Wed Oct 16 20:28:24 PDT 2013
Author: chandlerc
Date: Wed Oct 16 22:28:24 2013
New Revision: 192867
URL: http://llvm.org/viewvc/llvm-project?rev=192867&view=rev
Log:
Add support to the Clang driver for forwarding all of gfortran's flags
to GCC when asked to compile a fortran input.
This fixes a regression with essentially every Fortran compile since we
started rejecting unknown flags. Also moves a mis-classified gfortran
flag into the nicely documented set.
Added:
cfe/trunk/test/Driver/gfortran.f90
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/lit.local.cfg
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=192867&r1=192866&r2=192867&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Oct 16 22:28:24 2013
@@ -190,7 +190,7 @@ def _HASH_HASH_HASH : Flag<["-"], "###">
HelpText<"Print the commands to run for this compilation">;
def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>,
Flags<[DriverOption, CoreOption]>;
-def A : JoinedOrSeparate<["-"], "A">;
+def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>;
def B : JoinedOrSeparate<["-"], "B">;
def CC : Flag<["-"], "CC">, Flags<[CC1Option]>;
def C : Flag<["-"], "C">, Flags<[CC1Option]>;
@@ -1420,8 +1420,6 @@ def fuse_ld_EQ : Joined<["-"], "fuse-ld=
defm align_functions : BooleanFFlag<"align-functions">, Group<clang_ignored_f_Group>;
def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group<clang_ignored_f_Group>;
-def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group<clang_ignored_f_Group>;
-
defm eliminate_unused_debug_types : BooleanFFlag<"eliminate-unused-debug-types">, Group<clang_ignored_f_Group>;
defm float_store : BooleanFFlag<"float-store">, Group<clang_ignored_f_Group>;
defm function_attribute_list : BooleanFFlag<"function-attribute-list">, Group<clang_ignored_f_Group>;
@@ -1453,6 +1451,85 @@ defm tree_vectorizer_verbose : BooleanFF
defm unroll_all_loops : BooleanFFlag<"unroll-all-loops">, Group<clang_ignored_f_Group>;
defm unswitch_loops : BooleanFFlag<"unswitch-loops">, Group<clang_ignored_f_Group>;
+
+// gfortran options that we recognize in the driver and pass along when
+// invoking GCC to compile Fortran code.
+def gfortran_Group : OptionGroup<"gfortran Group">;
+
+// Generic gfortran options.
+def A_DASH : Joined<["-"], "A-">, Group<gfortran_Group>;
+def J : JoinedOrSeparate<["-"], "J">, Flags<[RenderJoined]>, Group<gfortran_Group>;
+def cpp : Flag<["-"], "cpp">, Group<gfortran_Group>;
+def nocpp : Flag<["-"], "nocpp">, Group<gfortran_Group>;
+def static_libgfortran : Flag<["-"], "static-libgfortran">, Group<gfortran_Group>;
+
+// "f" options with values for gfortran.
+def fblas_matmul_limit_EQ : Joined<["-"], "fblas-matmul-limit=">, Group<gfortran_Group>;
+def fcheck_EQ : Joined<["-"], "fcheck=">, Group<gfortran_Group>;
+def fcoarray_EQ : Joined<["-"], "fcoarray=">, Group<gfortran_Group>;
+def fconvert_EQ : Joined<["-"], "fconvert=">, Group<gfortran_Group>;
+def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group<gfortran_Group>;
+def ffpe_trap_EQ : Joined<["-"], "ffpe-trap=">, Group<gfortran_Group>;
+def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, Group<gfortran_Group>;
+def finit_character_EQ : Joined<["-"], "finit-character=">, Group<gfortran_Group>;
+def finit_integer_EQ : Joined<["-"], "finit-integer=">, Group<gfortran_Group>;
+def finit_logical_EQ : Joined<["-"], "finit-logical=">, Group<gfortran_Group>;
+def finit_real_EQ : Joined<["-"], "finit-real=">, Group<gfortran_Group>;
+def fmax_array_constructor_EQ : Joined<["-"], "fmax-array-constructor=">, Group<gfortran_Group>;
+def fmax_errors_EQ : Joined<["-"], "fmax-errors=">, Group<gfortran_Group>;
+def fmax_stack_var_size_EQ : Joined<["-"], "fmax-stack-var-size=">, Group<gfortran_Group>;
+def fmax_subrecord_length_EQ : Joined<["-"], "fmax-subrecord-length=">, Group<gfortran_Group>;
+def frecord_marker_EQ : Joined<["-"], "frecord-marker=">, Group<gfortran_Group>;
+
+// "f" flags for gfortran.
+defm aggressive_function_elimination : BooleanFFlag<"aggressive-function-elimination">, Group<gfortran_Group>;
+defm align_commons : BooleanFFlag<"align-commons">, Group<gfortran_Group>;
+defm all_intrinsics : BooleanFFlag<"all-intrinsics">, Group<gfortran_Group>;
+defm automatic : BooleanFFlag<"automatic">, Group<gfortran_Group>;
+defm backslash : BooleanFFlag<"backslash">, Group<gfortran_Group>;
+defm backtrace : BooleanFFlag<"backtrace">, Group<gfortran_Group>;
+defm bounds_check : BooleanFFlag<"bounds-check">, Group<gfortran_Group>;
+defm check_array_temporaries : BooleanFFlag<"check-array-temporaries">, Group<gfortran_Group>;
+defm cray_pointer : BooleanFFlag<"cray-pointer">, Group<gfortran_Group>;
+defm d_lines_as_code : BooleanFFlag<"d-lines-as-code">, Group<gfortran_Group>;
+defm d_lines_as_comments : BooleanFFlag<"d-lines-as-comments">, Group<gfortran_Group>;
+defm default_double_8 : BooleanFFlag<"default-double-8">, Group<gfortran_Group>;
+defm default_integer_8 : BooleanFFlag<"default-integer-8">, Group<gfortran_Group>;
+defm default_real_8 : BooleanFFlag<"default-real-8">, Group<gfortran_Group>;
+defm dollar_ok : BooleanFFlag<"dollar-ok">, Group<gfortran_Group>;
+defm dump_fortran_optimized : BooleanFFlag<"dump-fortran-optimized">, Group<gfortran_Group>;
+defm dump_fortran_original : BooleanFFlag<"dump-fortran-original">, Group<gfortran_Group>;
+defm dump_parse_tree : BooleanFFlag<"dump-parse-tree">, Group<gfortran_Group>;
+defm external_blas : BooleanFFlag<"external-blas">, Group<gfortran_Group>;
+defm f2c : BooleanFFlag<"f2c">, Group<gfortran_Group>;
+defm fixed_form : BooleanFFlag<"fixed-form">, Group<gfortran_Group>;
+defm free_form : BooleanFFlag<"free-form">, Group<gfortran_Group>;
+defm frontend_optimize : BooleanFFlag<"frontend-optimize">, Group<gfortran_Group>;
+defm implicit_none : BooleanFFlag<"implicit-none">, Group<gfortran_Group>;
+defm init_local_zero : BooleanFFlag<"init-local-zero">, Group<gfortran_Group>;
+defm integer_4_integer_8 : BooleanFFlag<"integer-4-integer-8">, Group<gfortran_Group>;
+defm intrinsic_modules_path : BooleanFFlag<"intrinsic-modules-path">, Group<gfortran_Group>;
+defm max_identifier_length : BooleanFFlag<"max-identifier-length">, Group<gfortran_Group>;
+defm module_private : BooleanFFlag<"module-private">, Group<gfortran_Group>;
+defm pack_derived : BooleanFFlag<"pack-derived">, Group<gfortran_Group>;
+defm protect_parens : BooleanFFlag<"protect-parens">, Group<gfortran_Group>;
+defm range_check : BooleanFFlag<"range-check">, Group<gfortran_Group>;
+defm real_4_real_10 : BooleanFFlag<"real-4-real-10">, Group<gfortran_Group>;
+defm real_4_real_16 : BooleanFFlag<"real-4-real-16">, Group<gfortran_Group>;
+defm real_4_real_8 : BooleanFFlag<"real-4-real-8">, Group<gfortran_Group>;
+defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group<gfortran_Group>;
+defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group<gfortran_Group>;
+defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group<gfortran_Group>;
+defm realloc_lhs : BooleanFFlag<"realloc-lhs">, Group<gfortran_Group>;
+defm recursive : BooleanFFlag<"recursive">, Group<gfortran_Group>;
+defm repack_arrays : BooleanFFlag<"repack-arrays">, Group<gfortran_Group>;
+defm second_underscore : BooleanFFlag<"second-underscore">, Group<gfortran_Group>;
+defm sign_zero : BooleanFFlag<"sign-zero">, Group<gfortran_Group>;
+defm stack_arrays : BooleanFFlag<"stack-arrays">, Group<gfortran_Group>;
+defm underscoring : BooleanFFlag<"underscoring">, Group<gfortran_Group>;
+defm whole_file : BooleanFFlag<"whole-file">, Group<gfortran_Group>;
+
+
include "CC1Options.td"
include "CLCompatOptions.td"
Added: cfe/trunk/test/Driver/gfortran.f90
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gfortran.f90?rev=192867&view=auto
==============================================================================
--- cfe/trunk/test/Driver/gfortran.f90 (added)
+++ cfe/trunk/test/Driver/gfortran.f90 Wed Oct 16 22:28:24 2013
@@ -0,0 +1,244 @@
+! Test that Clang can forward all of the flags which are documented as
+! being supported by gfortran to GCC when falling back to GCC for
+! a fortran input file.
+!
+! RUN: %clang -no-canonical-prefixes -target i386-linux -### %s -o %t 2>&1 \
+! RUN: -Aquestion=answer \
+! RUN: -A-question=answer \
+! RUN: -C \
+! RUN: -CC \
+! RUN: -Dmacro \
+! RUN: -Dmacro=value \
+! RUN: -H \
+! RUN: -Isome/directory \
+! RUN: -Jsome/other/directory \
+! RUN: -P \
+! RUN: -Umacro \
+! RUN: -Waliasing \
+! RUN: -Walign-commons \
+! RUN: -Wall \
+! RUN: -Wampersand \
+! RUN: -Warray-bounds \
+! RUN: -Wc-binding-type \
+! RUN: -Wcharacter-truncation \
+! RUN: -Wconversion \
+! RUN: -Wfunction-elimination \
+! RUN: -Wimplicit-interface \
+! RUN: -Wimplicit-procedure \
+! RUN: -Wintrinsic-shadow \
+! RUN: -Wintrinsics-std \
+! RUN: -Wline-truncation \
+! RUN: -Wreal-q-constant \
+! RUN: -Wrealloc-lhs \
+! RUN: -Wsurprising \
+! RUN: -Wtabs \
+! RUN: -Wtarget-lifetime \
+! RUN: -Wunderflow \
+! RUN: -Wunused-parameter \
+! RUN: -cpp \
+! RUN: -dD \
+! RUN: -dI \
+! RUN: -dM \
+! RUN: -dN \
+! RUN: -dU \
+! RUN: -faggressive-function-elimination \
+! RUN: -falign-commons \
+! RUN: -fall-intrinsics \
+! RUN: -fautomatic \
+! RUN: -fbackslash \
+! RUN: -fbacktrace \
+! RUN: -fblas-matmul-limit=42 \
+! RUN: -fbounds-check \
+! RUN: -fcheck-array-temporaries \
+! RUN: -fcheck=all \
+! RUN: -fcoarray=none \
+! RUN: -fconvert=foobar \
+! RUN: -fcray-pointer \
+! RUN: -fd-lines-as-code \
+! RUN: -fd-lines-as-comments \
+! RUN: -fdefault-double-8 \
+! RUN: -fdefault-integer-8 \
+! RUN: -fdefault-real-8 \
+! RUN: -fdollar-ok \
+! RUN: -fdump-fortran-optimized \
+! RUN: -fdump-fortran-original \
+! RUN: -fdump-parse-tree \
+! RUN: -fexternal-blas \
+! RUN: -ff2c \
+! RUN: -ffixed-form \
+! RUN: -ffixed-line-length-42 \
+! RUN: -ffpe-trap=list \
+! RUN: -ffree-form \
+! RUN: -ffree-line-length-42 \
+! RUN: -ffrontend-optimize \
+! RUN: -fimplicit-none \
+! RUN: -finit-character=n \
+! RUN: -finit-integer=n \
+! RUN: -finit-local-zero \
+! RUN: -finit-logical=false \
+! RUN: -finit-real=zero \
+! RUN: -finteger-4-integer-8 \
+! RUN: -fintrinsic-modules-path \
+! RUN: -fmax-array-constructor=42 \
+! RUN: -fmax-errors=42 \
+! RUN: -fmax-identifier-length \
+! RUN: -fmax-stack-var-size=42 \
+! RUN: -fmax-subrecord-length=42 \
+! RUN: -fmodule-private \
+! RUN: -fopenmp \
+! RUN: -fpack-derived \
+! RUN: -fprotect-parens \
+! RUN: -frange-check \
+! RUN: -freal-4-real-10 \
+! RUN: -freal-4-real-16 \
+! RUN: -freal-4-real-8 \
+! RUN: -freal-8-real-10 \
+! RUN: -freal-8-real-16 \
+! RUN: -freal-8-real-4 \
+! RUN: -frealloc-lhs \
+! RUN: -frecord-marker=42 \
+! RUN: -frecursive \
+! RUN: -frepack-arrays \
+! RUN: -fsecond-underscore \
+! RUN: -fshort-enums \
+! RUN: -fsign-zero \
+! RUN: -fstack-arrays \
+! RUN: -fsyntax-only \
+! RUN: -funderscoring \
+! RUN: -fwhole-file \
+! RUN: -fworking-directory \
+! RUN: -imultilib \
+! RUN: -iprefix \
+! RUN: -iquote \
+! RUN: -isysroot \
+! RUN: -isystem \
+! RUN: -nocpp \
+! RUN: -nostdinc \
+! RUN: -pedantic \
+! RUN: -pedantic-errors \
+! RUN: -static-libgfortran \
+! RUN: -std=f90 \
+! RUN: -undef \
+! RUN: | FileCheck %s
+!
+! FIXME: Several of these shouldn't necessarily be rendered separately
+! when passing to GCC... Hopefully their driver handles this.
+!
+! CHECK: "-Aquestion=answer"
+! CHECK: "-A-question=answer"
+! CHECK: "-C"
+! CHECK: "-CC"
+! CHECK: "-D" "macro"
+! CHECK: "-D" "macro=value"
+! CHECK: "-H"
+! CHECK: "-I" "some/directory"
+! CHECK: "-Jsome/other/directory"
+! CHECK: "-P"
+! CHECK: "-U" "macro"
+! CHECK: "-Waliasing"
+! CHECK: "-Walign-commons"
+! CHECK: "-Wall"
+! CHECK: "-Wampersand"
+! CHECK: "-Warray-bounds"
+! CHECK: "-Wc-binding-type"
+! CHECK: "-Wcharacter-truncation"
+! CHECK: "-Wconversion"
+! CHECK: "-Wfunction-elimination"
+! CHECK: "-Wimplicit-interface"
+! CHECK: "-Wimplicit-procedure"
+! CHECK: "-Wintrinsic-shadow"
+! CHECK: "-Wintrinsics-std"
+! CHECK: "-Wline-truncation"
+! CHECK: "-Wreal-q-constant"
+! CHECK: "-Wrealloc-lhs"
+! CHECK: "-Wsurprising"
+! CHECK: "-Wtabs"
+! CHECK: "-Wtarget-lifetime"
+! CHECK: "-Wunderflow"
+! CHECK: "-Wunused-parameter"
+! CHECK: "-cpp"
+! CHECK: "-dD"
+! CHECK: "-dI"
+! CHECK: "-dM"
+! CHECK: "-dN"
+! CHECK: "-dU"
+! CHECK: "-faggressive-function-elimination"
+! CHECK: "-falign-commons"
+! CHECK: "-fall-intrinsics"
+! CHECK: "-fautomatic"
+! CHECK: "-fbackslash"
+! CHECK: "-fbacktrace"
+! CHECK: "-fblas-matmul-limit=42"
+! CHECK: "-fbounds-check"
+! CHECK: "-fcheck-array-temporaries"
+! CHECK: "-fcheck=all"
+! CHECK: "-fcoarray=none"
+! CHECK: "-fconvert=foobar"
+! CHECK: "-fcray-pointer"
+! CHECK: "-fd-lines-as-code"
+! CHECK: "-fd-lines-as-comments"
+! CHECK: "-fdefault-double-8"
+! CHECK: "-fdefault-integer-8"
+! CHECK: "-fdefault-real-8"
+! CHECK: "-fdollar-ok"
+! CHECK: "-fdump-fortran-optimized"
+! CHECK: "-fdump-fortran-original"
+! CHECK: "-fdump-parse-tree"
+! CHECK: "-fexternal-blas"
+! CHECK: "-ff2c"
+! CHECK: "-ffixed-form"
+! CHECK: "-ffixed-line-length-42"
+! CHECK: "-ffpe-trap=list"
+! CHECK: "-ffree-form"
+! CHECK: "-ffree-line-length-42"
+! CHECK: "-ffrontend-optimize"
+! CHECK: "-fimplicit-none"
+! CHECK: "-finit-character=n"
+! CHECK: "-finit-integer=n"
+! CHECK: "-finit-local-zero"
+! CHECK: "-finit-logical=false"
+! CHECK: "-finit-real=zero"
+! CHECK: "-finteger-4-integer-8"
+! CHECK: "-fintrinsic-modules-path"
+! CHECK: "-fmax-array-constructor=42"
+! CHECK: "-fmax-errors=42"
+! CHECK: "-fmax-identifier-length"
+! CHECK: "-fmax-stack-var-size=42"
+! CHECK: "-fmax-subrecord-length=42"
+! CHECK: "-fmodule-private"
+! CHECK: "-fopenmp"
+! CHECK: "-fpack-derived"
+! CHECK: "-fprotect-parens"
+! CHECK: "-frange-check"
+! CHECK: "-freal-4-real-10"
+! CHECK: "-freal-4-real-16"
+! CHECK: "-freal-4-real-8"
+! CHECK: "-freal-8-real-10"
+! CHECK: "-freal-8-real-16"
+! CHECK: "-freal-8-real-4"
+! CHECK: "-frealloc-lhs"
+! CHECK: "-frecord-marker=42"
+! CHECK: "-frecursive"
+! CHECK: "-frepack-arrays"
+! CHECK: "-fsecond-underscore"
+! CHECK: "-fshort-enums"
+! CHECK: "-fsign-zero"
+! CHECK: "-fstack-arrays"
+! CHECK: "-funderscoring"
+! CHECK: "-fwhole-file"
+! CHECK: "-fworking-directory"
+! CHECK: "-imultilib"
+! CHECK: "-iprefix"
+! CHECK: "-iquote"
+! CHECK: "-isysroot"
+! CHECK: "-isystem"
+! CHECK: "-nocpp"
+! CHECK: "-nostdinc"
+! CHECK: "-pedantic"
+! CHECK: "-pedantic-errors"
+! CHECK: "-static-libgfortran"
+! CHECK: "-std=f90"
+! CHECK: "-undef"
+!
+! Clang understands this one and orders it weirdly.
+! CHECK: "-fsyntax-only"
Modified: cfe/trunk/test/Driver/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lit.local.cfg?rev=192867&r1=192866&r2=192867&view=diff
==============================================================================
--- cfe/trunk/test/Driver/lit.local.cfg (original)
+++ cfe/trunk/test/Driver/lit.local.cfg Wed Oct 16 22:28:24 2013
@@ -1 +1 @@
-config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s']
+config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.f95']
More information about the cfe-commits
mailing list