Recent

Author Topic: Lazarus doesn't recompile changed units  (Read 8057 times)

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Lazarus doesn't recompile changed units
« Reply #15 on: September 15, 2020, 10:48:41 am »
Sometimes strange behaviour is caused by "super-intelligent" anti-virus going crazy: Turn off your virus-scanner for a test. Add Lazarus and project folders to the exception list of the scanner.

Converting from Delphi: The sources of external libraries in Delphi are usually added to the unit search path. You should not do this in Lazarus, instead of adding the units to the search path you should add the corresponding packages to the project requirements.

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Lazarus doesn't recompile changed units
« Reply #16 on: September 15, 2020, 04:56:09 pm »
I have also sometimes this experience. I also noticed remainig linkXXXX.res files in my project directory. It does not happen always. I observed the directory and in >90% cases of Quick Compile or Run (F9) is that file created temporarily and immediately disappears.
Time to time it persists.
(I had to change file extension to *.txt to be able to upload it.)
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Re: Lazarus doesn't recompile changed units
« Reply #17 on: September 16, 2020, 08:58:57 am »
Anti-virus: only what windows has built in.

> - Are all the units in the project? (listed in project inspector?)

either they are listed in the source (a la delphi), or they are on the search path. It doesn't appear to make any difference which is which. I'm not using the project inspector.

> - Or if they are in packages, are they listed in that package?

not in packages.

> Are they all in the same folder, or are they in different sub/folders? How are other folders included.

There's about 25 folders for the source


And one case that sometimes may cause issues: Circular unit references, in combination with inline or generics. (Not sure about the exact circumstances needed to get an issue)

FLLSilva

  • New Member
  • *
  • Posts: 11
Re: Lazarus doesn't recompile changed units
« Reply #18 on: September 30, 2020, 04:44:31 am »
I have exactly the same problem that was reported here. I was already going crazy because I didn't even know how to start explaining this situation since English is not my native language. Luckily for me I found this thread.

The following is happening: I make any changes to any unit of the project. I compile with ctrl+F9 or shift+F9, whatever.

The IDE displays the progress of the compilation in the message area. Informs that the compilation happened successfully.

If I look at the application's .exe file, it appears with the current date and time, so it was recreated.

HOWEVER, when running the application, the changes made are not present, it remains exactly the same as the version before compilation. I already tried to DELETE the .exe BEFORE compiling... it is created again but the same problem continues.

In order for the .exe to be updated successfully, I need to DELETE the folder with the build binaries, so that Lazarus creates everything again. When I do this, the .exe is updated correctly. I need to do it all the time if I want to trust that my application was compiled correctly.

The thing is so bizarre that today I lost hours behind a problem and couldn't find it, I included components in a TForm and they just didn't show up. After I discovered the solution (excluding the binaries folder from the compilation), I did several tests and found that it is as if Lazarus could not identify that there was a change in the date and time of the units, or that he was using a copy of the files that were located in some kind of buffer.

The problem is so serious that I inserted deliberate errors into a unit that would prevent it from being compiled. I compiled the project and IDE simply gave the result as being successful.

After that, I deleted the binaries folder and had the project recompiled again. This time the IDE identified all the errors that I had inserted in the unit and did not compile the project.

I know it sounds crazy, I had never seen this before in my life, I thought it just happened to me but I managed to find someone else who has exactly the same problem as mine.

The configuration of my environment is as follows:

- Windows 10 Pro 64-Bits, Version 2004, Build 19041.508
- 16 Gb RAM
- Intel i3 processor
- Lazarus 2.0.10 64-bits
- FPC 3.2.0


There is no way I can set up a small project to simulate this, even because it does not happen with just 1 project, I did the same test with 2 other projects and the same thing happens.
It's been a few months since I migrated from version 2.0.8 to version 2.0.10 of Lazarus... as I wasn't having a lot of maintenance on these projects I didn't realize when the problem started to happen, but the projects were initially written in IDE version 2.0.8 and there was no such problem, so I believe it is something with the new version 2.0.10.

Could someone with more expertise, and a command of English, report this problem to the development team, please?

