1 /* Command line option handling.
2 Copyright (C) 2002, 2003 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. */
41 /* Value of the -G xx switch, and whether it was passed or not. */
42 unsigned HOST_WIDE_INT g_switch_value
;
45 /* True if we should exit after parsing options. */
46 bool exit_after_options
;
51 /* Print various extra warnings. -W/-Wextra. */
54 /* Don't print warning messages. -w. */
55 bool inhibit_warnings
;
57 /* Treat warnings as errors. -Werror. */
58 bool warnings_are_errors
;
60 /* Warn if a function returns an aggregate, since there are often
61 incompatible calling conventions for doing this. */
62 bool warn_aggregate_return
;
64 /* Nonzero means warn about pointer casts that increase the required
65 alignment of the target type (and might therefore lead to a crash
66 due to a misaligned access). */
69 /* Nonzero means warn about uses of __attribute__((deprecated))
71 bool warn_deprecated_decl
= true;
73 /* Warn when an optimization pass is disabled. */
74 bool warn_disabled_optimization
;
76 /* Nonzero means warn if inline function is too large. */
79 /* True to warn about any objects definitions whose size is larger
80 than N bytes. Also want about function definitions whose returned
81 values are larger than N bytes, where N is `larger_than_size'. */
82 bool warn_larger_than
;
83 HOST_WIDE_INT larger_than_size
;
85 /* Warn about functions which might be candidates for attribute noreturn. */
86 bool warn_missing_noreturn
;
88 /* True to warn about code which is never reached. */
91 /* Warn if packed attribute on struct is unnecessary and inefficient. */
94 /* Warn when gcc pads a structure to an alignment boundary. */
97 /* True means warn about all declarations which shadow others. */
100 /* Nonzero means warn about constructs which might not be
101 strict-aliasing safe. */
102 bool warn_strict_aliasing
;
104 /* True to warn if a switch on an enum, that does not have a default
105 case, fails to have a case for every enum value. */
108 /* Warn if a switch does not have a default case. */
109 bool warn_switch_default
;
111 /* Warn if a switch on an enum fails to have a case for every enum
112 value (regardless of the presence or otherwise of a default case). */
113 bool warn_switch_enum
;
115 /* Don't suppress warnings from system headers. -Wsystem-headers. */
116 bool warn_system_headers
;
118 /* True to warn about variables used before they are initialized. */
119 int warn_uninitialized
;
121 /* True to warn about unused variables, functions et.al. */
122 bool warn_unused_function
;
123 bool warn_unused_label
;
124 bool warn_unused_parameter
;
125 bool warn_unused_variable
;
126 bool warn_unused_value
;
128 /* Hack for cooperation between set_Wunused and set_Wextra. */
129 static bool maybe_warn_unused_parameter
;
131 /* Type(s) of debugging information we are producing (if any). See
132 flags.h for the definitions of the different possible types of
133 debugging information. */
134 enum debug_info_type write_symbols
= NO_DEBUG
;
136 /* Level of debugging information we are producing. See flags.h for
137 the definitions of the different possible levels. */
138 enum debug_info_level debug_info_level
= DINFO_LEVEL_NONE
;
140 /* Nonzero means use GNU-only extensions in the generated symbolic
141 debugging information. Currently, this only has an effect when
142 write_symbols is set to DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
143 bool use_gnu_debug_info_extensions
;
145 /* Columns of --help display. */
146 static unsigned int columns
= 80;
148 /* What to print when a switch has no documentation. */
149 static const char undocumented_msg
[] = N_("This switch lacks documentation");
151 /* Input file names. */
152 const char **in_fnames
;
153 unsigned num_in_fnames
;
155 static size_t find_opt (const char *, int);
156 static int common_handle_option (size_t scode
, const char *arg
, int value
);
157 static void handle_param (const char *);
158 static void set_Wextra (int);
159 static unsigned int handle_option (const char **argv
, unsigned int lang_mask
);
160 static char *write_langs (unsigned int lang_mask
);
161 static void complain_wrong_lang (const char *, const struct cl_option
*,
162 unsigned int lang_mask
);
163 static void handle_options (unsigned int, const char **, unsigned int);
164 static void wrap_help (const char *help
, const char *item
, unsigned int);
165 static void print_help (void);
166 static void print_param_help (void);
167 static void print_filtered_help (unsigned int flag
);
168 static unsigned int print_switch (const char *text
, unsigned int indent
);
169 static void set_debug_level (enum debug_info_type type
, int extended
,
172 /* Perform a binary search to find which option the command-line INPUT
173 matches. Returns its index in the option array, and N_OPTS
174 (cl_options_count) on failure.
176 This routine is quite subtle. A normal binary search is not good
177 enough because some options can be suffixed with an argument, and
178 multiple sub-matches can occur, e.g. input of "-pedantic" matching
179 the initial substring of "-pedantic-errors".
181 A more complicated example is -gstabs. It should match "-g" with
182 an argument of "stabs". Suppose, however, that the number and list
183 of switches are such that the binary search tests "-gen-decls"
184 before having tested "-g". This doesn't match, and as "-gen-decls"
185 is less than "-gstabs", it will become the lower bound of the
186 binary search range, and "-g" will never be seen. To resolve this
187 issue, opts.sh makes "-gen-decls" point, via the back_chain member,
188 to "-g" so that failed searches that end between "-gen-decls" and
189 the lexicographically subsequent switch know to go back and see if
190 "-g" causes a match (which it does in this example).
192 This search is done in such a way that the longest match for the
193 front end in question wins. If there is no match for the current
194 front end, the longest match for a different front end is returned
195 (or N_OPTS if none) and the caller emits an error message. */
197 find_opt (const char *input
, int lang_mask
)
199 size_t mn
, mx
, md
, opt_len
;
200 size_t match_wrong_lang
;
204 mx
= cl_options_count
;
206 /* Find mn such this lexicographical inequality holds:
207 cl_options[mn] <= input < cl_options[mn + 1]. */
211 opt_len
= cl_options
[md
].opt_len
;
212 comp
= strncmp (input
, cl_options
[md
].opt_text
+ 1, opt_len
);
220 /* This is the switch that is the best match but for a different
221 front end, or cl_options_count if there is no match at all. */
222 match_wrong_lang
= cl_options_count
;
224 /* Backtrace the chain of possible matches, returning the longest
225 one, if any, that fits best. With current GCC switches, this
226 loop executes at most twice. */
229 const struct cl_option
*opt
= &cl_options
[mn
];
231 /* Is this switch a prefix of the input? */
232 if (!strncmp (input
, opt
->opt_text
+ 1, opt
->opt_len
))
234 /* If language is OK, and the match is exact or the switch
235 takes a joined argument, return it. */
236 if ((opt
->flags
& lang_mask
)
237 && (input
[opt
->opt_len
] == '\0' || (opt
->flags
& CL_JOINED
)))
240 /* If we haven't remembered a prior match, remember this
241 one. Any prior match is necessarily better. */
242 if (match_wrong_lang
== cl_options_count
)
243 match_wrong_lang
= mn
;
246 /* Try the next possibility. This is cl_options_count if there
248 mn
= opt
->back_chain
;
250 while (mn
!= cl_options_count
);
252 /* Return the best wrong match, or cl_options_count if none. */
253 return match_wrong_lang
;
256 /* If ARG is a non-negative integer made up solely of digits, return its
257 value, otherwise return -1. */
259 integral_argument (const char *arg
)
263 while (*p
&& ISDIGIT (*p
))
272 /* Return a malloced slash-separated list of languages in MASK. */
274 write_langs (unsigned int mask
)
276 unsigned int n
= 0, len
= 0;
277 const char *lang_name
;
280 for (n
= 0; (lang_name
= lang_names
[n
]) != 0; n
++)
281 if (mask
& (1U << n
))
282 len
+= strlen (lang_name
) + 1;
284 result
= xmalloc (len
);
286 for (n
= 0; (lang_name
= lang_names
[n
]) != 0; n
++)
287 if (mask
& (1U << n
))
291 strcpy (result
+ len
, lang_name
);
292 len
+= strlen (lang_name
);
300 /* Complain that switch OPT_INDEX does not apply to this front end. */
302 complain_wrong_lang (const char *text
, const struct cl_option
*option
,
303 unsigned int lang_mask
)
305 char *ok_langs
, *bad_lang
;
307 ok_langs
= write_langs (option
->flags
);
308 bad_lang
= write_langs (lang_mask
);
310 /* Eventually this should become a hard error IMO. */
311 warning ("command line option \"%s\" is valid for %s but not for %s",
312 text
, ok_langs
, bad_lang
);
318 /* Handle the switch beginning at ARGV for the language indicated by
319 LANG_MASK. Returns the number of switches consumed. */
321 handle_option (const char **argv
, unsigned int lang_mask
)
324 const char *opt
, *arg
= 0;
327 unsigned int result
= 0;
328 const struct cl_option
*option
;
332 /* Drop the "no-" from negative switches. */
333 if ((opt
[1] == 'W' || opt
[1] == 'f')
334 && opt
[2] == 'n' && opt
[3] == 'o' && opt
[4] == '-')
336 size_t len
= strlen (opt
) - 3;
338 dup
= xmalloc (len
+ 1);
341 memcpy (dup
+ 2, opt
+ 5, len
- 2 + 1);
346 opt_index
= find_opt (opt
+ 1, lang_mask
| CL_COMMON
);
347 if (opt_index
== cl_options_count
)
350 option
= &cl_options
[opt_index
];
352 /* Reject negative form of switches that don't take negatives as
354 if (!value
&& (option
->flags
& CL_REJECT_NEGATIVE
))
357 /* We've recognized this switch. */
360 /* Sort out any argument the switch takes. */
361 if (option
->flags
& CL_JOINED
)
363 /* Have arg point to the original switch. This is because
364 some code, such as disable_builtin_function, expects its
365 argument to be persistent until the program exits. */
366 arg
= argv
[0] + cl_options
[opt_index
].opt_len
+ 1;
368 arg
+= strlen ("no-");
370 if (*arg
== '\0' && !(option
->flags
& CL_MISSING_OK
))
372 if (option
->flags
& CL_SEPARATE
)
378 /* Missing argument. */
382 else if (option
->flags
& CL_SEPARATE
)
388 /* Now we've swallowed any potential argument, complain if this
389 is a switch for a different front end. */
390 if (!(option
->flags
& (lang_mask
| CL_COMMON
)))
392 complain_wrong_lang (argv
[0], option
, lang_mask
);
396 if (arg
== NULL
&& (option
->flags
& (CL_JOINED
| CL_SEPARATE
)))
398 if (!(*lang_hooks
.missing_argument
) (opt
, opt_index
))
399 error ("missing argument to \"%s\"", opt
);
403 /* If the switch takes an integer, convert it. */
404 if (arg
&& (option
->flags
& CL_UINTEGER
))
406 value
= integral_argument (arg
);
409 error ("argument to \"%s\" should be a non-negative integer",
415 if (option
->flags
& lang_mask
)
416 if ((*lang_hooks
.handle_option
) (opt_index
, arg
, value
) == 0)
419 if (result
&& (option
->flags
& CL_COMMON
))
420 if (common_handle_option (opt_index
, arg
, value
) == 0)
429 /* Decode and handle the vector of command line options. LANG_MASK
430 contains has a single bit set representing the current
433 handle_options (unsigned int argc
, const char **argv
, unsigned int lang_mask
)
437 for (i
= 1; i
< argc
; i
+= n
)
439 const char *opt
= argv
[i
];
441 /* Interpret "-" or a non-switch as a file name. */
442 if (opt
[0] != '-' || opt
[1] == '\0')
444 main_input_filename
= opt
;
445 add_input_filename (opt
);
450 n
= handle_option (argv
+ i
, lang_mask
);
455 error ("unrecognized command line option \"%s\"", opt
);
460 /* Handle FILENAME from the command line. */
462 add_input_filename (const char *filename
)
465 in_fnames
= xrealloc (in_fnames
, num_in_fnames
* sizeof (in_fnames
[0]));
466 in_fnames
[num_in_fnames
- 1] = filename
;
469 /* Parse command line options and set default flag values. Do minimal
470 options processing. */
472 decode_options (unsigned int argc
, const char **argv
)
474 unsigned int i
, lang_mask
;
476 /* Perform language-specific options initialization. */
477 lang_mask
= (*lang_hooks
.init_options
) (argc
, argv
);
479 lang_hooks
.initialize_diagnostics (global_dc
);
481 /* Scan to see what optimization level has been specified. That will
482 determine the default value of many flags. */
483 for (i
= 1; i
< argc
; i
++)
485 if (!strcmp (argv
[i
], "-O"))
490 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
492 /* Handle -Os, -O2, -O3, -O69, ... */
493 const char *p
= &argv
[i
][2];
495 if ((p
[0] == 's') && (p
[1] == 0))
499 /* Optimizing for size forces optimize to be 2. */
504 const int optimize_val
= read_integral_parameter (p
, p
- 2, -1);
505 if (optimize_val
!= -1)
507 optimize
= optimize_val
;
516 flag_merge_constants
= 0;
522 flag_thread_jumps
= 1;
524 flag_delayed_branch
= 1;
526 #ifdef CAN_DEBUG_WITHOUT_FP
527 flag_omit_frame_pointer
= 1;
529 flag_guess_branch_prob
= 1;
530 flag_cprop_registers
= 1;
531 flag_loop_optimize
= 1;
532 flag_crossjumping
= 1;
533 flag_if_conversion
= 1;
534 flag_if_conversion2
= 1;
539 flag_optimize_sibling_calls
= 1;
540 flag_cse_follow_jumps
= 1;
541 flag_cse_skip_blocks
= 1;
543 flag_expensive_optimizations
= 1;
544 flag_strength_reduce
= 1;
545 flag_rerun_cse_after_loop
= 1;
546 flag_rerun_loop_opt
= 1;
547 flag_caller_saves
= 1;
550 #ifdef INSN_SCHEDULING
551 flag_schedule_insns
= 1;
552 flag_schedule_insns_after_reload
= 1;
555 flag_strict_aliasing
= 1;
556 flag_delete_null_pointer_checks
= 1;
557 flag_reorder_blocks
= 1;
558 flag_reorder_functions
= 1;
559 flag_unit_at_a_time
= 1;
564 flag_inline_functions
= 1;
565 flag_rename_registers
= 1;
566 flag_unswitch_loops
= 1;
569 if (optimize
< 2 || optimize_size
)
576 /* Don't reorder blocks when optimizing for size because extra
577 jump insns may be created; also barrier may create extra padding.
579 More correctly we should have a block reordering mode that tried
580 to minimize the combined size of all the jumps. This would more
581 or less automatically remove extra jumps, but would also try to
582 use more short jumps instead of long jumps. */
583 flag_reorder_blocks
= 0;
586 /* Initialize whether `char' is signed. */
587 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
588 #ifdef DEFAULT_SHORT_ENUMS
589 /* Initialize how much space enums occupy, by default. */
590 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
593 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
596 set_target_switch ("");
598 /* Unwind tables are always present in an ABI-conformant IA-64
599 object file, so the default should be ON. */
600 #ifdef IA64_UNWIND_INFO
601 flag_unwind_tables
= IA64_UNWIND_INFO
;
604 #ifdef OPTIMIZATION_OPTIONS
605 /* Allow default optimizations to be specified on a per-machine basis. */
606 OPTIMIZATION_OPTIONS (optimize
, optimize_size
);
609 handle_options (argc
, argv
, lang_mask
);
613 if (flag_pic
&& !flag_pie
)
616 if (flag_no_inline
== 2)
619 flag_really_no_inline
= flag_no_inline
;
621 /* Set flag_no_inline before the post_options () hook. The C front
622 ends use it to determine tree inlining defaults. FIXME: such
623 code should be lang-independent when all front ends use tree
624 inlining, in which case it, and this condition, should be moved
625 to the top of process_options() instead. */
628 /* Inlining does not work if not optimizing,
629 so force it not to be done. */
633 /* The c_decode_option function and decode_option hook set
634 this to `2' if -Wall is used, so we can avoid giving out
635 lots of errors for people who don't realize what -Wall does. */
636 if (warn_uninitialized
== 1)
637 warning ("-Wuninitialized is not supported without -O");
640 if (flag_really_no_inline
== 2)
641 flag_really_no_inline
= flag_no_inline
;
644 /* Handle target- and language-independent options. Return zero to
645 generate an "unknown option" message. */
647 common_handle_option (size_t scode
, const char *arg
,
648 int value ATTRIBUTE_UNUSED
)
650 enum opt_code code
= (enum opt_code
) scode
;
659 exit_after_options
= true;
666 case OPT__target_help
:
667 display_target_options ();
668 exit_after_options
= true;
672 print_version (stderr
, "");
673 exit_after_options
= true;
677 g_switch_value
= value
;
683 /* Currently handled in a prescan. */
687 /* For backward compatibility, -W is the same as -Wextra. */
691 case OPT_Waggregate_return
:
692 warn_aggregate_return
= value
;
695 case OPT_Wcast_align
:
696 warn_cast_align
= value
;
699 case OPT_Wdeprecated_declarations
:
700 warn_deprecated_decl
= value
;
703 case OPT_Wdisabled_optimization
:
704 warn_disabled_optimization
= value
;
708 warnings_are_errors
= value
;
719 case OPT_Wlarger_than_
:
720 larger_than_size
= value
;
721 warn_larger_than
= value
!= -1;
724 case OPT_Wmissing_noreturn
:
725 warn_missing_noreturn
= value
;
740 case OPT_Wstrict_aliasing
:
741 warn_strict_aliasing
= value
;
748 case OPT_Wswitch_default
:
749 warn_switch_default
= value
;
752 case OPT_Wswitch_enum
:
753 warn_switch_enum
= value
;
756 case OPT_Wsystem_headers
:
757 warn_system_headers
= value
;
760 case OPT_Wuninitialized
:
761 warn_uninitialized
= value
;
764 case OPT_Wunreachable_code
:
765 warn_notreached
= value
;
772 case OPT_Wunused_function
:
773 warn_unused_function
= value
;
776 case OPT_Wunused_label
:
777 warn_unused_label
= value
;
780 case OPT_Wunused_parameter
:
781 warn_unused_parameter
= value
;
784 case OPT_Wunused_value
:
785 warn_unused_value
= value
;
788 case OPT_Wunused_variable
:
789 warn_unused_variable
= value
;
794 aux_info_file_name
= arg
;
795 flag_gen_aux_info
= 1;
802 case OPT_auxbase_strip
:
804 char *tmp
= xstrdup (arg
);
805 strip_off_ending (tmp
, strlen (tmp
));
812 decode_d_option (arg
);
816 dump_base_name
= arg
;
820 flag_pic
= value
+ value
;
824 flag_pie
= value
+ value
;
827 case OPT_falign_functions
:
828 align_functions
= !value
;
831 case OPT_falign_functions_
:
832 align_functions
= value
;
835 case OPT_falign_jumps
:
836 align_jumps
= !value
;
839 case OPT_falign_jumps_
:
843 case OPT_falign_labels
:
844 align_labels
= !value
;
847 case OPT_falign_labels_
:
848 align_labels
= value
;
851 case OPT_falign_loops
:
852 align_loops
= !value
;
855 case OPT_falign_loops_
:
859 case OPT_fargument_alias
:
860 flag_argument_noalias
= !value
;
863 case OPT_fargument_noalias
:
864 flag_argument_noalias
= value
;
867 case OPT_fargument_noalias_global
:
868 flag_argument_noalias
= value
+ value
;
871 case OPT_fasynchronous_unwind_tables
:
872 flag_asynchronous_unwind_tables
= value
;
875 case OPT_fbounds_check
:
876 flag_bounds_check
= value
;
879 case OPT_fbranch_count_reg
:
880 flag_branch_on_count_reg
= value
;
883 case OPT_fbranch_probabilities
:
884 flag_branch_probabilities
= value
;
887 case OPT_fbranch_target_load_optimize
:
888 flag_branch_target_load_optimize
= value
;
891 case OPT_fbranch_target_load_optimize2
:
892 flag_branch_target_load_optimize2
= value
;
895 case OPT_fcall_used_
:
896 fix_register (arg
, 0, 1);
899 case OPT_fcall_saved_
:
900 fix_register (arg
, 0, 0);
903 case OPT_fcaller_saves
:
904 flag_caller_saves
= value
;
908 flag_no_common
= !value
;
911 case OPT_fcprop_registers
:
912 flag_cprop_registers
= value
;
915 case OPT_fcrossjumping
:
916 flag_crossjumping
= value
;
919 case OPT_fcse_follow_jumps
:
920 flag_cse_follow_jumps
= value
;
923 case OPT_fcse_skip_blocks
:
924 flag_cse_skip_blocks
= value
;
927 case OPT_fdata_sections
:
928 flag_data_sections
= value
;
932 flag_defer_pop
= value
;
935 case OPT_fdelayed_branch
:
936 flag_delayed_branch
= value
;
939 case OPT_fdelete_null_pointer_checks
:
940 flag_delete_null_pointer_checks
= value
;
943 case OPT_fdiagnostics_show_location_
:
944 if (!strcmp (arg
, "once"))
945 diagnostic_prefixing_rule (global_dc
) = DIAGNOSTICS_SHOW_PREFIX_ONCE
;
946 else if (!strcmp (arg
, "every-line"))
947 diagnostic_prefixing_rule (global_dc
)
948 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE
;
953 case OPT_fdump_unnumbered
:
954 flag_dump_unnumbered
= value
;
957 case OPT_feliminate_dwarf2_dups
:
958 flag_eliminate_dwarf2_dups
= value
;
961 case OPT_feliminate_unused_debug_types
:
962 flag_eliminate_unused_debug_types
= value
;
965 case OPT_feliminate_unused_debug_symbols
:
966 flag_debug_only_used_symbols
= value
;
969 case OPT_fexceptions
:
970 flag_exceptions
= value
;
973 case OPT_fexpensive_optimizations
:
974 flag_expensive_optimizations
= value
;
978 set_fast_math_flags (value
);
981 case OPT_ffinite_math_only
:
982 flag_finite_math_only
= value
;
986 fix_register (arg
, 1, 1);
989 case OPT_ffunction_cse
:
990 flag_no_function_cse
= !value
;
993 case OPT_ffloat_store
:
994 flag_float_store
= value
;
997 case OPT_fforce_addr
:
998 flag_force_addr
= value
;
1001 case OPT_fforce_mem
:
1002 flag_force_mem
= value
;
1005 case OPT_ffunction_sections
:
1006 flag_function_sections
= value
;
1014 flag_gcse_lm
= value
;
1018 flag_gcse_sm
= value
;
1021 case OPT_fgnu_linker
:
1022 flag_gnu_linker
= value
;
1025 case OPT_fguess_branch_probability
:
1026 flag_guess_branch_prob
= value
;
1030 flag_no_ident
= !value
;
1033 case OPT_fif_conversion
:
1034 flag_if_conversion
= value
;
1037 case OPT_fif_conversion2
:
1038 flag_if_conversion2
= value
;
1041 case OPT_finhibit_size_directive
:
1042 flag_inhibit_size_directive
= value
;
1046 flag_no_inline
= !value
;
1049 case OPT_finline_functions
:
1050 flag_inline_functions
= value
;
1053 case OPT_finline_limit_
:
1054 case OPT_finline_limit_eq
:
1055 set_param_value ("max-inline-insns", value
);
1056 set_param_value ("max-inline-insns-single", value
/ 2);
1057 set_param_value ("max-inline-insns-auto", value
/ 2);
1058 set_param_value ("max-inline-insns-rtl", value
);
1059 if (value
/ 4 < MIN_INLINE_INSNS
)
1062 set_param_value ("min-inline-insns", value
/ 4);
1064 set_param_value ("min-inline-insns", 10);
1068 case OPT_finstrument_functions
:
1069 flag_instrument_function_entry_exit
= value
;
1072 case OPT_fkeep_inline_functions
:
1073 flag_keep_inline_functions
=value
;
1076 case OPT_fkeep_static_consts
:
1077 flag_keep_static_consts
= value
;
1080 case OPT_fleading_underscore
:
1081 flag_leading_underscore
= value
;
1084 case OPT_floop_optimize
:
1085 flag_loop_optimize
= value
;
1088 case OPT_fmath_errno
:
1089 flag_errno_math
= value
;
1092 case OPT_fmem_report
:
1096 case OPT_fmerge_all_constants
:
1097 flag_merge_constants
= value
+ value
;
1100 case OPT_fmerge_constants
:
1101 flag_merge_constants
= value
;
1104 case OPT_fmessage_length_
:
1105 pp_set_line_maximum_length (global_dc
->printer
, value
);
1108 case OPT_fmove_all_movables
:
1109 flag_move_all_movables
= value
;
1113 flag_new_regalloc
= value
;
1116 case OPT_fnon_call_exceptions
:
1117 flag_non_call_exceptions
= value
;
1120 case OPT_fold_unroll_all_loops
:
1121 flag_old_unroll_all_loops
= value
;
1124 case OPT_fold_unroll_loops
:
1125 flag_old_unroll_loops
= value
;
1128 case OPT_fomit_frame_pointer
:
1129 flag_omit_frame_pointer
= value
;
1132 case OPT_foptimize_register_move
:
1133 flag_regmove
= value
;
1136 case OPT_foptimize_sibling_calls
:
1137 flag_optimize_sibling_calls
= value
;
1140 case OPT_fpack_struct
:
1141 flag_pack_struct
= value
;
1144 case OPT_fpeel_loops
:
1145 flag_peel_loops
= value
;
1148 case OPT_fpcc_struct_return
:
1149 flag_pcc_struct_return
= value
;
1153 flag_no_peephole
= !value
;
1156 case OPT_fpeephole2
:
1157 flag_peephole2
= value
;
1168 case OPT_fprefetch_loop_arrays
:
1169 flag_prefetch_loop_arrays
= value
;
1173 profile_flag
= value
;
1176 case OPT_fprofile_arcs
:
1177 profile_arc_flag
= value
;
1180 case OPT_frandom_seed
:
1181 /* The real switch is -fno-random-seed. */
1184 flag_random_seed
= NULL
;
1187 case OPT_frandom_seed_
:
1188 flag_random_seed
= arg
;
1191 case OPT_freduce_all_givs
:
1192 flag_reduce_all_givs
= value
;
1195 case OPT_freg_struct_return
:
1196 flag_pcc_struct_return
= !value
;
1200 flag_regmove
= value
;
1203 case OPT_frename_registers
:
1204 flag_rename_registers
= value
;
1207 case OPT_freorder_blocks
:
1208 flag_reorder_blocks
= value
;
1211 case OPT_freorder_functions
:
1212 flag_reorder_functions
= value
;
1215 case OPT_frerun_cse_after_loop
:
1216 flag_rerun_cse_after_loop
= value
;
1219 case OPT_frerun_loop_opt
:
1220 flag_rerun_loop_opt
= value
;
1223 case OPT_frounding_math
:
1224 flag_rounding_math
= value
;
1227 case OPT_fsched_interblock
:
1228 flag_schedule_interblock
= value
;
1231 case OPT_fsched_spec
:
1232 flag_schedule_speculative
= value
;
1235 case OPT_fsched_spec_load
:
1236 flag_schedule_speculative_load
= value
;
1239 case OPT_fsched_spec_load_dangerous
:
1240 flag_schedule_speculative_load_dangerous
= value
;
1243 case OPT_fsched_verbose_
:
1244 #ifdef INSN_SCHEDULING
1245 fix_sched_param ("verbose", arg
);
1251 case OPT_fsched2_use_superblocks
:
1252 flag_sched2_use_superblocks
= value
;
1255 case OPT_fsched2_use_traces
:
1256 flag_sched2_use_traces
= value
;
1259 case OPT_fschedule_insns
:
1260 flag_schedule_insns
= value
;
1263 case OPT_fschedule_insns2
:
1264 flag_schedule_insns_after_reload
= value
;
1267 case OPT_fshared_data
:
1268 flag_shared_data
= value
;
1271 case OPT_fsignaling_nans
:
1272 flag_signaling_nans
= value
;
1275 case OPT_fsingle_precision_constant
:
1276 flag_single_precision_constant
= value
;
1284 flag_ssa_ccp
= value
;
1288 flag_ssa_dce
= value
;
1291 case OPT_fstack_check
:
1292 flag_stack_check
= value
;
1295 case OPT_fstack_limit
:
1296 /* The real switch is -fno-stack-limit. */
1299 stack_limit_rtx
= NULL_RTX
;
1302 case OPT_fstack_limit_register_
:
1304 int reg
= decode_reg_name (arg
);
1306 error ("unrecognized register name \"%s\"", arg
);
1308 stack_limit_rtx
= gen_rtx_REG (Pmode
, reg
);
1312 case OPT_fstack_limit_symbol_
:
1313 stack_limit_rtx
= gen_rtx_SYMBOL_REF (Pmode
, ggc_strdup (arg
));
1316 case OPT_fstrength_reduce
:
1317 flag_strength_reduce
= value
;
1320 case OPT_fstrict_aliasing
:
1321 flag_strict_aliasing
= value
;
1324 case OPT_fsyntax_only
:
1325 flag_syntax_only
= value
;
1328 case OPT_ftest_coverage
:
1329 flag_test_coverage
= value
;
1332 case OPT_fthread_jumps
:
1333 flag_thread_jumps
= value
;
1336 case OPT_ftime_report
:
1337 time_report
= value
;
1340 case OPT_ftls_model_
:
1341 if (!strcmp (arg
, "global-dynamic"))
1342 flag_tls_default
= TLS_MODEL_GLOBAL_DYNAMIC
;
1343 else if (!strcmp (arg
, "local-dynamic"))
1344 flag_tls_default
= TLS_MODEL_LOCAL_DYNAMIC
;
1345 else if (!strcmp (arg
, "initial-exec"))
1346 flag_tls_default
= TLS_MODEL_INITIAL_EXEC
;
1347 else if (!strcmp (arg
, "local-exec"))
1348 flag_tls_default
= TLS_MODEL_LOCAL_EXEC
;
1350 warning ("unknown tls-model \"%s\"", arg
);
1354 flag_tracer
= value
;
1357 case OPT_ftrapping_math
:
1358 flag_trapping_math
= value
;
1365 case OPT_funit_at_a_time
:
1366 flag_unit_at_a_time
= value
;
1369 case OPT_funroll_all_loops
:
1370 flag_unroll_all_loops
= value
;
1373 case OPT_funroll_loops
:
1374 flag_unroll_loops
= value
;
1377 case OPT_funsafe_math_optimizations
:
1378 flag_unsafe_math_optimizations
= value
;
1381 case OPT_funswitch_loops
:
1382 flag_unswitch_loops
= value
;
1385 case OPT_funwind_tables
:
1386 flag_unwind_tables
= value
;
1389 case OPT_fverbose_asm
:
1390 flag_verbose_asm
= value
;
1397 case OPT_fwritable_strings
:
1398 flag_writable_strings
= value
;
1401 case OPT_fzero_initialized_in_bss
:
1402 flag_zero_initialized_in_bss
= value
;
1406 set_debug_level (NO_DEBUG
, DEFAULT_GDB_EXTENSIONS
, arg
);
1410 set_debug_level (SDB_DEBUG
, false, arg
);
1416 error ("use -gdwarf -gN for DWARF v1 level N, "
1417 "and -gdwarf-2 for DWARF v2" );
1423 set_debug_level (DWARF_DEBUG
, code
== OPT_gdwarf_
, arg
);
1427 set_debug_level (DWARF2_DEBUG
, false, arg
);
1431 set_debug_level (NO_DEBUG
, 2, arg
);
1436 set_debug_level (DBX_DEBUG
, code
== OPT_gstabs_
, arg
);
1440 set_debug_level (VMS_DEBUG
, false, arg
);
1445 set_debug_level (XCOFF_DEBUG
, code
== OPT_gxcoff_
, arg
);
1449 set_target_switch (arg
);
1453 asm_file_name
= arg
;
1464 case OPT_pedantic_errors
:
1465 flag_pedantic_errors
= pedantic
= 1;
1477 inhibit_warnings
= true;
1484 /* Handle --param NAME=VALUE. */
1486 handle_param (const char *carg
)
1491 arg
= xstrdup (carg
);
1492 equal
= strchr (arg
, '=');
1494 error ("%s: --param arguments should be of the form NAME=VALUE", arg
);
1497 value
= integral_argument (equal
+ 1);
1499 error ("invalid --param value `%s'", equal
+ 1);
1503 set_param_value (arg
, value
);
1510 /* Handle -W and -Wextra. */
1512 set_Wextra (int setting
)
1514 extra_warnings
= setting
;
1515 warn_unused_value
= setting
;
1516 warn_unused_parameter
= (setting
&& maybe_warn_unused_parameter
);
1518 /* We save the value of warn_uninitialized, since if they put
1519 -Wuninitialized on the command line, we need to generate a
1520 warning about not using it without also specifying -O. */
1522 warn_uninitialized
= 0;
1523 else if (warn_uninitialized
!= 1)
1524 warn_uninitialized
= 2;
1527 /* Initialize unused warning flags. */
1529 set_Wunused (int setting
)
1531 warn_unused_function
= setting
;
1532 warn_unused_label
= setting
;
1533 /* Unused function parameter warnings are reported when either
1534 ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
1535 Thus, if -Wextra has already been seen, set warn_unused_parameter;
1536 otherwise set maybe_warn_extra_parameter, which will be picked up
1538 maybe_warn_unused_parameter
= setting
;
1539 warn_unused_parameter
= (setting
&& extra_warnings
);
1540 warn_unused_variable
= setting
;
1541 warn_unused_value
= setting
;
1544 /* The following routines are useful in setting all the flags that
1545 -ffast-math and -fno-fast-math imply. */
1547 set_fast_math_flags (int set
)
1549 flag_trapping_math
= !set
;
1550 flag_unsafe_math_optimizations
= set
;
1551 flag_finite_math_only
= set
;
1552 flag_errno_math
= !set
;
1555 flag_signaling_nans
= 0;
1556 flag_rounding_math
= 0;
1560 /* Return true iff flags are set as if -ffast-math. */
1562 fast_math_flags_set_p (void)
1564 return (!flag_trapping_math
1565 && flag_unsafe_math_optimizations
1566 && flag_finite_math_only
1567 && !flag_errno_math
);
1570 /* Handle a debug output -g switch. EXTENDED is true or false to support
1571 extended output (2 is special and means "-ggdb" was given). */
1573 set_debug_level (enum debug_info_type type
, int extended
, const char *arg
)
1575 static bool type_explicit
;
1577 use_gnu_debug_info_extensions
= extended
;
1579 if (type
== NO_DEBUG
)
1581 if (write_symbols
== NO_DEBUG
)
1583 write_symbols
= PREFERRED_DEBUGGING_TYPE
;
1587 #ifdef DWARF2_DEBUGGING_INFO
1588 write_symbols
= DWARF2_DEBUG
;
1589 #elif defined DBX_DEBUGGING_INFO
1590 write_symbols
= DBX_DEBUG
;
1594 if (write_symbols
== NO_DEBUG
)
1595 warning ("target system does not support debug output");
1600 /* Does it conflict with an already selected type? */
1601 if (type_explicit
&& write_symbols
!= NO_DEBUG
&& type
!= write_symbols
)
1602 error ("debug format \"%s\" conflicts with prior selection",
1603 debug_type_names
[type
]);
1604 write_symbols
= type
;
1605 type_explicit
= true;
1608 /* A debug flag without a level defaults to level 2. */
1611 if (!debug_info_level
)
1612 debug_info_level
= 2;
1616 debug_info_level
= integral_argument (arg
);
1617 if (debug_info_level
== (unsigned int) -1)
1618 error ("unrecognised debug output level \"%s\"", arg
);
1619 else if (debug_info_level
> 3)
1620 error ("debug output level %s is too high", arg
);
1624 /* Output --help text. */
1631 GET_ENVIRONMENT (p
, "COLUMNS");
1634 int value
= atoi (p
);
1639 puts (_("The following options are language-independent:\n"));
1641 print_filtered_help (CL_COMMON
);
1642 print_param_help ();
1644 for (i
= 0; lang_names
[i
]; i
++)
1646 printf (_("The %s front end recognizes the following options:\n\n"),
1648 print_filtered_help (1U << i
);
1651 display_target_options ();
1654 /* Print the help for --param. */
1656 print_param_help (void)
1660 puts (_("The --param option recognizes the following as parameters:\n"));
1662 for (i
= 0; i
< LAST_PARAM
; i
++)
1664 const char *help
= compiler_params
[i
].help
;
1665 const char *param
= compiler_params
[i
].option
;
1667 if (help
== NULL
|| *help
== '\0')
1668 help
= undocumented_msg
;
1670 /* Get the translation. */
1673 wrap_help (help
, param
, strlen (param
));
1679 /* Print help for a specific front-end, etc. */
1681 print_filtered_help (unsigned int flag
)
1683 unsigned int i
, len
, filter
, indent
= 0;
1684 bool duplicates
= false;
1685 const char *help
, *opt
, *tab
;
1686 static char *printed
;
1688 if (flag
== CL_COMMON
)
1692 printed
= xmalloc (cl_options_count
);
1693 memset (printed
, 0, cl_options_count
);
1697 /* Don't print COMMON options twice. */
1698 filter
= flag
| CL_COMMON
;
1700 for (i
= 0; i
< cl_options_count
; i
++)
1702 if ((cl_options
[i
].flags
& filter
) != flag
)
1705 /* Skip help for internal switches. */
1706 if (cl_options
[i
].flags
& CL_UNDOCUMENTED
)
1709 /* Skip switches that have already been printed, mark them to be
1714 indent
= print_switch (cl_options
[i
].opt_text
, indent
);
1725 for (i
= 0; i
< cl_options_count
; i
++)
1727 if ((cl_options
[i
].flags
& filter
) != flag
)
1730 /* Skip help for internal switches. */
1731 if (cl_options
[i
].flags
& CL_UNDOCUMENTED
)
1734 /* Skip switches that have already been printed. */
1740 help
= cl_options
[i
].help
;
1742 help
= undocumented_msg
;
1744 /* Get the translation. */
1747 tab
= strchr (help
, '\t');
1756 opt
= cl_options
[i
].opt_text
;
1760 wrap_help (help
, opt
, len
);
1766 /* Output ITEM, of length ITEM_WIDTH, in the left column, followed by
1767 word-wrapped HELP in a second column. */
1769 print_switch (const char *text
, unsigned int indent
)
1771 unsigned int len
= strlen (text
) + 1; /* trailing comma */
1776 if (indent
+ len
> columns
)
1787 fputs (text
, stdout
);
1789 return indent
+ len
+ 1;
1792 /* Output ITEM, of length ITEM_WIDTH, in the left column, followed by
1793 word-wrapped HELP in a second column. */
1795 wrap_help (const char *help
, const char *item
, unsigned int item_width
)
1797 unsigned int col_width
= 27;
1798 unsigned int remaining
, room
, len
;
1800 remaining
= strlen (help
);
1804 room
= columns
- 3 - MAX (col_width
, item_width
);
1813 for (i
= 0; help
[i
]; i
++)
1815 if (i
>= room
&& len
!= remaining
)
1819 else if ((help
[i
] == '-' || help
[i
] == '/')
1820 && help
[i
+ 1] != ' '
1821 && ISALPHA (help
[i
- 1]))
1826 printf( " %-*.*s %.*s\n", col_width
, item_width
, item
, len
, help
);
1828 while (help
[len
] == ' ')