Sign in Join

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

Mailing lists / fpc-pascal / 2020-05

Optimizing code generation fpc (lazarus)?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Bo Berglund

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 is this impossible due to the way the compile/linking is working?

Bo Berglund Developer in Sweden
Bo Berglund
to Bo Berglund

On Sun, 17 May 2020 11:15:17 +0200, Bo Berglund via fpc-pascal 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 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
Jonas Maebe
to Bo Berglund
Bo Berglund 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

Michael Van Canneyt
to Bo Berglund: On Sun, 17 May 2020 11:15:17 +0200, Bo Berglund via fpc-pascal Maybe a stupid question,…
Bo Berglund wrote 6 lines
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.