Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2022-05

Compiler flag define or $IFOPT for optimizations

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Benito van der Zander

Hallo,

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

Bye,

Benito

Tomas Hajny
to Benito van der Zander

On 2022-05-28 13:44, Benito van der Zander via fpc-pascal wrote:

Hi,

Show quoted text 13 lines
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

Benito van der Zander
to Tomas Hajny

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

Tomas Hajny wrote 35 lines
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  - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Tomas Hajny
to Benito van der Zander

On 2022-06-03 14:41, Benito van der Zander via fpc-pascal wrote:

Hi,

Show quoted text 9 lines
> 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 disable using the configuration files using -n (that's what is being done during the FPC release process for release builds) and define all necessary / used options from the environment.

Show quoted text 6 lines
> 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.

As mentioned above, then the suggested approach should fit well, IMHO.

Tomas

Show quoted text 42 lines
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 - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal