https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108022
Bug ID: 108022 Summary: [11/12/13 regression] -frecord-gcc-switches doesn't record preprocessor macros since 7caa49706316e650fb67719e1a1bf3a35054b685 Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver Assignee: unassigned at gcc dot gnu.org Reporter: sam at gentoo dot org CC: marxin at gcc dot gnu.org Target Milestone: --- -frecord-gcc-switches seems to have stopped recording preprocessor flags passed on the command line between GCC 10 and GCC 11. ``` $ cat test.c #include <stdio.h> int main(void) { printf("%s", "hi\n"); } $ gcc-10 -frecord-gcc-switches -D_TEST_SAVE_CPPFLAGS test.c -o ~/test && objdump -s test | grep -i TEST_SAVE 0000 2d44205f 54455354 5f534156 455f4350 -D _TEST_SAVE_CP $ gcc-11 -frecord-gcc-switches -D_TEST_SAVE_CPPFLAGS test.c -o ~/test && objdump -s test | grep -i TEST_SAVE ``` 10.4.1 (20221201) is fine 11.3.1 (20221202) is not gcc 12 and gcc 13 also have the same regression from gcc 10 (they don't work). Manually inspecting 'objdump -s test' doesn't show -DD_TEST_SAVE_CPPFLAGS either (it's not an issue with how the string is chunked). I ran a bisect overnight and it looks like the culprit is: ``` 7caa49706316e650fb67719e1a1bf3a35054b685 is the first bad commit commit 7caa49706316e650fb67719e1a1bf3a35054b685 Author: Martin Liska <mli...@suse.cz> Date: Mon Nov 23 13:40:04 2020 +0100 Refactor -frecord-gcc-switches. gcc/ChangeLog: * doc/tm.texi: Change argument of the record_gcc_switches hook and remove SWITCH_TYPE_* enum values. * dwarf2out.c (gen_producer_string): Move to opts.c and remove handling of the dwarf_record_gcc_switches option. (dwarf2out_early_finish): Use moved gen_producer_string function. * opts.c (gen_producer_string): New. * opts.h (gen_producer_string): New. * target.def: Change type of record_gcc_switches. * target.h (enum print_switch_type): Remove. (elf_record_gcc_switches): Change first argument. * toplev.c (MAX_LINE): Remove. (print_to_asm_out_file): Likewise. (print_to_stderr): Likewise. (print_single_switch): Likewise. (print_switch_values): Likewise. (init_asm_output): Use new gen_producer_string function. (process_options): Likewise. * varasm.c (elf_record_gcc_switches): Just save the string argument to the ELF container. gcc/doc/tm.texi | 38 +----------- gcc/dwarf2out.c | 118 +++---------------------------------- gcc/opts.c | 119 ++++++++++++++++++++++++++++++++++++++ gcc/opts.h | 6 ++ gcc/target.def | 38 +----------- gcc/target.h | 14 +---- gcc/toplev.c | 176 ++++++-------------------------------------------------- gcc/varasm.c | 48 ++++------------ 8 files changed, 166 insertions(+), 391 deletions(-) ``` I haven't tried reverting it yet as it doesn't revert cleanly on master.