[fpc-pascal] Compiler flag define or $IFOPT for optimizations

Benito van der Zander benito at benibela.de
Fri Jun 3 14:41:09 CEST 2022


Hi,
> 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. 

Unfortunately it is picking up all kinds of options from fpc.cfg and 
Lazarus.

Like in this case, I tried to disable range checking, and it is still 
enabled.


 > 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.

I am setting up a build server that compiles the entire project from 
scratch on every commit.


Best,
Benito
On 28.05.22 14:34, Tomas Hajny via fpc-pascal wrote:
> 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
> _______________________________________________
> fpc-pascal maillist  - fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20220603/ea89909e/attachment.htm>


More information about the fpc-pascal mailing list