[fpc-pascal] Compiler flag define or $IFOPT for optimizations
Tomas Hajny
XHajT03 at hajny.biz
Sat May 28 14:34:24 CEST 2022
On 2022-05-28 13:44, Benito van der Zander via fpc-pascal wrote:
Hi,
> I want to show how my program was compiled.
>
> Now I have string like "FPC3.2.2 i386-Linux R+C+" from
>
> compiler := 'FPC' + {$INCLUDE %FPCVERSION%} + ' ' + {$INCLUDE
> %FPCTargetCPU%}+'-'+{$INCLUDE %FPCTargetOS%}+ ' ' + {$IfOpt
> R+}+'R+'{$endif} {$IfOpt S+}+'S+'{$endif} {$IfOpt O+}+'O+'{$endif}
> {$IfOpt Q+}+'Q+'{$endif} {$IfOpt M+}+'M+'{$endif} {$IfOpt
> C+}+'C+'{$endif};
>
> But the optimization level (-O2 or -O1 ...) is missing.
>
> Is there an IFOPT for that? Or a define with all the arguments
I don't think that there's such an option at the moment. However, you
can possibly solve it by always taking the options from an environment
variable to the command line and then including contents of this command
line to your sources. I don't think that it makes much sense for the
compiler to provide such an option, because unlike the compiler version,
different options (including the optimization level) may be used for
compilation of different units and there's no such a thing as a general
optimization level valid for the complete compiled program from the
compiler point of view. You can introduce something like that yourself
by always building all your sources from scratch, but then the solution
outlined above should work for you.
Tomas
More information about the fpc-pascal
mailing list