Optimizing code generation fpc (lazarus)?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Optimizing code generation fpc (lazarus)?

Free Pascal - General mailing list
Maybe a stupid question, but...

I am struggling with porting a Windows service application written
with D7/D2007 back in 2004-2006 or so. I need to get it moved to Linux
because of Windows 10 issues.

Now I am handling a lot of errors from a "CommonFuncs" unit that is
used in many different applications including this one. It contains a
whole lot of functions that all work fine in Windows from Delphi.
Looks like it is a unit that has collected a lot of very special
functions over the years...

When compiling from Lazarus I get a lot of errors thrown from
functions not used by the application I am porting....

So now I wonder if there is a way to compile the application where the
compiler will not touch functions that are not used in the current
project?

As it is now I am slooowly working my way through a mass of functions
that are not used in order to ifdef away parts of the code and finding
FPC equivalents for others.
But it would be so much easier if the compiler could disregard
functions that are not called in the project and therefore not try to
compile them at all.

Or is this impossible due to the way the compile/linking is working?


--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Optimizing code generation fpc (lazarus)?

Free Pascal - General mailing list
On Sun, 17 May 2020 11:15:17 +0200, Bo Berglund via fpc-pascal
<[hidden email]> wrote:

Maybe a stupid question, but...

I am struggling with porting a Windows service application written
with D7/D2007 back in 2004-2006 or so. I need to get it moved to Linux
because of Windows 10 issues.

Now I am handling a lot of errors from a "CommonFuncs" unit that is
used in many different applications including this one. It contains a
whole lot of functions that all work fine in Windows from Delphi.
Looks like it is a unit that has collected a lot of very special
functions over the years...

When compiling from Lazarus I get a lot of errors thrown from
functions not used by the application I am porting....

So now I wonder if there is a way to compile the application where the
compiler will not touch functions that are not used in the current
project?

As it is now I am slooowly working my way through a mass of functions
that are not used in order to ifdef away parts of the code and finding
FPC equivalents for others.
But it would be so much easier if the compiler could disregard
functions that are not called in the project and therefore not try to
compile them at all.

Or is this impossible due to the way the compile/linking is working?

ADDING ANOTHER QUESTION:
------------------------
Is there a way to find out which functions in a particular unit are
called from the other units in the project?
Sort of an expanded list of "dependencies"...


--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Optimizing code generation fpc (lazarus)?

Jonas Maebe-3
On 17/05/2020 11:18, Bo Berglund via fpc-pascal wrote:
> So now I wonder if there is a way to compile the application where the
> compiler will not touch functions that are not used in the current
> project?

No.

> ADDING ANOTHER QUESTION:
> ------------------------
> Is there a way to find out which functions in a particular unit are
> called from the other units in the project?

When compiles, you can tell the linker to generate a linker map with the
-Xm parameter, and then you can see all the (mangled) names of the
referenced symbols (variables, functions, rtti, internally generated
constants, ...). I'm sure Delphi can also generate a linker map with
that information.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Optimizing code generation fpc (lazarus)?

Michael Van Canneyt
In reply to this post by Free Pascal - General mailing list


On Sun, 17 May 2020, Bo Berglund via fpc-pascal wrote:

>
> ADDING ANOTHER QUESTION:
> ------------------------
> Is there a way to find out which functions in a particular unit are
> called from the other units in the project?
> Sort of an expanded list of "dependencies"...

The lazarus IDE can give you this information.
It can be that you need the cody package installed, but this is how it works:

Click right on the function declaration/implementation,
select 'find' and then 'Find identifier references'.

The IDE will then show you where a particular function is used.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal