-- Set optimization indicators appropriately. In gcc-based GNAT this
-- is picked up from imported variables set by the gcc driver, but
- -- for compilers with non-gcc back ends we do it here to allow use
- -- of these switches by the front end. Allowed optimization switches
- -- are -Os (optimize for size), -O[0123], and -O (same as -O1).
+ -- for compilers with non-gcc back ends we do it here to allow use of
+ -- these switches by the front end. Allowed optimization switches are
+ -- -Os (optimize for size), -O[0123], -O (same as -O1), -Ofast
+ -- (disregard strict standards compliance), and -Og (optimize
+ -- debugging experience).
elsif Switch_Chars (First) = 'O' then
if First = Last then
Optimization_Level :=
Character'Pos (Switch_Chars (Last)) - Character'Pos ('0');
+ -- Switch -Og is between -O0 and -O1 in GCC. Consider it like
+ -- -O0 for other back ends.
+
+ elsif Switch_Chars (Last) = 'g' then
+ Optimization_Level := 0;
+
else
Fail ("invalid switch: " & Switch_Chars);
end if;
+ -- Switch -Ofast enables -O3
+
+ elsif Switch_Chars (First + 1 .. Last) = "fast" then
+ Optimization_Level := 3;
+
else
Fail ("invalid switch: " & Switch_Chars);
end if;
return;
- -- Special check, the back end switch -fno-inline also sets the
+ -- Special check, the back-end switch -fno-inline also sets the
-- front end flags to entirely inhibit all inlining. So we store it
-- and set the appropriate flags.
end case;
end if;
- -- Ignore all other back end switches
+ -- Ignore all other back-end switches
elsif Is_Back_End_Switch (Switch_Chars) then
null;