I really appreciate everyone's help. Thank you.

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Lazarus doesn't recompile changed units
« Reply #19 on: September 30, 2020, 04:59:49 am »
Your English is good and you explained it well.

I sometimes have such problem too. It can be easily fixed by deleting lib folder (to force the compiler to regenerate them) or use Lazarus main menu > Run > Build.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus doesn't recompile changed units
« Reply #20 on: September 30, 2020, 01:03:35 pm »
More important, than a good English explanation (which you did) is an example that reproduces the issue.
For example a zipped copy of the project folder, that I can unpack, open in Lazarus, and see it happen here.

There are a few thinks you can check.
<project_dir>  => the folder that contains the *.lpi file


1)
When you get the issue, you should know the name of the unit that you changed.
E.g. you changed "unit MyMainForm" in MyMainForm.ppu.
Then:
- Check if there are any MyMainForm.o or MyMainForm.ppu files
=> You should have exactly ONE of each. And they should be in <project_dir>/lib/x86_64/*  (or i386 or similar)
=> If there are any other  MyMainForm.o or MyMainForm.ppu  then that is bad
=> They should both have the current date/time

If you made changes to a Form (add/change components), then check that <project_dir>/lib/x86_64/MyMainForm.lfm is up to date.

Also make sure, that your unit name is not used elsewhere. For example, you cannot have a unit called "graphics" because that already exists.

2)
Are the source files *ALL* in <project_dir>?
Do you have some sources forms in other folders? Such as <project_dir>/some_folder? Or even outside <project_dir> like c:\my_other_sources?
Yes that should work. But who knows, maybe there is an issue?

Do you have code like
Code: Pascal  [Select][+][-]
  1. unit MyUnit;
  2. uses OtherUnit in '..\foo\other.pas'

3)
Do you have include files {$I ....}
I am not sure how well detection of changes in include files work....

4) Do you have circular unit references?
MyUnit1 uses MyUnit2, and MyUnit2 uses MyUnit1? => Circles can be bigger, including more units.
Menu View > "Unit dependencies" then change to tab "Project and packages" => Does the lower graph (with your units) have any red lines?




FLLSilva

  • New Member
  • *
  • Posts: 11
Re: Lazarus doesn't recompile changed units
« Reply #21 on: September 30, 2020, 01:59:50 pm »
Your English is good and you explained it well.

I sometimes have such problem too. It can be easily fixed by deleting lib folder (to force the compiler to regenerate them) or use Lazarus main menu > Run > Build.

Thank you Handoko.

Build (shift+f9) the project also does not work. It only works by excluding the lib folder itself.

I'm working around the problem by configuring a .bat file in each project, on the compiler command screen, to be executed BEFORE compilation. This file deletes files from the lib folder, so I don't have to do it manually.

FLLSilva

  • New Member
  • *
  • Posts: 11
Re: Lazarus doesn't recompile changed units
« Reply #22 on: September 30, 2020, 02:36:46 pm »
More important, than a good English explanation (which you did) is an example that reproduces the issue.
For example a zipped copy of the project folder, that I can unpack, open in Lazarus, and see it happen here.

Hi Martin_fr.

Answering your questions:

<project_dir>  => the folder that contains the *.lpi file
A = *.lpi files they are located in the folder one level higher than the source files, along with the other files in the project (*.lps, *.lpi, *.lpr).

1) When you get the issue, you should know the name of the unit that you changed. E.g. you changed "unit MyMainForm" in MyMainForm.ppu. Then:
- Check if there are any MyMainForm.o or MyMainForm.ppu files
=> You should have exactly ONE of each. And they should be in <project_dir>/lib/x86_64/*  (or i386 or similar)

A = Yes, there is only one copy of the modified units, and they are located only in the lib folder (x86_64-win64).

=> If there are any other  MyMainForm.o or MyMainForm.ppu  then that is bad
A = No, there is not.

If you made changes to a Form (add/change components), then check that <project_dir>/lib/x86_64/MyMainForm.lfm is up to date.
A = I believe this is a function of the compiler, don't you agree? If I need to check the date and time of every * .lfm file to see if it has been updated or not in the lib folder, it is better to continue simply deleting the files in this folder, it is faster and safer.

Also make sure, that your unit name is not used elsewhere. For example, you cannot have a unit called "graphics" because that already exists.
A = No, the units are named following a specific pattern and with names in Portuguese.

2) Are the source files *ALL* in <project_dir>?
Do you have some sources forms in other folders? Such as <project_dir>/some_folder? Or even outside <project_dir> like c:\my_other_sources?
Yes that should work. But who knows, maybe there is an issue?

A = Yes, I have source files distributed in several subfolders, but all within the main project folder.
       Example: <projDir>\Source, <projDir>\Source\Server, <projDir>\Source\Client, <projDir>\Source\Client\Views, <projDir>\Source\Client\Models, <projDir>\Source\Client\Controllers, etc.
       But all of these units are properly inserted in the project's .lpr file.

Do you have code like:

    unit MyUnit;
    uses OtherUnit in '..\foo\other.pas'

A = No, the only place that has such a code is in the project's .lpr file, informing where each source file is located. Within the project units I refer only to their name.

3) Do you have include files {$I ....}
I am not sure how well detection of changes in include files work....

A = No, I do not have.

4) Do you have circular unit references?
MyUnit1 uses MyUnit2, and MyUnit2 uses MyUnit1? => Circles can be bigger, including more units.
Menu View > "Unit dependencies" then change to tab "Project and packages" => Does the lower graph (with your units) have any red lines?

A = I ran this analysis now and did not show any dependency flagged in red.

See, this is a small part from the .lpr file of a REST Dataware server project, there are very few units and all are properly identified and with their locations relative to where the project is saved.

Code: Pascal  [Select][+][-]
  1. program ServidorStandalonePrj;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Interfaces, // this includes the LCL widgetset
  10.   Forms, SysUtils, unidac10, ibprovider10, liteprovider10, oraprovider10, pgprovider10, zcomponent,
  11.   { you can add units after this }
  12.   servidor.dm                   in '.\Source\Standalone\servidor.dm.pas',
  13.   servidor.view.principal       in '.\Source\Standalone\servidor.view.principal.pas',
  14.   common.criptografia           in '..\Public\common.criptografia.pas',
  15.   common.vo.infoacesso          in '..\Public\common.vo.infoacesso.pas',
  16.   servidor.Consts               in '.\Source\servidor.consts.pas',
  17.   servidor.login                in '.\Source\servidor.login.pas',
  18.   servidor.sm.register          in '.\Source\servidor.sm.register.pas',
  19.   servidor.tipos                in '.\Source\servidor.tipos.pas',
  20.   {$IFDEF USE_UNIDAC}
  21.   servidor.dm.database          in '.\Source\UniDac\servidor.dm.database.pas',
  22.   servidor.sessions.Clear       in '.\Source\UniDac\servidor.sessions.clear.pas',
  23.   servidor.sessions             in '.\Source\UniDac\servidor.sessions.pas',
  24.   {$ENDIF}
  25.   common.estoque.vo.fornecedor  in '..\..\Estoque\Source\common.estoque.vo.fornecedor.pas',
  26.   servidor.estoque.calculos     in '..\..\Estoque\Source\Servidor\servidor.estoque.calculos.pas',
  27.   servidor.estoque.fornecedores in '..\..\Estoque\Source\Servidor\servidor.estoque.fornecedores.pas',
  28.   servidor.sm.estoque           in '..\..\Estoque\Source\Servidor\servidor.sm.estoque.pas';


I am temporarily working around this problem by configuring a .bat file to run BEFORE compiling to CLEAN files in the lib folder. But I need to do this for every project I create. Ideally, this problem should be addressed directly by the compiler.

Thank you for your help.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus doesn't recompile changed units
« Reply #23 on: September 30, 2020, 04:01:39 pm »
Ok, I have not tested how well the (relatively new) namespace support works (the "." in the unit names).
Nor, if having sources in a subfolder may have anything to do with the problem.

One thing you might want to look at:
Menu: Project > "Project inspector"
Does it list all your source files?

If not add them. Use the drop down from the "add" button, and "add files from file system". Then select all the pascal files.
Maybe that helps...

FLLSilva

  • New Member
  • *
  • Posts: 11
Re: Lazarus doesn't recompile changed units
« Reply #24 on: September 30, 2020, 04:32:08 pm »
Ok, I have not tested how well the (relatively new) namespace support works (the "." in the unit names).
Nor, if having sources in a subfolder may have anything to do with the problem.

One thing you might want to look at:
Menu: Project > "Project inspector"
Does it list all your source files?

If not add them. Use the drop down from the "add" button, and "add files from file system". Then select all the pascal files.
Maybe that helps...

Hi Martin_fr.

Yes, the project inspector displays all files correctly, including the folders in which they are located. Look:

https://i.ibb.co/BfDN5Zx/Snap23.jpg"

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Lazarus doesn't recompile changed units
« Reply #25 on: October 01, 2020, 02:35:54 pm »
Also make sure, that your unit name is not used elsewhere. For example, you cannot have a unit called "graphics" because that already exists.
A = No, the units are named following a specific pattern and with names in Portuguese.
Could you rename all your units in a way that portuguese characters are replaced with plain ascii, and all dots in filenames are replaced with minus character? After that test if your behavior is still the same?
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Lazarus doesn't recompile changed units
« Reply #26 on: October 01, 2020, 04:54:40 pm »
@FLLSilva, you should make a Lazarus package out of you library code. Then the package can easily be shared between projects.
I don't know if that would cure this particular problem but it prevents many potential problems when sharing code between projects.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

FLLSilva

  • New Member
  • *
  • Posts: 11
Re: Lazarus doesn't recompile changed units
« Reply #27 on: October 01, 2020, 06:06:07 pm »
Also make sure, that your unit name is not used elsewhere. For example, you cannot have a unit called "graphics" because that already exists.
A = No, the units are named following a specific pattern and with names in Portuguese.
Could you rename all your units in a way that portuguese characters are replaced with plain ascii, and all dots in filenames are replaced with minus character? After that test if your behavior is still the same?

Hi avra.

I did what you recommended (it took a lot of work to rename the files inside and out too).

It hasn't exactly changed anything as you can see from the image below. I simply inserted any text in the source code to force a compilation error. I did the compile and build also of the project, and in both cases the FPC simply ignored the changes to the unit.

I also informed in the image how it was the date and time of the files of the unit that was modified. The .pas file is update but the .ppu and .o files are not, and therefore have not been compiled.
IF I DELETE the lib folder, the unit is compiled and the syntax error message appears normally.

I believe that there must be some problem with the comparison of the units' datetime, at moment of compilation, which is preventing the unit from being detected as modified. Maybe there is a time zone conversion problem in my region? I don't think so, because the compiler should always work with local time.

Even if there was a datetime comparison problem, the build function should force the recompilation of all units, regardless of whether they have been changed or not.

It really is a situation to make anyone crazy.  %)

FLLSilva

  • New Member
  • *
  • Posts: 11
Re: Lazarus doesn't recompile changed units
« Reply #28 on: October 01, 2020, 06:10:55 pm »
@FLLSilva, you should make a Lazarus package out of you library code. Then the package can easily be shared between projects.
I don't know if that would cure this particular problem but it prevents many potential problems when sharing code between projects.

Hello JuhaManninen.

The project does share source code among other projects, like any other object-oriented project.

But the lib folder with the compilation output files (*.ppu, *.o, *.lfm) are independent, each project has its own separate lib folder, they do not share the same folder.

OK? Thank you for your help.

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Lazarus doesn't recompile changed units
« Reply #29 on: October 01, 2020, 06:43:46 pm »
I believe that there must be some problem with the comparison of the units' datetime, at moment of compilation, which is preventing the unit from being detected as modified.

I believe it was time comparison issue. I ever had twice such cases but mine were easily solved, just delete the lib folder and problem solved. I should but I didn't submit bug report because I did not have enough information.

Yep, if I remember correctly in my cases they all used shared library codes, which should be made as packages. I didn't because those codes were frequently changed and improved. Making them packages means I had to do extra steps.
« Last Edit: October 01, 2020, 06:46:08 pm by Handoko »

 

TinyPortal © 2005-2018