#[non_exhaustive]pub struct Options {Show 28 fields
pub target: Triple,
pub opt_level: OptLevel,
pub emit: EmitKind,
pub debug_info: bool,
pub frame_pointer: bool,
pub red_zone: bool,
pub warnings_are_errors: bool,
pub error_limit: u32,
pub std: Std,
pub gnu_extensions: bool,
pub pedantic: bool,
pub gnuc: GnucVersion,
pub hosted: bool,
pub builtins: bool,
pub no_builtin: Vec<String>,
pub defines: Vec<String>,
pub undefines: Vec<String>,
pub search: SearchPath,
pub line_markers: bool,
pub dumps: Dumps,
pub passes: Vec<(String, bool)>,
pub pass_fuel: Vec<(String, u32)>,
pub pass_gates: Vec<(bool, String)>,
pub dump_ir: Vec<String>,
pub opt_info: Vec<String>,
pub opt_info_file: Option<String>,
pub verify_each: bool,
pub rule_coverage: Option<String>,
}Expand description
Everything a compilation was asked to do.
Options are a plain value with no interior mutability, so a caller can build one, clone
it, tweak one field and run a second compilation, which is exactly what the differential
testing in spec/15-testing.md needs.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.target: TripleThe target to generate code for.
opt_level: OptLevelThe optimisation level.
emit: EmitKindWhat to produce.
debug_info: boolWhether to emit debug information.
frame_pointer: boolWhether every function keeps a frame pointer, from -fno-omit-frame-pointer.
Off by default, which is what gcc does at every level above -O0 and what leaves the
register free for the allocator. A profiler that walks the stack by following saved frame
pointers needs it on, and so does any code a debugger has to unwind without unwind tables.
red_zone: boolWhether the red zone may be used, from -mno-red-zone turned around.
The 128 bytes below the stack pointer that the System V psABI promises no signal handler
will touch, which lets a small leaf function keep its locals without moving the stack
pointer at all. A kernel turns this off, because an interrupt taken on the kernel stack
makes the promise false, and every kernel build in the wild passes -mno-red-zone for
exactly that reason. A convention without a red zone ignores this.
warnings_are_errors: boolWhether warnings are errors.
error_limit: u32How many diagnostics to print before giving up. Past a certain point the output is noise from a single earlier mistake, and GCC’s default of no limit is not a kindness.
std: StdThe dialect, from -std=.
gnu_extensions: boolWhether the GNU extensions are on, which is -std=gnu23 rather than -std=c23.
pedantic: boolWhether -pedantic was given, which is what turns a use of an extension from silence
into a diagnostic. It is not the same knob as the dialect: -std=c17 -pedantic warns
about a construct that -std=c17 alone accepts without a word.
gnuc: GnucVersionThe GCC release claimed, from -fgnuc-version=.
hosted: boolWhether there is a standard library, which is -ffreestanding turned around.
builtins: boolWhether a call to a C library function written under its own plain name may be taken to
mean that function, which is -fno-builtin turned around.
The names are reserved, so llabs is the library’s llabs and the compiler is allowed to
know what it does. A program that means something else by one of them is the reason the
flag exists, and -ffreestanding turns it off as well, because a freestanding program has
no C library for the name to be the name of. The __builtin_ spellings are not affected by
either, since the prefix is the program saying which function it means.
no_builtin: Vec<String>The names -fno-builtin-<name> took away one at a time, without the prefix.
A build that means its own memcpy and the library’s everything else writes this rather
than the whole flag, which is what the kernel does for a handful of names.
defines: Vec<String>-D in command line order. FOO means FOO=1, as GCC has it.
undefines: Vec<String>-U in command line order, applied after the defines because -U wins.
search: SearchPathWhere a header is looked for.
line_markers: boolWhether -E writes line markers, which -P turns off.
dumps: DumpsWhat the -d family asks for.
passes: Vec<(String, bool)>What -f<pass> and -fno-<pass> said about an optimizer pass, in the order the command
line said it, so that the last mention of a pass is the one that decides.
The pipeline the level chose is the starting point and this is what is added to and taken away from it. The names are checked against the pass list while the arguments are parsed, so anything in here is a pass the compiler has.
pass_fuel: Vec<(String, u32)>What -fpass-fuel=<pass>=<n> limited a pass to, by pass name.
A pass with an entry here performs exactly that many transformations and then stops
transforming, which is what bisects a miscompilation to one rewrite. See section 9.10 of
spec/09-optimizer.md.
pass_gates: Vec<(bool, String)>What -fdisable-<pass>[=<range>] and -fenable-<pass>[=<range>] said, in the order the
command line said it, with true for the enabling half.
A rule covers the functions it names and nothing else, and the last rule that covers a
function is the one that decides for it, so the order has to survive. This is the second
half of the bisection interface in section 41.6 of spec/optimizer/41-correctness.md:
-fpass-fuel finds the rewrite and this finds the function. The pass names are checked
against the pass list while the arguments are parsed.
dump_ir: Vec<String>What -fdump-ir= asked to see, as it was written, which is all, before-<pass> or
after-<pass>.
opt_info: Vec<String>What -fopt-info asked to hear about, as the keywords were written, with the leading
hyphen taken off, so a bare -fopt-info is the empty string in here.
The keywords are optimized, missed, note and all, and two flags add up rather than
the second replacing the first. Checked while the arguments are parsed, so anything in
here is a spelling the optimizer understands. See section 42.2 of
spec/optimizer/42-measurement.md for why missed is the one that earns the feature.
opt_info_file: Option<String>Where -fopt-info=<file> sends the remarks, or None for standard error.
One file for the whole run rather than one per input, the way GCC does it, and the last
one on the command line is the one that decides. A harness that wants the remarks kept
away from the diagnostics gives a file, which is what the corpus in tamnd/rucc-corpus
does with GCC so that a rejection can still be matched against the diagnostic stream.
verify_each: boolWhether the IR verifier runs after every pass that changed anything.
On in a debug build without being asked, since that is where a broken pass should be
caught. -Zverify-each turns it on in a release build, which is what CI wants.
rule_coverage: Option<String>Where -Zrule-coverage=FILE writes which lowering rules fired, if it was given.
A measurement rather than a thing a build asks for, which is why it is spelled with a -Z
the way an unstable option is everywhere else: it is here for the harness in
tamnd/rucc-compat to union over a corpus and report, and nothing about the code that comes
out changes when it is on. One file per run of the compiler, holding the whole rule set with
the rules this run reached marked, whatever the run compiled and however many files it was.