In previous releases of GCC, the "column numbers" emitted in diagnostics
were actually a count of bytes from the start of the source line. This
could be problematic, both because of:
- multibyte characters (requiring more than one byte to encode), and
- multicolumn characters (requiring more than one column to display in a monospace font)
For example, the character π ("GREEK SMALL LETTER PI (U+03C0)")
occupies one column, and its UTF-8 encoding requires two bytes; the
character 🙂 ("SLIGHTLY SMILING FACE (U+1F642)") occupies two
columns, and its UTF-8 encoding requires four bytes.
In GCC 11 the column numbers default to being column numbers, respecting
multi-column characters. The old behavior can be restored using a new
option
-fdiagnostics-column-unit=byte
.
There is also a new option
-fdiagnostics-column-origin=
,
allowing the pre-existing default of the left-hand column being column
1 to be overridden if desired (e.g. for 0-based columns). The output
of
-fdiagnostics-format=json
has been extended to supply both byte counts and column numbers for all source locations.
Additionally, in previous releases of GCC, tab characters in the source
would be emitted verbatim when quoting source code, but be prefixed
with whitespace or line number information, leading to misalignments
in the resulting output when compared with the actual source. Tab
characters are now printed as an appropriate number of spaces, using the
-ftabstop
option (which defaults to 8 spaces per tab stop).
For targets that produce DWARF debugging information GCC now
defaults to DWARF
version 5 (with the exception of VxWorks and Darwin/Mac OS X
which default to version 2 and AIX which defaults to version 4).
This can produce up to 25% more compact debug information
compared to earlier versions.
To take full advantage of DWARF version 5 GCC needs to be build
against binutils version 2.35.2 or higher. When GCC is build
against earlier versions of binutils GCC will still emit DWARF
version 5 for most debuginfo data, but will generate version 4
debug line tables (even when explicitly given -gdwarf-5
).
The following debug information consumers can process DWARF version 5:
- GDB 8.0, or higher
- valgrind 3.17.0
- elfutils 0.172, or higher (for use with systemtap,
dwarves/pahole, perf and libabigail)
- dwz 0.14
Programs embedding libbacktrace are urged to upgrade to the version
shipping with GCC 11.
To make GCC 11 generate an older DWARF version
use -g
together with -gdwarf-2
,
-gdwarf-3
or -gdwarf-4
.