pub struct GnucVersion {
pub major: u32,
pub minor: u32,
pub patch: u32,
}Expand description
The GCC release the compiler claims to be, as __GNUC__, __GNUC_MINOR__ and
__GNUC_PATCHLEVEL__.
Design: spec/04-driver-and-cli.md section 4.5, which makes this a knob rather than a
constant and says to start conservative and raise it as the matrix in rucc-gnu fills in.
The default is sixteen, which is the release this compiler is written against. glibc gates
most of what it hands a caller on __GNUC_PREREQ, so the claim decides which half of
sys/cdefs.h we get, and a project does the same thing to itself: it asks what compiler this
is and writes different code depending on the answer. The claim is therefore not a boast, it
is the sentence that selects which of a program’s own branches gets compiled, and claiming an
old release means compiling the code that release needed rather than the code this compiler
wants.
It stood at seven for a long time, and seven was the right number then. Below seven
bits/floatn-common.h writes typedef float _Float32; over a keyword this compiler already
has and every header that reaches it stops there, so moving from 4.2.1 to seven took Ubuntu
24.04’s glibc 2.39 from 180 of 214 headers to 202 and took the amalgamated sqlite from four
errors to none. What kept it at seven after that was that nothing needed more, and claiming a
version whose promises have not been kept means being handed syntax the compiler cannot parse.
What needed more was micropython. Its py/nlrx64.c asks for __GNUC__ >= 8 before it writes
__attribute__((naked)), and at seven it took the gcc 7 path instead and handed this compiler
an ordinary function ending in a bare jmp, which is refused and ought to be. The naked
function it writes at eight and above compiles here, byte for byte what gcc 16 emits, and had
compiled for a week without micropython ever reaching it.
The measurement that moved it is the real corpus at the rung the claim could break: fifty six
projects across rungs zero through three, built at -O2 with the claim at seven and again at
sixteen, on gcc 16.0.1 and glibc. Fifty of fifty six passed both times, and it was the same
fifty both times, with the same four not passing for the same four reasons. Nothing regressed
and nothing started working by accident. Thirteen and sixteen had already been measured
identical to seven on glibc, on the macOS SDK and on sqlite when seven was chosen, so this
confirms on real builds what the header sweep said.
Sixteen point zero rather than the point release on any particular machine, because
__GNUC_PREREQ(16, 1) is a promise about a specific release and the honest claim is the
earliest one in the series whose promises this compiler means to keep.
Fields§
§major: u32__GNUC__.
minor: u32__GNUC_MINOR__.
patch: u32__GNUC_PATCHLEVEL__.
Implementations§
Source§impl GnucVersion
impl GnucVersion
Sourcepub const fn default_std(self) -> Std
pub const fn default_std(self) -> Std
The dialect that GCC release compiles when the command line has no -std=.
A build that claims an old GCC is usually an old tree, and an old tree that passes no
-std= was written against that release’s default rather than ours. Kernels up to 3.17 are
the example that matters: they rely on gnu89, and under gnu23 their own identifiers meet
keywords. GCC 5 moved the default to gnu11, GCC 8 to gnu17 and GCC 15 to gnu23. Every one of
these is a GNU dialect, so the extensions stay on. spec/04-driver-and-cli.md section 4.6.
Sourcepub const fn common_by_default(self) -> bool
pub const fn common_by_default(self) -> bool
Whether that GCC release put a tentative definition in a common symbol when the command line did not say, which every release before 10 did.
Sourcepub fn dumpversion(self) -> String
pub fn dumpversion(self) -> String
What -dumpversion prints for that release.
Before GCC 7 it was the whole version, and there was nothing else to ask. GCC 7 added
-dumpfullversion for that and, built the way the distributions build it, prints only the
major number for -dumpversion, which is the shape scripts written since then expect.