2

I used to use -frecord-gcc-switches to embed a version string in a binary.

With gcc 10.4, when compiling some c code with -Wall -Werror -O3 -frecord-gcc-switches -DVERSION_THING=123hello, I'd get the following output from readelf -p .GCC.command.line

String dump of section '.GCC.command.line':
  [     0]  -fdiagnostics-color=always
  [    1b]  -imultiarch x86_64-linux-gnu
  [    38]  -iprefix /opt/compiler-explorer/gcc-10.4.0/bin/../lib/gcc/x86_64-linux-gnu/10.4.0/
  [    8b]  -D VERSION_THING=123hello
  [    a5]  /app/example.c
  [    b4]  -mtune=generic
  [    c3]  -march=x86-64
  [    d1]  -g
  [    d4]  -O3
  [    d8]  -Wall
  [    de]  -Werror
  [    e6]  -frecord-gcc-switches

However, with gcc 11.1 and later, I get this

String dump of section '.GCC.command.line':
  [     0]  GNU C17 11.1.0 -mtune=generic -march=x86-64 -g -O3

Does anybody know where I should be looking to see what's changed between versions and why with regard to -frecord-gcc-switches and if it's possible to get the old behaviour back?

wreckgar23
  • 1,025
  • 9
  • 22
  • 1
    At a glance, I don't find anything about this that changed in 11.0/11.1. https://gcc.gnu.org/gcc-11/changes.html. However this option has a couple of reported bugs over the years. Also check out this which seems related: https://gcc.gnu.org/legacy-ml/gcc-patches/2019-11/msg00434.html – Lundin Jan 17 '23 at 12:31
  • This is the change that 'broke' it: https://github.com/gcc-mirror/gcc/commit/7caa49706316e650fb67719e1a1bf3a35054b685 – David Apr 11 '23 at 10:25
  • More information on motivation in this thread: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108022 – David Apr 11 '23 at 11:14

0 Answers0