[fpc-pascal] Why does fpc copies *.lfm files to unit output directory

Mattias Gaertner nc-gaertnma at netcologne.de
Tue May 12 12:34:16 CEST 2015

On Tue, 12 May 2015 10:26:04 +0100
Graeme Geldenhuys <mailinglists at geldenhuys.co.uk> wrote:

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

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

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


More information about the fpc-pascal mailing list