1 /* Command line option handling.
2 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
3 Contributed by Neil Booth.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #include "coretypes.h"
31 #include "langhooks.h"
37 #include "diagnostic.h"
38 #include "tm_p.h" /* For OPTIMIZATION_OPTIONS. */
39 #include "insn-attr.h" /* For INSN_SCHEDULING. */
42 /* Value of the -G xx switch, and whether it was passed or not. */
43 unsigned HOST_WIDE_INT g_switch_value
;
46 /* True if we should exit after parsing options. */
47 bool exit_after_options
;
52 /* Print various extra warnings. -W/-Wextra. */
55 /* Don't print warning messages. -w. */
56 bool inhibit_warnings
;
58 /* Treat warnings as errors. -Werror. */
59 bool warnings_are_errors
;
61 /* Warn if a function returns an aggregate, since there are often
62 incompatible calling conventions for doing this. */
63 bool warn_aggregate_return
;
65 /* Nonzero means warn about pointer casts that increase the required
66 alignment of the target type (and might therefore lead to a crash
67 due to a misaligned access). */
70 /* Nonzero means warn about uses of __attribute__((deprecated))
72 bool warn_deprecated_decl
= true;
74 /* Warn when an optimization pass is disabled. */
75 bool warn_disabled_optimization
;
77 /* Nonzero means warn if inline function is too large. */
80 /* True to warn about any objects definitions whose size is larger
81 than N bytes. Also want about function definitions whose returned
82 values are larger than N bytes, where N is `larger_than_size'. */
83 bool warn_larger_than
;
84 HOST_WIDE_INT larger_than_size
;
86 /* Warn about functions which might be candidates for attribute noreturn. */
87 bool warn_missing_noreturn
;
89 /* True to warn about code which is never reached. */
92 /* Warn if packed attribute on struct is unnecessary and inefficient. */
95 /* Warn when gcc pads a structure to an alignment boundary. */
98 /* True means warn about all declarations which shadow others. */
101 /* Nonzero means warn about constructs which might not be
102 strict-aliasing safe. */
103 int warn_strict_aliasing
;
105 /* True to warn if a switch on an enum, that does not have a default
106 case, fails to have a case for every enum value. */
109 /* Warn if a switch does not have a default case. */
110 bool warn_switch_default
;
112 /* Warn if a switch on an enum fails to have a case for every enum
113 value (regardless of the presence or otherwise of a default case). */
114 bool warn_switch_enum
;
116 /* Don't suppress warnings from system headers. -Wsystem-headers. */
117 bool warn_system_headers
;
119 /* True to warn about variables used before they are initialized. */
120 int warn_uninitialized
;
122 /* True to warn about unused variables, functions et.al. */
123 bool warn_unused_function
;
124 bool warn_unused_label
;
125 bool warn_unused_parameter
;
126 bool warn_unused_variable
;
127 bool warn_unused_value
;
129 /* Hack for cooperation between set_Wunused and set_Wextra. */
130 static bool maybe_warn_unused_parameter
;
132 /* Type(s) of debugging information we are producing (if any). See
133 flags.h for the definitions of the different possible types of
134 debugging information. */
135 enum debug_info_type write_symbols
= NO_DEBUG
;
137 /* Level of debugging information we are producing. See flags.h for
138 the definitions of the different possible levels. */
139 enum debug_info_level debug_info_level
= DINFO_LEVEL_NONE
;
141 /* Nonzero means use GNU-only extensions in the generated symbolic
142 debugging information. Currently, this only has an effect when
143 write_symbols is set to DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
144 bool use_gnu_debug_info_extensions
;
146 /* Columns of --help display. */
147 static unsigned int columns
= 80;
149 /* What to print when a switch has no documentation. */
150 static const char undocumented_msg
[] = N_("This switch lacks documentation");
152 /* Used for bookkeeping on whether user set these flags so
153 -fprofile-use/-fprofile-generate does not use them. */
154 static bool profile_arc_flag_set
, flag_profile_values_set
;
155 static bool flag_unroll_loops_set
, flag_tracer_set
;
156 static bool flag_value_profile_transformations_set
;
157 static bool flag_peel_loops_set
, flag_branch_probabilities_set
;
159 /* Input file names. */
160 const char **in_fnames
;
161 unsigned num_in_fnames
;
163 static size_t find_opt (const char *, int);
164 static int common_handle_option (size_t scode
, const char *arg
, int value
);
165 static void handle_param (const char *);
166 static void set_Wextra (int);
167 static unsigned int handle_option (const char **argv
, unsigned int lang_mask
);
168 static char *write_langs (unsigned int lang_mask
);
169 static void complain_wrong_lang (const char *, const struct cl_option
*,
170 unsigned int lang_mask
);
171 static void handle_options (unsigned int, const char **, unsigned int);
172 static void wrap_help (const char *help
, const char *item
, unsigned int);
173 static void print_help (void);
174 static void print_param_help (void);
175 static void print_filtered_help (unsigned int flag
);
176 static unsigned int print_switch (const char *text
, unsigned int indent
);
177 static void set_debug_level (enum debug_info_type type
, int extended
,
180 /* Perform a binary search to find which option the command-line INPUT
181 matches. Returns its index in the option array, and N_OPTS
182 (cl_options_count) on failure.
184 This routine is quite subtle. A normal binary search is not good
185 enough because some options can be suffixed with an argument, and
186 multiple sub-matches can occur, e.g. input of "-pedantic" matching
187 the initial substring of "-pedantic-errors".
189 A more complicated example is -gstabs. It should match "-g" with
190 an argument of "stabs". Suppose, however, that the number and list
191 of switches are such that the binary search tests "-gen-decls"
192 before having tested "-g". This doesn't match, and as "-gen-decls"
193 is less than "-gstabs", it will become the lower bound of the
194 binary search range, and "-g" will never be seen. To resolve this
195 issue, opts.sh makes "-gen-decls" point, via the back_chain member,
196 to "-g" so that failed searches that end between "-gen-decls" and
197 the lexicographically subsequent switch know to go back and see if
198 "-g" causes a match (which it does in this example).
200 This search is done in such a way that the longest match for the
201 front end in question wins. If there is no match for the current
202 front end, the longest match for a different front end is returned
203 (or N_OPTS if none) and the caller emits an error message. */
205 find_opt (const char *input
, int lang_mask
)
207 size_t mn
, mx
, md
, opt_len
;
208 size_t match_wrong_lang
;
212 mx
= cl_options_count
;
214 /* Find mn such this lexicographical inequality holds:
215 cl_options[mn] <= input < cl_options[mn + 1]. */
219 opt_len
= cl_options
[md
].opt_len
;
220 comp
= strncmp (input
, cl_options
[md
].opt_text
+ 1, opt_len
);
228 /* This is the switch that is the best match but for a different
229 front end, or cl_options_count if there is no match at all. */
230 match_wrong_lang
= cl_options_count
;
232 /* Backtrace the chain of possible matches, returning the longest
233 one, if any, that fits best. With current GCC switches, this
234 loop executes at most twice. */
237 const struct cl_option
*opt
= &cl_options
[mn
];
239 /* Is this switch a prefix of the input? */
240 if (!strncmp (input
, opt
->opt_text
+ 1, opt
->opt_len
))
242 /* If language is OK, and the match is exact or the switch
243 takes a joined argument, return it. */
244 if ((opt
->flags
& lang_mask
)
245 && (input
[opt
->opt_len
] == '\0' || (opt
->flags
& CL_JOINED
)))
248 /* If we haven't remembered a prior match, remember this
249 one. Any prior match is necessarily better. */
250 if (match_wrong_lang
== cl_options_count
)
251 match_wrong_lang
= mn
;
254 /* Try the next possibility. This is cl_options_count if there
256 mn
= opt
->back_chain
;
258 while (mn
!= cl_options_count
);
260 /* Return the best wrong match, or cl_options_count if none. */
261 return match_wrong_lang
;
264 /* If ARG is a non-negative integer made up solely of digits, return its
265 value, otherwise return -1. */
267 integral_argument (const char *arg
)
271 while (*p
&& ISDIGIT (*p
))
280 /* Return a malloced slash-separated list of languages in MASK. */
282 write_langs (unsigned int mask
)
284 unsigned int n
= 0, len
= 0;
285 const char *lang_name
;
288 for (n
= 0; (lang_name
= lang_names
[n
]) != 0; n
++)
289 if (mask
& (1U << n
))
290 len
+= strlen (lang_name
) + 1;
292 result
= xmalloc (len
);
294 for (n
= 0; (lang_name
= lang_names
[n
]) != 0; n
++)
295 if (mask
& (1U << n
))
299 strcpy (result
+ len
, lang_name
);
300 len
+= strlen (lang_name
);
308 /* Complain that switch OPT_INDEX does not apply to this front end. */
310 complain_wrong_lang (const char *text
, const struct cl_option
*option
,
311 unsigned int lang_mask
)
313 char *ok_langs
, *bad_lang
;
315 ok_langs
= write_langs (option
->flags
);
316 bad_lang
= write_langs (lang_mask
);
318 /* Eventually this should become a hard error IMO. */
319 warning ("command line option \"%s\" is valid for %s but not for %s",
320 text
, ok_langs
, bad_lang
);
326 /* Handle the switch beginning at ARGV for the language indicated by
327 LANG_MASK. Returns the number of switches consumed. */
329 handle_option (const char **argv
, unsigned int lang_mask
)
332 const char *opt
, *arg
= 0;
335 unsigned int result
= 0;
336 const struct cl_option
*option
;
340 /* Drop the "no-" from negative switches. */
341 if ((opt
[1] == 'W' || opt
[1] == 'f')
342 && opt
[2] == 'n' && opt
[3] == 'o' && opt
[4] == '-')
344 size_t len
= strlen (opt
) - 3;
346 dup
= xmalloc (len
+ 1);
349 memcpy (dup
+ 2, opt
+ 5, len
- 2 + 1);
354 opt_index
= find_opt (opt
+ 1, lang_mask
| CL_COMMON
);
355 if (opt_index
== cl_options_count
)
358 option
= &cl_options
[opt_index
];
360 /* Reject negative form of switches that don't take negatives as
362 if (!value
&& (option
->flags
& CL_REJECT_NEGATIVE
))
365 /* We've recognized this switch. */
368 /* Sort out any argument the switch takes. */
369 if (option
->flags
& CL_JOINED
)
371 /* Have arg point to the original switch. This is because
372 some code, such as disable_builtin_function, expects its
373 argument to be persistent until the program exits. */
374 arg
= argv
[0] + cl_options
[opt_index
].opt_len
+ 1;
376 arg
+= strlen ("no-");
378 if (*arg
== '\0' && !(option
->flags
& CL_MISSING_OK
))
380 if (option
->flags
& CL_SEPARATE
)
386 /* Missing argument. */
390 else if (option
->flags
& CL_SEPARATE
)
396 /* Now we've swallowed any potential argument, complain if this
397 is a switch for a different front end. */
398 if (!(option
->flags
& (lang_mask
| CL_COMMON
)))
400 complain_wrong_lang (argv
[0], option
, lang_mask
);
404 if (arg
== NULL
&& (option
->flags
& (CL_JOINED
| CL_SEPARATE
)))
406 if (!lang_hooks
.missing_argument (opt
, opt_index
))
407 error ("missing argument to \"%s\"", opt
);
411 /* If the switch takes an integer, convert it. */
412 if (arg
&& (option
->flags
& CL_UINTEGER
))
414 value
= integral_argument (arg
);
417 error ("argument to \"%s\" should be a non-negative integer",
423 if (option
->flags
& lang_mask
)
424 if (lang_hooks
.handle_option (opt_index
, arg
, value
) == 0)
427 if (result
&& (option
->flags
& CL_COMMON
))
428 if (common_handle_option (opt_index
, arg
, value
) == 0)
437 /* Decode and handle the vector of command line options. LANG_MASK
438 contains has a single bit set representing the current
441 handle_options (unsigned int argc
, const char **argv
, unsigned int lang_mask
)
445 for (i
= 1; i
< argc
; i
+= n
)
447 const char *opt
= argv
[i
];
449 /* Interpret "-" or a non-switch as a file name. */
450 if (opt
[0] != '-' || opt
[1] == '\0')
452 if (main_input_filename
== NULL
)
453 main_input_filename
= opt
;
454 add_input_filename (opt
);
459 n
= handle_option (argv
+ i
, lang_mask
);
464 error ("unrecognized command line option \"%s\"", opt
);
469 /* Handle FILENAME from the command line. */
471 add_input_filename (const char *filename
)
474 in_fnames
= xrealloc (in_fnames
, num_in_fnames
* sizeof (in_fnames
[0]));
475 in_fnames
[num_in_fnames
- 1] = filename
;
478 /* Parse command line options and set default flag values. Do minimal
479 options processing. */
481 decode_options (unsigned int argc
, const char **argv
)
483 unsigned int i
, lang_mask
;
485 /* Perform language-specific options initialization. */
486 lang_mask
= lang_hooks
.init_options (argc
, argv
);
488 lang_hooks
.initialize_diagnostics (global_dc
);
490 /* Scan to see what optimization level has been specified. That will
491 determine the default value of many flags. */
492 for (i
= 1; i
< argc
; i
++)
494 if (!strcmp (argv
[i
], "-O"))
499 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
501 /* Handle -Os, -O2, -O3, -O69, ... */
502 const char *p
= &argv
[i
][2];
504 if ((p
[0] == 's') && (p
[1] == 0))
508 /* Optimizing for size forces optimize to be 2. */
513 const int optimize_val
= read_integral_parameter (p
, p
- 2, -1);
514 if (optimize_val
!= -1)
516 optimize
= optimize_val
;
525 flag_merge_constants
= 0;
531 flag_thread_jumps
= 1;
533 flag_delayed_branch
= 1;
535 #ifdef CAN_DEBUG_WITHOUT_FP
536 flag_omit_frame_pointer
= 1;
538 flag_guess_branch_prob
= 1;
539 flag_cprop_registers
= 1;
540 flag_loop_optimize
= 1;
541 flag_if_conversion
= 1;
542 flag_if_conversion2
= 1;
547 flag_crossjumping
= 1;
548 flag_optimize_sibling_calls
= 1;
549 flag_cse_follow_jumps
= 1;
550 flag_cse_skip_blocks
= 1;
552 flag_expensive_optimizations
= 1;
553 flag_strength_reduce
= 1;
554 flag_rerun_cse_after_loop
= 1;
555 flag_rerun_loop_opt
= 1;
556 flag_caller_saves
= 1;
559 #ifdef INSN_SCHEDULING
560 flag_schedule_insns
= 1;
561 flag_schedule_insns_after_reload
= 1;
564 flag_strict_aliasing
= 1;
565 flag_delete_null_pointer_checks
= 1;
566 flag_reorder_blocks
= 1;
567 flag_reorder_functions
= 1;
568 flag_unit_at_a_time
= 1;
573 flag_inline_functions
= 1;
574 flag_rename_registers
= 1;
575 flag_unswitch_loops
= 1;
577 flag_gcse_after_reload
= 1;
580 if (optimize
< 2 || optimize_size
)
587 /* Don't reorder blocks when optimizing for size because extra
588 jump insns may be created; also barrier may create extra padding.
590 More correctly we should have a block reordering mode that tried
591 to minimize the combined size of all the jumps. This would more
592 or less automatically remove extra jumps, but would also try to
593 use more short jumps instead of long jumps. */
594 flag_reorder_blocks
= 0;
597 /* Initialize whether `char' is signed. */
598 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
599 /* Initialize how much space enums occupy, by default. */
600 flag_short_enums
= targetm
.default_short_enums ();
602 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
605 set_target_switch ("");
607 /* Unwind tables are always present in an ABI-conformant IA-64
608 object file, so the default should be ON. */
609 #ifdef IA64_UNWIND_INFO
610 flag_unwind_tables
= IA64_UNWIND_INFO
;
613 #ifdef OPTIMIZATION_OPTIONS
614 /* Allow default optimizations to be specified on a per-machine basis. */
615 OPTIMIZATION_OPTIONS (optimize
, optimize_size
);
618 handle_options (argc
, argv
, lang_mask
);
622 if (flag_pic
&& !flag_pie
)
625 if (flag_no_inline
== 2)
628 flag_really_no_inline
= flag_no_inline
;
630 /* Set flag_no_inline before the post_options () hook. The C front
631 ends use it to determine tree inlining defaults. FIXME: such
632 code should be lang-independent when all front ends use tree
633 inlining, in which case it, and this condition, should be moved
634 to the top of process_options() instead. */
637 /* Inlining does not work if not optimizing,
638 so force it not to be done. */
642 /* The c_decode_option function and decode_option hook set
643 this to `2' if -Wall is used, so we can avoid giving out
644 lots of errors for people who don't realize what -Wall does. */
645 if (warn_uninitialized
== 1)
646 warning ("-Wuninitialized is not supported without -O");
649 if (flag_really_no_inline
== 2)
650 flag_really_no_inline
= flag_no_inline
;
653 /* Handle target- and language-independent options. Return zero to
654 generate an "unknown option" message. */
656 common_handle_option (size_t scode
, const char *arg
,
657 int value ATTRIBUTE_UNUSED
)
659 enum opt_code code
= (enum opt_code
) scode
;
668 exit_after_options
= true;
675 case OPT__target_help
:
676 display_target_options ();
677 exit_after_options
= true;
681 print_version (stderr
, "");
682 exit_after_options
= true;
686 g_switch_value
= value
;
692 /* Currently handled in a prescan. */
696 /* For backward compatibility, -W is the same as -Wextra. */
700 case OPT_Waggregate_return
:
701 warn_aggregate_return
= value
;
704 case OPT_Wcast_align
:
705 warn_cast_align
= value
;
708 case OPT_Wdeprecated_declarations
:
709 warn_deprecated_decl
= value
;
712 case OPT_Wdisabled_optimization
:
713 warn_disabled_optimization
= value
;
717 warnings_are_errors
= value
;
728 case OPT_Wlarger_than_
:
729 larger_than_size
= value
;
730 warn_larger_than
= value
!= -1;
733 case OPT_Wmissing_noreturn
:
734 warn_missing_noreturn
= value
;
749 case OPT_Wstrict_aliasing
:
750 case OPT_Wstrict_aliasing_
:
751 warn_strict_aliasing
= value
;
758 case OPT_Wswitch_default
:
759 warn_switch_default
= value
;
762 case OPT_Wswitch_enum
:
763 warn_switch_enum
= value
;
766 case OPT_Wsystem_headers
:
767 warn_system_headers
= value
;
770 case OPT_Wuninitialized
:
771 warn_uninitialized
= value
;
774 case OPT_Wunreachable_code
:
775 warn_notreached
= value
;
782 case OPT_Wunused_function
:
783 warn_unused_function
= value
;
786 case OPT_Wunused_label
:
787 warn_unused_label
= value
;
790 case OPT_Wunused_parameter
:
791 warn_unused_parameter
= value
;
794 case OPT_Wunused_value
:
795 warn_unused_value
= value
;
798 case OPT_Wunused_variable
:
799 warn_unused_variable
= value
;
804 aux_info_file_name
= arg
;
805 flag_gen_aux_info
= 1;
812 case OPT_auxbase_strip
:
814 char *tmp
= xstrdup (arg
);
815 strip_off_ending (tmp
, strlen (tmp
));
822 decode_d_option (arg
);
826 dump_base_name
= arg
;
830 flag_pic
= value
+ value
;
834 flag_pie
= value
+ value
;
837 case OPT_fabi_version_
:
838 flag_abi_version
= value
;
841 case OPT_falign_functions
:
842 align_functions
= !value
;
845 case OPT_falign_functions_
:
846 align_functions
= value
;
849 case OPT_falign_jumps
:
850 align_jumps
= !value
;
853 case OPT_falign_jumps_
:
857 case OPT_falign_labels
:
858 align_labels
= !value
;
861 case OPT_falign_labels_
:
862 align_labels
= value
;
865 case OPT_falign_loops
:
866 align_loops
= !value
;
869 case OPT_falign_loops_
:
873 case OPT_fargument_alias
:
874 flag_argument_noalias
= !value
;
877 case OPT_fargument_noalias
:
878 flag_argument_noalias
= value
;
881 case OPT_fargument_noalias_global
:
882 flag_argument_noalias
= value
+ value
;
885 case OPT_fasynchronous_unwind_tables
:
886 flag_asynchronous_unwind_tables
= value
;
889 case OPT_fbounds_check
:
890 flag_bounds_check
= value
;
893 case OPT_fbranch_count_reg
:
894 flag_branch_on_count_reg
= value
;
897 case OPT_fbranch_probabilities
:
898 flag_branch_probabilities_set
= true;
899 flag_branch_probabilities
= value
;
902 case OPT_fbranch_target_load_optimize
:
903 flag_branch_target_load_optimize
= value
;
906 case OPT_fbranch_target_load_optimize2
:
907 flag_branch_target_load_optimize2
= value
;
910 case OPT_fbtr_bb_exclusive
:
911 flag_btr_bb_exclusive
= value
;
914 case OPT_fcall_used_
:
915 fix_register (arg
, 0, 1);
918 case OPT_fcall_saved_
:
919 fix_register (arg
, 0, 0);
922 case OPT_fcaller_saves
:
923 flag_caller_saves
= value
;
927 flag_no_common
= !value
;
930 case OPT_fcprop_registers
:
931 flag_cprop_registers
= value
;
934 case OPT_fcrossjumping
:
935 flag_crossjumping
= value
;
938 case OPT_fcse_follow_jumps
:
939 flag_cse_follow_jumps
= value
;
942 case OPT_fcse_skip_blocks
:
943 flag_cse_skip_blocks
= value
;
946 case OPT_fdata_sections
:
947 flag_data_sections
= value
;
951 flag_defer_pop
= value
;
954 case OPT_fdelayed_branch
:
955 flag_delayed_branch
= value
;
958 case OPT_fdelete_null_pointer_checks
:
959 flag_delete_null_pointer_checks
= value
;
962 case OPT_fdiagnostics_show_location_
:
963 if (!strcmp (arg
, "once"))
964 diagnostic_prefixing_rule (global_dc
) = DIAGNOSTICS_SHOW_PREFIX_ONCE
;
965 else if (!strcmp (arg
, "every-line"))
966 diagnostic_prefixing_rule (global_dc
)
967 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE
;
972 case OPT_fdump_unnumbered
:
973 flag_dump_unnumbered
= value
;
976 case OPT_feliminate_dwarf2_dups
:
977 flag_eliminate_dwarf2_dups
= value
;
980 case OPT_feliminate_unused_debug_types
:
981 flag_eliminate_unused_debug_types
= value
;
984 case OPT_feliminate_unused_debug_symbols
:
985 flag_debug_only_used_symbols
= value
;
988 case OPT_fexceptions
:
989 flag_exceptions
= value
;
992 case OPT_fexpensive_optimizations
:
993 flag_expensive_optimizations
= value
;
997 set_fast_math_flags (value
);
1000 case OPT_ffinite_math_only
:
1001 flag_finite_math_only
= value
;
1005 fix_register (arg
, 1, 1);
1008 case OPT_ffunction_cse
:
1009 flag_no_function_cse
= !value
;
1012 case OPT_ffloat_store
:
1013 flag_float_store
= value
;
1016 case OPT_fforce_addr
:
1017 flag_force_addr
= value
;
1020 case OPT_fforce_mem
:
1021 flag_force_mem
= value
;
1024 case OPT_ffunction_sections
:
1025 flag_function_sections
= value
;
1033 flag_gcse_lm
= value
;
1037 flag_gcse_sm
= value
;
1040 case OPT_fgcse_after_reload
:
1041 flag_gcse_after_reload
= value
;
1045 flag_gcse_las
= value
;
1048 case OPT_fguess_branch_probability
:
1049 flag_guess_branch_prob
= value
;
1053 flag_no_ident
= !value
;
1056 case OPT_fif_conversion
:
1057 flag_if_conversion
= value
;
1060 case OPT_fif_conversion2
:
1061 flag_if_conversion2
= value
;
1064 case OPT_finhibit_size_directive
:
1065 flag_inhibit_size_directive
= value
;
1069 flag_no_inline
= !value
;
1072 case OPT_finline_functions
:
1073 flag_inline_functions
= value
;
1076 case OPT_finline_limit_
:
1077 case OPT_finline_limit_eq
:
1078 set_param_value ("max-inline-insns-single", value
/ 2);
1079 set_param_value ("max-inline-insns-auto", value
/ 2);
1080 set_param_value ("max-inline-insns-rtl", value
);
1083 case OPT_finstrument_functions
:
1084 flag_instrument_function_entry_exit
= value
;
1087 case OPT_fkeep_inline_functions
:
1088 flag_keep_inline_functions
=value
;
1091 case OPT_fkeep_static_consts
:
1092 flag_keep_static_consts
= value
;
1095 case OPT_fleading_underscore
:
1096 flag_leading_underscore
= value
;
1099 case OPT_floop_optimize
:
1100 flag_loop_optimize
= value
;
1103 case OPT_fmath_errno
:
1104 flag_errno_math
= value
;
1107 case OPT_fmem_report
:
1111 case OPT_fmerge_all_constants
:
1112 flag_merge_constants
= value
+ value
;
1115 case OPT_fmerge_constants
:
1116 flag_merge_constants
= value
;
1119 case OPT_fmessage_length_
:
1120 pp_set_line_maximum_length (global_dc
->printer
, value
);
1123 case OPT_fmove_all_movables
:
1124 flag_move_all_movables
= value
;
1128 flag_new_regalloc
= value
;
1131 case OPT_fnon_call_exceptions
:
1132 flag_non_call_exceptions
= value
;
1135 case OPT_fold_unroll_all_loops
:
1136 flag_old_unroll_all_loops
= value
;
1139 case OPT_fold_unroll_loops
:
1140 flag_old_unroll_loops
= value
;
1143 case OPT_fomit_frame_pointer
:
1144 flag_omit_frame_pointer
= value
;
1147 case OPT_foptimize_register_move
:
1148 flag_regmove
= value
;
1151 case OPT_foptimize_sibling_calls
:
1152 flag_optimize_sibling_calls
= value
;
1155 case OPT_fpack_struct
:
1156 flag_pack_struct
= value
;
1159 case OPT_fpeel_loops
:
1160 flag_peel_loops_set
= true;
1161 flag_peel_loops
= value
;
1164 case OPT_fpcc_struct_return
:
1165 flag_pcc_struct_return
= value
;
1169 flag_no_peephole
= !value
;
1172 case OPT_fpeephole2
:
1173 flag_peephole2
= value
;
1184 case OPT_fprefetch_loop_arrays
:
1185 flag_prefetch_loop_arrays
= value
;
1189 profile_flag
= value
;
1192 case OPT_fprofile_arcs
:
1193 profile_arc_flag_set
= true;
1194 profile_arc_flag
= value
;
1197 case OPT_fprofile_use
:
1198 if (!flag_branch_probabilities_set
)
1199 flag_branch_probabilities
= value
;
1200 if (!flag_profile_values_set
)
1201 flag_profile_values
= value
;
1202 if (!flag_unroll_loops_set
)
1203 flag_unroll_loops
= value
;
1204 if (!flag_peel_loops_set
)
1205 flag_peel_loops
= value
;
1206 if (!flag_tracer_set
)
1207 flag_tracer
= value
;
1208 if (!flag_value_profile_transformations_set
)
1209 flag_value_profile_transformations
= value
;
1212 case OPT_fprofile_generate
:
1213 if (!profile_arc_flag_set
)
1214 profile_arc_flag
= value
;
1215 if (!flag_profile_values_set
)
1216 flag_profile_values
= value
;
1217 if (!flag_value_profile_transformations_set
)
1218 flag_value_profile_transformations
= value
;
1221 case OPT_fprofile_values
:
1222 flag_profile_values_set
= true;
1223 flag_profile_values
= value
;
1227 flag_value_profile_transformations_set
= value
;
1228 flag_value_profile_transformations
= value
;
1231 case OPT_frandom_seed
:
1232 /* The real switch is -fno-random-seed. */
1235 flag_random_seed
= NULL
;
1238 case OPT_frandom_seed_
:
1239 flag_random_seed
= arg
;
1242 case OPT_freduce_all_givs
:
1243 flag_reduce_all_givs
= value
;
1246 case OPT_freg_struct_return
:
1247 flag_pcc_struct_return
= !value
;
1251 flag_regmove
= value
;
1254 case OPT_frename_registers
:
1255 flag_rename_registers
= value
;
1258 case OPT_freorder_blocks
:
1259 flag_reorder_blocks
= value
;
1262 case OPT_freorder_functions
:
1263 flag_reorder_functions
= value
;
1266 case OPT_frerun_cse_after_loop
:
1267 flag_rerun_cse_after_loop
= value
;
1270 case OPT_frerun_loop_opt
:
1271 flag_rerun_loop_opt
= value
;
1274 case OPT_frounding_math
:
1275 flag_rounding_math
= value
;
1278 case OPT_fsched_interblock
:
1279 flag_schedule_interblock
= value
;
1282 case OPT_fsched_spec
:
1283 flag_schedule_speculative
= value
;
1286 case OPT_fsched_spec_load
:
1287 flag_schedule_speculative_load
= value
;
1290 case OPT_fsched_spec_load_dangerous
:
1291 flag_schedule_speculative_load_dangerous
= value
;
1294 case OPT_fsched_verbose_
:
1295 #ifdef INSN_SCHEDULING
1296 fix_sched_param ("verbose", arg
);
1302 case OPT_fsched2_use_superblocks
:
1303 flag_sched2_use_superblocks
= value
;
1306 case OPT_fsched2_use_traces
:
1307 flag_sched2_use_traces
= value
;
1310 case OPT_fschedule_insns
:
1311 flag_schedule_insns
= value
;
1314 case OPT_fschedule_insns2
:
1315 flag_schedule_insns_after_reload
= value
;
1318 case OPT_fsched_stalled_insns
:
1319 flag_sched_stalled_insns
= value
;
1322 case OPT_fsched_stalled_insns_
:
1323 flag_sched_stalled_insns
= value
;
1324 if (flag_sched_stalled_insns
== 0)
1325 flag_sched_stalled_insns
= -1;
1328 case OPT_fsched_stalled_insns_dep
:
1329 flag_sched_stalled_insns_dep
= 1;
1332 case OPT_fsched_stalled_insns_dep_
:
1333 flag_sched_stalled_insns_dep
= value
;
1336 case OPT_fshared_data
:
1337 flag_shared_data
= value
;
1340 case OPT_fsignaling_nans
:
1341 flag_signaling_nans
= value
;
1344 case OPT_fsingle_precision_constant
:
1345 flag_single_precision_constant
= value
;
1348 case OPT_fstack_check
:
1349 flag_stack_check
= value
;
1352 case OPT_fstack_limit
:
1353 /* The real switch is -fno-stack-limit. */
1356 stack_limit_rtx
= NULL_RTX
;
1359 case OPT_fstack_limit_register_
:
1361 int reg
= decode_reg_name (arg
);
1363 error ("unrecognized register name \"%s\"", arg
);
1365 stack_limit_rtx
= gen_rtx_REG (Pmode
, reg
);
1369 case OPT_fstack_limit_symbol_
:
1370 stack_limit_rtx
= gen_rtx_SYMBOL_REF (Pmode
, ggc_strdup (arg
));
1373 case OPT_fstrength_reduce
:
1374 flag_strength_reduce
= value
;
1377 case OPT_fstrict_aliasing
:
1378 flag_strict_aliasing
= value
;
1381 case OPT_fsyntax_only
:
1382 flag_syntax_only
= value
;
1385 case OPT_ftest_coverage
:
1386 flag_test_coverage
= value
;
1389 case OPT_fthread_jumps
:
1390 flag_thread_jumps
= value
;
1393 case OPT_ftime_report
:
1394 time_report
= value
;
1397 case OPT_ftls_model_
:
1398 if (!strcmp (arg
, "global-dynamic"))
1399 flag_tls_default
= TLS_MODEL_GLOBAL_DYNAMIC
;
1400 else if (!strcmp (arg
, "local-dynamic"))
1401 flag_tls_default
= TLS_MODEL_LOCAL_DYNAMIC
;
1402 else if (!strcmp (arg
, "initial-exec"))
1403 flag_tls_default
= TLS_MODEL_INITIAL_EXEC
;
1404 else if (!strcmp (arg
, "local-exec"))
1405 flag_tls_default
= TLS_MODEL_LOCAL_EXEC
;
1407 warning ("unknown tls-model \"%s\"", arg
);
1411 flag_tracer_set
= true;
1412 flag_tracer
= value
;
1415 case OPT_ftrapping_math
:
1416 flag_trapping_math
= value
;
1423 case OPT_funit_at_a_time
:
1424 flag_unit_at_a_time
= value
;
1427 case OPT_funroll_all_loops
:
1428 flag_unroll_all_loops
= value
;
1431 case OPT_funroll_loops
:
1432 flag_unroll_loops_set
= true;
1433 flag_unroll_loops
= value
;
1436 case OPT_funsafe_math_optimizations
:
1437 flag_unsafe_math_optimizations
= value
;
1440 case OPT_funswitch_loops
:
1441 flag_unswitch_loops
= value
;
1444 case OPT_funwind_tables
:
1445 flag_unwind_tables
= value
;
1448 case OPT_fvar_tracking
:
1449 flag_var_tracking
= value
;
1452 case OPT_fverbose_asm
:
1453 flag_verbose_asm
= value
;
1464 case OPT_fzero_initialized_in_bss
:
1465 flag_zero_initialized_in_bss
= value
;
1469 set_debug_level (NO_DEBUG
, DEFAULT_GDB_EXTENSIONS
, arg
);
1473 set_debug_level (SDB_DEBUG
, false, arg
);
1477 set_debug_level (DWARF2_DEBUG
, false, arg
);
1481 set_debug_level (NO_DEBUG
, 2, arg
);
1486 set_debug_level (DBX_DEBUG
, code
== OPT_gstabs_
, arg
);
1490 set_debug_level (VMS_DEBUG
, false, arg
);
1495 set_debug_level (XCOFF_DEBUG
, code
== OPT_gxcoff_
, arg
);
1499 set_target_switch (arg
);
1503 asm_file_name
= arg
;
1514 case OPT_pedantic_errors
:
1515 flag_pedantic_errors
= pedantic
= 1;
1527 inhibit_warnings
= true;
1534 /* Handle --param NAME=VALUE. */
1536 handle_param (const char *carg
)
1541 arg
= xstrdup (carg
);
1542 equal
= strchr (arg
, '=');
1544 error ("%s: --param arguments should be of the form NAME=VALUE", arg
);
1547 value
= integral_argument (equal
+ 1);
1549 error ("invalid --param value `%s'", equal
+ 1);
1553 set_param_value (arg
, value
);
1560 /* Handle -W and -Wextra. */
1562 set_Wextra (int setting
)
1564 extra_warnings
= setting
;
1565 warn_unused_value
= setting
;
1566 warn_unused_parameter
= (setting
&& maybe_warn_unused_parameter
);
1568 /* We save the value of warn_uninitialized, since if they put
1569 -Wuninitialized on the command line, we need to generate a
1570 warning about not using it without also specifying -O. */
1572 warn_uninitialized
= 0;
1573 else if (warn_uninitialized
!= 1)
1574 warn_uninitialized
= 2;
1577 /* Initialize unused warning flags. */
1579 set_Wunused (int setting
)
1581 warn_unused_function
= setting
;
1582 warn_unused_label
= setting
;
1583 /* Unused function parameter warnings are reported when either
1584 ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
1585 Thus, if -Wextra has already been seen, set warn_unused_parameter;
1586 otherwise set maybe_warn_extra_parameter, which will be picked up
1588 maybe_warn_unused_parameter
= setting
;
1589 warn_unused_parameter
= (setting
&& extra_warnings
);
1590 warn_unused_variable
= setting
;
1591 warn_unused_value
= setting
;
1594 /* The following routines are useful in setting all the flags that
1595 -ffast-math and -fno-fast-math imply. */
1597 set_fast_math_flags (int set
)
1599 flag_trapping_math
= !set
;
1600 flag_unsafe_math_optimizations
= set
;
1601 flag_finite_math_only
= set
;
1602 flag_errno_math
= !set
;
1605 flag_signaling_nans
= 0;
1606 flag_rounding_math
= 0;
1610 /* Return true iff flags are set as if -ffast-math. */
1612 fast_math_flags_set_p (void)
1614 return (!flag_trapping_math
1615 && flag_unsafe_math_optimizations
1616 && flag_finite_math_only
1617 && !flag_errno_math
);
1620 /* Handle a debug output -g switch. EXTENDED is true or false to support
1621 extended output (2 is special and means "-ggdb" was given). */
1623 set_debug_level (enum debug_info_type type
, int extended
, const char *arg
)
1625 static bool type_explicit
;
1627 use_gnu_debug_info_extensions
= extended
;
1629 if (type
== NO_DEBUG
)
1631 if (write_symbols
== NO_DEBUG
)
1633 write_symbols
= PREFERRED_DEBUGGING_TYPE
;
1637 #ifdef DWARF2_DEBUGGING_INFO
1638 write_symbols
= DWARF2_DEBUG
;
1639 #elif defined DBX_DEBUGGING_INFO
1640 write_symbols
= DBX_DEBUG
;
1644 if (write_symbols
== NO_DEBUG
)
1645 warning ("target system does not support debug output");
1650 /* Does it conflict with an already selected type? */
1651 if (type_explicit
&& write_symbols
!= NO_DEBUG
&& type
!= write_symbols
)
1652 error ("debug format \"%s\" conflicts with prior selection",
1653 debug_type_names
[type
]);
1654 write_symbols
= type
;
1655 type_explicit
= true;
1658 /* A debug flag without a level defaults to level 2. */
1661 if (!debug_info_level
)
1662 debug_info_level
= 2;
1666 debug_info_level
= integral_argument (arg
);
1667 if (debug_info_level
== (unsigned int) -1)
1668 error ("unrecognised debug output level \"%s\"", arg
);
1669 else if (debug_info_level
> 3)
1670 error ("debug output level %s is too high", arg
);
1674 /* Output --help text. */
1681 GET_ENVIRONMENT (p
, "COLUMNS");
1684 int value
= atoi (p
);
1689 puts (_("The following options are language-independent:\n"));
1691 print_filtered_help (CL_COMMON
);
1692 print_param_help ();
1694 for (i
= 0; lang_names
[i
]; i
++)
1696 printf (_("The %s front end recognizes the following options:\n\n"),
1698 print_filtered_help (1U << i
);
1701 display_target_options ();
1704 /* Print the help for --param. */
1706 print_param_help (void)
1710 puts (_("The --param option recognizes the following as parameters:\n"));
1712 for (i
= 0; i
< LAST_PARAM
; i
++)
1714 const char *help
= compiler_params
[i
].help
;
1715 const char *param
= compiler_params
[i
].option
;
1717 if (help
== NULL
|| *help
== '\0')
1718 help
= undocumented_msg
;
1720 /* Get the translation. */
1723 wrap_help (help
, param
, strlen (param
));
1729 /* Print help for a specific front-end, etc. */
1731 print_filtered_help (unsigned int flag
)
1733 unsigned int i
, len
, filter
, indent
= 0;
1734 bool duplicates
= false;
1735 const char *help
, *opt
, *tab
;
1736 static char *printed
;
1738 if (flag
== CL_COMMON
)
1742 printed
= xmalloc (cl_options_count
);
1743 memset (printed
, 0, cl_options_count
);
1747 /* Don't print COMMON options twice. */
1748 filter
= flag
| CL_COMMON
;
1750 for (i
= 0; i
< cl_options_count
; i
++)
1752 if ((cl_options
[i
].flags
& filter
) != flag
)
1755 /* Skip help for internal switches. */
1756 if (cl_options
[i
].flags
& CL_UNDOCUMENTED
)
1759 /* Skip switches that have already been printed, mark them to be
1764 indent
= print_switch (cl_options
[i
].opt_text
, indent
);
1775 for (i
= 0; i
< cl_options_count
; i
++)
1777 if ((cl_options
[i
].flags
& filter
) != flag
)
1780 /* Skip help for internal switches. */
1781 if (cl_options
[i
].flags
& CL_UNDOCUMENTED
)
1784 /* Skip switches that have already been printed. */
1790 help
= cl_options
[i
].help
;
1792 help
= undocumented_msg
;
1794 /* Get the translation. */
1797 tab
= strchr (help
, '\t');
1806 opt
= cl_options
[i
].opt_text
;
1810 wrap_help (help
, opt
, len
);
1816 /* Output ITEM, of length ITEM_WIDTH, in the left column, followed by
1817 word-wrapped HELP in a second column. */
1819 print_switch (const char *text
, unsigned int indent
)
1821 unsigned int len
= strlen (text
) + 1; /* trailing comma */
1826 if (indent
+ len
> columns
)
1837 fputs (text
, stdout
);
1839 return indent
+ len
+ 1;
1842 /* Output ITEM, of length ITEM_WIDTH, in the left column, followed by
1843 word-wrapped HELP in a second column. */
1845 wrap_help (const char *help
, const char *item
, unsigned int item_width
)
1847 unsigned int col_width
= 27;
1848 unsigned int remaining
, room
, len
;
1850 remaining
= strlen (help
);
1854 room
= columns
- 3 - MAX (col_width
, item_width
);
1863 for (i
= 0; help
[i
]; i
++)
1865 if (i
>= room
&& len
!= remaining
)
1869 else if ((help
[i
] == '-' || help
[i
] == '/')
1870 && help
[i
+ 1] != ' '
1871 && i
> 0 && ISALPHA (help
[i
- 1]))
1876 printf( " %-*.*s %.*s\n", col_width
, item_width
, item
, len
, help
);
1878 while (help
[len
] == ' ')