We have various layers of extra configuration around this, but nothing that looks specific to tweaking the compiler settings. I have managed to build a local gcc 12.1 that works, as well as one that doesn't, but it is sadly quite difficult to tell what causes the difference in assembly output, given the many layers of Nix involved.
Running the correctly functioning version with "g++ -dumpspecs"
*asm_debug:
%{%:debug-level-gt(0):%{gstabs*:--gstabs;:%{g*:}}} %{fdebug-prefix-map=*:--debug-prefix-map %*}
*asm_debug_option:
%{%:debug-level-gt(0):%{!gstabs*:%{g*:%{%:dwarf-version-gt(4):--gdwarf-5 ;%:dwarf-version-gt(3):--gdwarf-4 ;%:dwarf-version-gt(2):--gdwarf-3 ;:--gdwarf2 }}}}
And the version that does not produce .loc entries, with "g++ -dumpspecs"
*asm_debug:
%{%:debug-level-gt(0):%{gstabs*:--gstabs;:%{g*:--gdwarf2}}} %{fdebug-prefix-map=*:--debug-prefix-map %*}
*asm_debug_option:
This all leads me to think the problem is entirely on my side, with the g++ in use not configured correctly (somehow) to produce debug symbols in dwarf-5.
Thanks for your time, I think Compiler Explorer is off the hook here. There isn't much you can do if the assembly is lacking in debug information I guess!
Brian