Properly use opts in finish_options
When code was moved from process_options to finish_options it
was not properly adjusted to look at and alter the opts set
passed to the function but continued to modify the global options
set. The following rectifies this and makes sure the same
mistake isn't repeated by poisoning global_options{,_set}.
2022-05-10 Richard Biener <rguenther@suse.de>
* flags.h (dwarf_debuginfo_p): Add opts argument, guard
API with !GENERATOR_FILE.
* opts.cc (global_options): Poison.
(global_options_set): Likewise.
(finish_options): Refer to options via opts.
(cherry picked from commit d469484610
)
This commit is contained in:
parent
1e43783b3f
commit
ad4fa189a7
|
@ -40,6 +40,7 @@ unsigned int debug_set_count (uint32_t w_symbols);
|
||||||
|
|
||||||
const char * debug_set_names (uint32_t w_symbols);
|
const char * debug_set_names (uint32_t w_symbols);
|
||||||
|
|
||||||
|
#ifndef GENERATOR_FILE
|
||||||
/* Return true iff BTF debug info is enabled. */
|
/* Return true iff BTF debug info is enabled. */
|
||||||
|
|
||||||
extern bool btf_debuginfo_p ();
|
extern bool btf_debuginfo_p ();
|
||||||
|
@ -54,12 +55,13 @@ extern bool ctf_debuginfo_p ();
|
||||||
|
|
||||||
/* Return true iff DWARF2 debug info is enabled. */
|
/* Return true iff DWARF2 debug info is enabled. */
|
||||||
|
|
||||||
extern bool dwarf_debuginfo_p ();
|
extern bool dwarf_debuginfo_p (struct gcc_options *opts = &global_options);
|
||||||
|
|
||||||
/* Return true iff the debug info format is to be generated based on DWARF
|
/* Return true iff the debug info format is to be generated based on DWARF
|
||||||
DIEs (like CTF and BTF debug info formats). */
|
DIEs (like CTF and BTF debug info formats). */
|
||||||
|
|
||||||
extern bool dwarf_based_debuginfo_p ();
|
extern bool dwarf_based_debuginfo_p ();
|
||||||
|
#endif
|
||||||
|
|
||||||
extern void strip_off_ending (char *, int);
|
extern void strip_off_ending (char *, int);
|
||||||
extern int base_of_path (const char *path, const char **base_out);
|
extern int base_of_path (const char *path, const char **base_out);
|
||||||
|
|
67
gcc/opts.cc
67
gcc/opts.cc
|
@ -157,9 +157,9 @@ ctf_debuginfo_p ()
|
||||||
/* Return TRUE iff dwarf2 debug info is enabled. */
|
/* Return TRUE iff dwarf2 debug info is enabled. */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
dwarf_debuginfo_p ()
|
dwarf_debuginfo_p (struct gcc_options *opts)
|
||||||
{
|
{
|
||||||
return (write_symbols & DWARF2_DEBUG);
|
return (opts->x_write_symbols & DWARF2_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return true iff the debug info format is to be generated based on DWARF
|
/* Return true iff the debug info format is to be generated based on DWARF
|
||||||
|
@ -171,6 +171,11 @@ bool dwarf_based_debuginfo_p ()
|
||||||
|| (write_symbols & BTF_DEBUG));
|
|| (write_symbols & BTF_DEBUG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* All flag uses below need to explicitely reference the option sets
|
||||||
|
to operate on. */
|
||||||
|
#define global_options DO_NOT_USE
|
||||||
|
#define global_options_set DO_NOT_USE
|
||||||
|
|
||||||
/* Parse the -femit-struct-debug-detailed option value
|
/* Parse the -femit-struct-debug-detailed option value
|
||||||
and set the flag variables. */
|
and set the flag variables. */
|
||||||
|
|
||||||
|
@ -1305,57 +1310,61 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
|
||||||
SET_OPTION_IF_UNSET (opts, opts_set, flag_vect_cost_model,
|
SET_OPTION_IF_UNSET (opts, opts_set, flag_vect_cost_model,
|
||||||
VECT_COST_MODEL_CHEAP);
|
VECT_COST_MODEL_CHEAP);
|
||||||
|
|
||||||
if (flag_gtoggle)
|
if (opts->x_flag_gtoggle)
|
||||||
{
|
{
|
||||||
/* Make sure to process -gtoggle only once. */
|
/* Make sure to process -gtoggle only once. */
|
||||||
flag_gtoggle = false;
|
opts->x_flag_gtoggle = false;
|
||||||
if (debug_info_level == DINFO_LEVEL_NONE)
|
if (opts->x_debug_info_level == DINFO_LEVEL_NONE)
|
||||||
{
|
{
|
||||||
debug_info_level = DINFO_LEVEL_NORMAL;
|
opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
|
||||||
|
|
||||||
if (write_symbols == NO_DEBUG)
|
if (opts->x_write_symbols == NO_DEBUG)
|
||||||
write_symbols = PREFERRED_DEBUGGING_TYPE;
|
opts->x_write_symbols = PREFERRED_DEBUGGING_TYPE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
debug_info_level = DINFO_LEVEL_NONE;
|
opts->x_debug_info_level = DINFO_LEVEL_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opts_set->x_debug_nonbind_markers_p)
|
if (!opts_set->x_debug_nonbind_markers_p)
|
||||||
debug_nonbind_markers_p
|
opts->x_debug_nonbind_markers_p
|
||||||
= (optimize
|
= (opts->x_optimize
|
||||||
&& debug_info_level >= DINFO_LEVEL_NORMAL
|
&& opts->x_debug_info_level >= DINFO_LEVEL_NORMAL
|
||||||
&& dwarf_debuginfo_p ()
|
&& dwarf_debuginfo_p (opts)
|
||||||
&& !(flag_selective_scheduling || flag_selective_scheduling2));
|
&& !(opts->x_flag_selective_scheduling
|
||||||
|
|| opts->x_flag_selective_scheduling2));
|
||||||
|
|
||||||
/* Note -fvar-tracking is enabled automatically with OPT_LEVELS_1_PLUS and
|
/* Note -fvar-tracking is enabled automatically with OPT_LEVELS_1_PLUS and
|
||||||
so we need to drop it if we are called from optimize attribute. */
|
so we need to drop it if we are called from optimize attribute. */
|
||||||
if (debug_info_level < DINFO_LEVEL_NORMAL)
|
if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
|
||||||
flag_var_tracking = false;
|
opts->x_flag_var_tracking = false;
|
||||||
|
|
||||||
/* One could use EnabledBy, but it would lead to a circular dependency. */
|
/* One could use EnabledBy, but it would lead to a circular dependency. */
|
||||||
if (!opts_set->x_flag_var_tracking_uninit)
|
if (!opts_set->x_flag_var_tracking_uninit)
|
||||||
flag_var_tracking_uninit = flag_var_tracking;
|
opts->x_flag_var_tracking_uninit = opts->x_flag_var_tracking;
|
||||||
|
|
||||||
if (!opts_set->x_flag_var_tracking_assignments)
|
if (!opts_set->x_flag_var_tracking_assignments)
|
||||||
flag_var_tracking_assignments
|
opts->x_flag_var_tracking_assignments
|
||||||
= (flag_var_tracking
|
= (opts->x_flag_var_tracking
|
||||||
&& !(flag_selective_scheduling || flag_selective_scheduling2));
|
&& !(opts->x_flag_selective_scheduling
|
||||||
|
|| opts->x_flag_selective_scheduling2));
|
||||||
|
|
||||||
if (flag_var_tracking_assignments_toggle)
|
if (opts->x_flag_var_tracking_assignments_toggle)
|
||||||
flag_var_tracking_assignments = !flag_var_tracking_assignments;
|
opts->x_flag_var_tracking_assignments
|
||||||
|
= !opts->x_flag_var_tracking_assignments;
|
||||||
|
|
||||||
if (flag_var_tracking_assignments && !flag_var_tracking)
|
if (opts->x_flag_var_tracking_assignments && !opts->x_flag_var_tracking)
|
||||||
flag_var_tracking = flag_var_tracking_assignments = -1;
|
opts->x_flag_var_tracking = opts->x_flag_var_tracking_assignments = -1;
|
||||||
|
|
||||||
if (flag_var_tracking_assignments
|
if (opts->x_flag_var_tracking_assignments
|
||||||
&& (flag_selective_scheduling || flag_selective_scheduling2))
|
&& (opts->x_flag_selective_scheduling
|
||||||
|
|| opts->x_flag_selective_scheduling2))
|
||||||
warning_at (loc, 0,
|
warning_at (loc, 0,
|
||||||
"var-tracking-assignments changes selective scheduling");
|
"var-tracking-assignments changes selective scheduling");
|
||||||
|
|
||||||
if (flag_syntax_only)
|
if (opts->x_flag_syntax_only)
|
||||||
{
|
{
|
||||||
write_symbols = NO_DEBUG;
|
opts->x_write_symbols = NO_DEBUG;
|
||||||
profile_flag = 0;
|
opts->x_profile_flag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue