Sign in Join

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

Mailing lists / fpc-pascal / 2015-05

Why does fpc copies *.lfm files to unit output directory

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

I don't know when this started, but fpc copies *.lfm files to the unit output directory. Then turns around and complains about duplicate *.lfm files? Though the complaint about duplicate files might be from Lazarus IDE - I'm not sure any more with the new Messages Window behaviour in Lazarus.

================================
Messages, Warnings: 34
Warning: Duplicate file "fpideexteditorinsertfilenameunit.lfm" in "weblaz 1.0",
path="/home/graemeg/devel/lazarus/components/fpweb/lib/x86_64-linux/fpideexteditorinsertfilenameunit.lfm" Warning: Duplicate file "fpideexteditorinsertfilenameunit.lfm" in "lazwebextra 0.9",
path="/home/graemeg/devel/lazarus/components/fpweb/fpideexteditorinsertfilenameunit.lfm" Warning: Duplicate file "fpwebfieldsettagunit.lfm" in "weblaz 1.0", path="/home/graemeg/devel/lazarus/components/fpweb/lib/x86_64-linux/fpwebfieldsettagunit.lfm" Warning: Duplicate file "fpwebfieldsettagunit.lfm" in "lazwebextra 0.9", path="/home/graemeg/devel/lazarus/components/fpweb/fpwebfieldsettagunit.lfm" Warning: Duplicate file "fpwebhrefeditunit.lfm" in "weblaz 1.0", path="/home/graemeg/devel/lazarus/components/fpweb/lib/x86_64-linux/fpwebhrefeditunit.lfm" Warning: Duplicate file "fpwebhrefeditunit.lfm" in "lazwebextra 0.9", path="/home/graemeg/devel/lazarus/components/fpweb/fpwebhrefeditunit.lfm" Warning: Duplicate file "fpwebhtmltaglegendunit.lfm" in "weblaz 1.0", path="/home/graemeg/devel/lazarus/components/fpweb/lib/x86_64-linux/fpwebhtmltaglegendunit.lfm" Warning: Duplicate file "fpwebhtmltaglegendunit.lfm" in "lazwebextra 0.9",
path="/home/graemeg/devel/lazarus/components/fpweb/fpwebhtmltaglegendunit.lfm" Warning: Duplicate file "fpwebnewhtmlfileunit.lfm" in "weblaz 1.0", path="/home/graemeg/devel/lazarus/components/fpweb/lib/x86_64-linux/fpwebnewhtmlfileunit.lfm" Warning: Duplicate file "fpwebnewhtmlfileunit.lfm" in "lazwebextra 0.9", path="/home/graemeg/devel/lazarus/components/fpweb/fpwebnewhtmlfileunit.lfm" ...snip...
================================

I first thought it was Lazarus IDE copying the files, but then found out that it is fpc. Why exactly is fpc copying the file? If it is to find the *.lfm files while linking... well if it knows where to find the files to copy, why can't it find the original *.lfm files (in the source directories) to do linking?

It's not just duplicate files, it seems sometimes the *.lfm files can changes, without the associated *.pas file changing. In such cases fpc doesn't seem to copy the *.lfm files, but then compilation/linking fails. I had to create a bash script to manually clear out all unit output directories to resolve this issue. This happens a couple of times per week now.

As I said, I don't know when this behaviour started in FPC - I never noticed it for years, because fpGUI doesn't have extra form files (like *.lfm), but only a single *.pas file. But recently I've been working on a LCL based project, and now frequently hit this issue.

I'm using 64-bit FPC 2.6.4 and Lazarus IDE v1.5 (trunk checkout from beginning of May) on FreeBSD 10.1

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Mattias Gaertner
to Graeme Geldenhuys
Show quoted text 7 lines
Hi, I don't know when this started, but fpc copies *.lfm files to the unit output directory. Then turns around and complains about duplicate *.lfm files? Though the complaint about duplicate files might be from Lazarus IDE - I'm not sure any more with the new Messages Window behaviour in Lazarus.

The duplicate .lfm warnings come from the IDE. The compiler messages are under "Compile ...".

Show quoted text 8 lines
================================ Messages, Warnings: 34 Warning: Duplicate file "fpideexteditorinsertfilenameunit.lfm" in "weblaz 1.0", path="/home/graemeg/devel/lazarus/components/fpweb/lib/x86_64-linux/fpideexteditorinsertfilenameunit.lfm" Warning: Duplicate file "fpideexteditorinsertfilenameunit.lfm" in "lazwebextra 0.9", path="/home/graemeg/devel/lazarus/components/fpweb/fpideexteditorinsertfilenameunit.lfm"

The IDE warns because the lfm file is in the output of weblaz and in the sources of lazwebextra as well. And lazwebextra uses weblaz. This typically happens when a file was moved and the old copy was not deleted. In this case it is by design:

Package lazwebextra is now an empty dummy package. See the description of the package. The two packages share the lfm files.

I added a check, so that the IDE does not warn for files in shared source directories.

I first thought it was Lazarus IDE copying the files, but then found out that it is fpc. Why exactly is fpc copying the file? If it is to find the *.lfm files while linking...

AFAIK this is the reason.

Show quoted text 7 lines
[...] It's not just duplicate files, it seems sometimes the *.lfm files can changes, without the associated *.pas file changing. In such cases fpc doesn't seem to copy the *.lfm files, but then compilation/linking fails. I had to create a bash script to manually clear out all unit output directories to resolve this issue. This happens a couple of times per week now.

I find this annoying too. From an user pov it looks like a compiler bug. Maybe some compiler guru can tell if this is a bug or by design. Then I know if Lazarus needs a workaround.

Mattias

Reply by email

Jonas Maebe
to Graeme Geldenhuys: I don't know when this started, but fpc copies *.lfm files to the unit output directory.…

Graeme Geldenhuys wrote on Tue, 12 May 2015:

I don't know when this started, but fpc copies *.lfm files to the unit output directory.

It started on 29 May 2007 :) (r7515)

I think the reason is that the unit output directory is supposed to contain everything you need to use that unit in a program. If you use a unit, you also need its resource file(s). It's probably also done for the main program out of convenience.

Jonas

Reply by email

Graeme Geldenhuys
to Mattias Gaertner: On Tue, 12 May 2015 10:26:04 +0100 The duplicate .lfm warnings come from the IDE. The…
Mattias Gaertner wrote
The duplicate .lfm warnings come from the IDE. The compiler messages are under "Compile ...".

Thanks for confirmation.

The IDE warns because the lfm file is in the output of weblaz and in the sources of lazwebextra as well. And lazwebextra uses weblaz.

Just to be clear, this issue isn't only with packages include with Lazarus. I get similar warnings about non-Lazarus packages I use in my project too.

Then I know if Lazarus needs a workaround.

It looks like a bug to me too, and Lazarus shouldn't need to work around it. After all, it will affect other editors and IDE's used with FPC too.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Graeme Geldenhuys
to Jonas Maebe: Graeme Geldenhuys wrote on Tue, 12 May 2015: It started on 29 May 2007 :) (r7515) I think…
Jonas Maebe wrote
I think the reason is that the unit output directory is supposed to contain everything you need to use that unit in a program.

Interestingly, when compiling MSEide, there are no *.mfm files (equivalent to *.lfm from Lazarus) in the unit output directory.

Also, if *.res files are in the source directory, and used via {$R ..}, the *.res files don't seem to be copied to the unit output directory. The exception is if there is no *.res, only *.rc - then a compiler .rc file will end up in the unit output directory. The latter I understand.

So it seems *.lfm is copied, but *.res and *.mfm isn't. Yet they are all used via the {$R..} usage in .pas files.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email