Lazarus

Programming => General => Topic started by: Grahame Grieve on September 10, 2020, 02:28:19 am

Title: Lazarus doesn't recompile changed units
Post by: Grahame Grieve on September 10, 2020, 02:28:19 am
So I am porting a rather large project to Lazarus. I'm finding that if I change a unit that has already been compiled, then I need to do a clean and build, otherwise the unit I've changed won't be recompiled.

I can't find any settings related to this...
Title: Re: Lazarus doesn't recompile changed units
Post by: af0815 on September 10, 2020, 06:53:17 am
Is the changed source correct touched with a newer date/time than the old version.

What System is used Windows, Linux or Mac ?

I have this seen only if the sourcefile (and compiled file) have not correct dates, maybe in future by accident.
Title: Re: Lazarus doesn't recompile changed units
Post by: Thaddy on September 10, 2020, 11:02:26 am
-B
With that I mean a rebuilt is usually unavoidable.
Title: Re: Lazarus doesn't recompile changed units
Post by: JuhaManninen on September 10, 2020, 11:07:33 am
The compiler does not notice if an .inc file is changed. With unit files it should work correctly.
Title: Re: Lazarus doesn't recompile changed units
Post by: marcov on September 10, 2020, 11:46:08 am
If you can't reproduce with a small project, compiling the project with -vt might also give some insight. That logs recompilation decisions.
Title: Re: Lazarus doesn't recompile changed units
Post by: Ñuño_Martínez on September 10, 2020, 11:47:27 am
Also, INLINEd procedures/methods doesn't force recompilation of units that use such procedure/method while INTERFACE declaration doesn't change, so behavior doesn't change.
Title: Re: Lazarus doesn't recompile changed units
Post by: Grahame Grieve on September 12, 2020, 02:08:34 am
I'm changing the interface of compiled units, so it's not one of the edge cases. It's happening all the time, not just occasionally or once off.

The .pas file is 6 minutes more recent that the .ppu and .or files for it. It doesn't make any difference whether it's in the project or just on the search path.  It doesn't matter whether the file is open in the IDE or not

No, I can't reproduce this with a small project. It only happens (so far) with my very large project (~320 units in the .lpr, and that's about half what's in the project)
Title: Re: Lazarus doesn't recompile changed units
Post by: Grahame Grieve on September 12, 2020, 02:09:10 am
how do I compile with -vt?
Title: Re: Lazarus doesn't recompile changed units
Post by: furious programming on September 12, 2020, 02:13:29 am
Check this option in the Project Options window (see attachment).
Title: Re: Lazarus doesn't recompile changed units
Post by: Grahame Grieve on September 12, 2020, 03:00:07 am
It didn't make any difference; there's no additional notes in the output
Title: Re: Lazarus doesn't recompile changed units
Post by: jamie on September 12, 2020, 03:17:40 am
have you tried the "Always BUILD even if nothing changes"?

Its in the Project objects under misc.....

Title: Re: Lazarus doesn't recompile changed units
Post by: Grahame Grieve on September 12, 2020, 03:33:56 am
I just did, and still nothing is rebuilt.
Title: Re: Lazarus doesn't recompile changed units
Post by: avra on September 12, 2020, 09:16:27 pm
That is not a normal behavior so you should try Lazarus reinstallation
Title: Re: Lazarus doesn't recompile changed units
Post by: Grahame Grieve on September 15, 2020, 08:56:23 am
ok. I reinstalled. Didn't make any difference. It's just the one very large project that does this; I can't reproduce it with smaller projects
Title: Re: Lazarus doesn't recompile changed units
Post by: Martin_fr on September 15, 2020, 10:15:17 am
- Are all the units in the project? (listed in project inspector?)
- Or if they are in packages, are they listed in that package?

It may not be enough that they are in the relevant folder, they should be in the project/package inspector.

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


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)
Title: Re: Lazarus doesn't recompile changed units
Post by: wp 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.
Title: Re: Lazarus doesn't recompile changed units
Post by: Blaazen 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.)
Title: Re: Lazarus doesn't recompile changed units
Post by: Grahame Grieve 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)
Title: Re: Lazarus doesn't recompile changed units
Post by: FLLSilva 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.
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko 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.
Title: Re: Lazarus doesn't recompile changed units
Post by: Martin_fr 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?



Title: Re: Lazarus doesn't recompile changed units
Post by: FLLSilva 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.
Title: Re: Lazarus doesn't recompile changed units
Post by: FLLSilva 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.
Title: Re: Lazarus doesn't recompile changed units
Post by: Martin_fr 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...
Title: Re: Lazarus doesn't recompile changed units
Post by: FLLSilva 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" (https://i.ibb.co/BfDN5Zx/Snap23.jpg")
Title: Re: Lazarus doesn't recompile changed units
Post by: avra 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?
Title: Re: Lazarus doesn't recompile changed units
Post by: JuhaManninen 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.
Title: Re: Lazarus doesn't recompile changed units
Post by: FLLSilva 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.  %)
Title: Re: Lazarus doesn't recompile changed units
Post by: FLLSilva 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.
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko 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.
Title: Re: Lazarus doesn't recompile changed units
Post by: FLLSilva on October 01, 2020, 07:01:02 pm
Regardless of datetime comparison problems, or code sharing, shouldn't the BUILD function compile all units regardless of whether they have been changed or not? In that case, wouldn't that be considered a bug in the compiler?

I've already set up Lazarus to run a routine to clean the lib folder before each build, I waste a few seconds in this process each time I send it, but I'm more sure that everything is being done correctly.

But I believe that this issue of the project's build should be analyzed by the FPC team to identify what else could be influencing this problem. Today, at least here for me, the build is working exactly like the compile.

Thank you Handoko.
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko on October 01, 2020, 07:13:03 pm
Maybe no one ever reported this issue before you, it happens extremely rare. Without enough information, nothing can be done.

Anyways, thank you for providing the information.
Title: Re: Lazarus doesn't recompile changed units
Post by: JuhaManninen on October 01, 2020, 07:18:11 pm
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.
They are in the .lpr file, but are the paths also in the "Other unit files (-Fu)" settings?
Project options -> Compiler options -> Paths.

This may be out of topic but I highly recommend using Lazarus packages for library code!
A Lazarus package is more advanced than a Delphi package. When you set a dependent package for a project, the package injects its search paths into the project. You don't need to set them anywhere else.
The IDE remembers the location of a package after seeing it once. You don't need to search it from directory structures after that.
I am sorry to say but you have configured your project in a dummy way. :(

Quote from: Handako
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.
What is the extra step?
A unit belonging to a package can be changed as easily as a unit belonging to a project.
Dependent packages of a project, and the project itself, are compiled automatically when they are changed.
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko on October 01, 2020, 07:47:10 pm
For example I had a project SideNote.lpr, it used a unit uniData.pas.

The uniData is a shared library that handle data generation, reading and writing using TDBF. It also used by some of my other projects. Because the uniData.pas was just at its proof-of-concept stage, when developing the SideNote, I needed frequently to modify and add new features for uniData. Lazarus IDE allow us to edit multiple sources easily by opening and showing them as tabs on the Source Editor window.

If I make uniData as a package. When developing SideNote.lpr and I need to edit something on uniData, I have to open the package, edit and compile it. And then reopen SideNote.lpr again to continue developing.

Also, I frequently use undo feature especially when test new idea. But if I open a new project or package, I will lost the undos.

The package concept is great but not very suitable for me. When I write a module I rarely just focus writing it. I usually will choose a real project, so at the same time I am developing the module I also writing a project that using it.
Title: Re: Lazarus doesn't recompile changed units
Post by: Sieben on October 01, 2020, 07:56:56 pm
I'm currently working on a few components that need to be installed in a package to be used. But I don't have to explicitly recompile that package to test new code. As JuhaManninen said it is automatically recompiled with every project recompile. Only when I introduce new published properties I need an explicit rebuild of the IDE of course to have them show up in OI. So I don't see any drawbacks in making your libraries a package. Only that the IDE posts a funny question when first installing a package that has no register procedure...
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko on October 01, 2020, 08:06:08 pm
Really? Then I should try.
Thank you for the information.
Title: Re: Lazarus doesn't recompile changed units
Post by: Sieben on October 01, 2020, 08:28:53 pm
And when I consider this:

Quote from: JuhaManninen
The IDE remembers the location of a package after seeing it once.

it seems it doesn't even have to be installed, just 'packed' and compiled once. And that can be done without even leaving the current project.
Title: Re: Lazarus doesn't recompile changed units
Post by: Blaazen on October 01, 2020, 08:32:19 pm
I am able to reproduce with even a very small project.

How to:
Unzip attached project, open all units in Source Editor (unit1.,pas, unit2.pas and project1.lpr).
Open Console In/Output debug window (Ctrl+Alt+O).

Step 1: Change text in unit1
Code: Pascal  [Select][+][-]
  1.   writeln('Unit1 Click aaaaaaaaa');
  and do not save file!

Step 2: Switch to tab unit2 and change text
Code: Pascal  [Select][+][-]
  1. writeln('create bbbbbb');

Step 3: Do Quick Compile (from menu or by short cut). Note that both files are saved now.

Step 4: Change text again
Code: Pascal  [Select][+][-]
  1. writeln('create bbbbbb ccccc');

Step 5: Run project and click button. The output is:
Code: Pascal  [Select][+][-]
  1. create bbbbbb ccccc
  2. Unit1 Click

 >:( >:( >:( Where is "aaaaaaaaa" added in Step 1?  >:( >:( >:(
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko on October 01, 2020, 08:47:52 pm
@Sieben

Yes, it works. I am changing the way I work now. Thank you.

@Blaazen

I opened the project you provided. Nothing showed in the Project Inspector. I'm using Lazarus 2.0.10 Linux.
Title: Re: Lazarus doesn't recompile changed units
Post by: Blaazen on October 01, 2020, 09:07:04 pm
@ Handoko

Here Project Inspector shows three files and LCL dependency.  IMO zip contains all necessary files.
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko on October 01, 2020, 09:16:41 pm
It is empty on my Object Inspector.

I sometimes have problems opening projects posted on the forum. They're just empty. I believe the problems have something to do with the version difference of the Lazarus we're using.
Title: Re: Lazarus doesn't recompile changed units
Post by: Blaazen on October 01, 2020, 09:37:48 pm
Info for Project Inspector should be in *.lpi file. Anyway, you can test this issue because the steps I described "works" for any project.
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko on October 01, 2020, 09:43:11 pm
Just tested it again. I re-downloaded the zip file, uncompressed it and opened the project1.lpi. Still nothing showed on my Object Inspector.

I'm using Lazarus 2.0.10. The projects files created using my Lazarus have Project Options > Version Value = 11. Simply modifying the value does not work. I remember there was a project info converter posted on the forum not long ago. But I miss it.

This is  your project1.lpi opened using a text editor:

Code: Pascal  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <CONFIG>
  3.   <ProjectOptions>
  4.     <Version Value="12"/>
  5.     <General>
  6.       <SessionStorage Value="InProjectDir"/>
  7.       <Title Value="project1"/>
  8.       <Scaled Value="True"/>
  9.       <ResourceType Value="res"/>
  10.       <UseXPManifest Value="True"/>
  11.       <Icon Value="0"/>
  12.     </General>
  13.     <MacroValues Count="1">
  14.       <Macro1 Name="LCLWidgetType" Value="qt"/>
  15.     </MacroValues>
  16.     <BuildModes>
  17.       <Item Name="Default" Default="True"/>
  18.       <Item Name="Final">
  19.         <CompilerOptions>
  20.           <Version Value="11"/>
  21.           <Target>
  22.             <Filename Value="ecsas"/>
  23.           </Target>
  24.           <SearchPaths>
  25.             <IncludeFiles Value="include;$(ProjOutDir)"/>
  26.             <OtherUnitFiles Value=".;frames;portaudio;xxhash"/>
  27.             <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
  28.           </SearchPaths>
  29.           <Parsing>
  30.             <SyntaxOptions>
  31.               <CStyleOperator Value="False"/>
  32.               <AllowLabel Value="False"/>
  33.             </SyntaxOptions>
  34.           </Parsing>
  35.           <CodeGeneration>
  36.             <SmartLinkUnit Value="True"/>
  37.             <TargetCPU Value="x86_64"/>
  38.             <TargetOS Value="linux"/>
  39.             <Optimizations>
  40.               <OptimizationLevel Value="3"/>
  41.               <VariablesInRegisters Value="True"/>
  42.               <UncertainOptimizations Value="True"/>
  43.             </Optimizations>
  44.           </CodeGeneration>
  45.           <Linking>
  46.             <Debugging>
  47.               <GenerateDebugInfo Value="False"/>
  48.               <DebugInfoType Value="dsStabs"/>
  49.               <StripSymbols Value="True"/>
  50.             </Debugging>
  51.             <LinkSmart Value="True"/>
  52.           </Linking>
  53.           <Other>
  54.             <Verbosity>
  55.               <ShowNotes Value="False"/>
  56.               <ShowHints Value="False"/>
  57.             </Verbosity>
  58.             <CustomOptions Value="-godwarfsets"/>
  59.           </Other>
  60.         </CompilerOptions>
  61.       </Item>
  62.       <SharedMatrixOptions Count="4">
  63.         <Item1 ID="775240689950" Modes="Default" Type="IDEMacro" MacroName="LCLWidgetType" Value="qt"/>
  64.         <Item2 ID="083542331135" Type="IDEMacro" MacroName="LCLWidgetType" Value="gtk2"/>
  65.         <Item3 ID="605968800907" Modes="Default" Value="-dEnableUTF8RTL"/>
  66.         <Item4 ID="236377512695" Type="IDEMacro" MacroName="LCLWidgetType" Value="qt5"/>
  67.       </SharedMatrixOptions>
  68.     </BuildModes>
  69.     <PublishOptions>
  70.       <Version Value="2"/>
  71.       <UseFileFilters Value="True"/>
  72.     </PublishOptions>
  73.     <RunParams>
  74.       <FormatVersion Value="2"/>
  75.     </RunParams>
  76.     <RequiredPackages>
  77.       <Item>
  78.         <PackageName Value="LCL"/>
  79.       </Item>
  80.     </RequiredPackages>
  81.     <Units>
  82.       <Unit>
  83.         <Filename Value="project1.lpr"/>
  84.         <IsPartOfProject Value="True"/>
  85.       </Unit>
  86.       <Unit>
  87.         <Filename Value="unit1.pas"/>
  88.         <IsPartOfProject Value="True"/>
  89.         <ComponentName Value="Form1"/>
  90.         <ResourceBaseClass Value="Form"/>
  91.         <UnitName Value="Unit1"/>
  92.       </Unit>
  93.       <Unit>
  94.         <Filename Value="unit2.pas"/>
  95.         <IsPartOfProject Value="True"/>
  96.         <UnitName Value="Unit2"/>
  97.       </Unit>
  98.     </Units>
  99.   </ProjectOptions>
  100.   <CompilerOptions>
  101.     <Version Value="11"/>
  102.     <SearchPaths>
  103.       <IncludeFiles Value="$(ProjOutDir)"/>
  104.       <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
  105.     </SearchPaths>
  106.     <Parsing>
  107.       <SyntaxOptions>
  108.         <CStyleOperator Value="False"/>
  109.         <AllowLabel Value="False"/>
  110.       </SyntaxOptions>
  111.     </Parsing>
  112.     <CodeGeneration>
  113.       <Checks>
  114.         <IOChecks Value="True"/>
  115.         <RangeChecks Value="True"/>
  116.         <OverflowChecks Value="True"/>
  117.       </Checks>
  118.       <VerifyObjMethodCallValidity Value="True"/>
  119.       <Optimizations>
  120.         <OptimizationLevel Value="0"/>
  121.       </Optimizations>
  122.     </CodeGeneration>
  123.     <Linking>
  124.       <Debugging>
  125.         <DebugInfoType Value="dsDwarf2"/>
  126.         <UseHeaptrc Value="True"/>
  127.         <TrashVariables Value="True"/>
  128.       </Debugging>
  129.     </Linking>
  130.     <Other>
  131.       <Verbosity>
  132.         <ShowNotes Value="False"/>
  133.       </Verbosity>
  134.       <CustomOptions Value="-godwarfsets
  135. -dDBGGRID
  136. -dDEBUG
  137. -dDBGAPP
  138. -dDBGCALC
  139. -dDBGCORE
  140. -dDBGPRJ"/>
  141.     </Other>
  142.   </CompilerOptions>
  143.   <Debugging>
  144.     <Exceptions>
  145.       <Item>
  146.         <Name Value="EAbort"/>
  147.       </Item>
  148.       <Item>
  149.         <Name Value="ECodetoolError"/>
  150.       </Item>
  151.       <Item>
  152.         <Name Value="EFOpenError"/>
  153.       </Item>
  154.     </Exceptions>
  155.   </Debugging>
  156. </CONFIG>
Title: Re: Lazarus doesn't recompile changed units
Post by: Blaazen on October 01, 2020, 09:53:08 pm
I don't know what's wrong. Try to create a new prj with just one button and copy the code there. It should work.
Title: Re: Lazarus doesn't recompile changed units
Post by: JuhaManninen on October 01, 2020, 10:13:17 pm
I sometimes have problems opening projects posted on the forum. They're just empty. I believe the problems have something to do with the version difference of the Lazarus we're using.
Yes, exactly. The unit file list in project info .lpi file now uses an XML tag syntax without numbers. Like :
Code: [Select]
<Unit>
...
</Unit>
Earlier it was something like :
Code: [Select]
<Unit1>
...
</Unit1>
which caused big diffs when files were added or deleted, and thus the numbers shifted.
Projects uploaded here should use the option "Maximize compatibility of project files (LPI and LPS)" in Miscellaneous page. Then the project is saved using the old XML syntax.
Title: Re: Lazarus doesn't recompile changed units
Post by: wp on October 01, 2020, 10:21:34 pm
I sometimes have problems opening projects posted on the forum. They're just empty. I believe the problems have something to do with the version difference of the Lazarus we're using.
If you don't have Laz trunk (where you should check the "maximize compatibility" box in the project options, as Juha described already) you should should use my tool "fixlp" (https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/applications/fixlp/) which converts the old to the new xml structure.
Title: Re: Lazarus doesn't recompile changed units
Post by: JuhaManninen on October 01, 2020, 10:23:50 pm
If I make uniData as a package. When developing SideNote.lpr and I need to edit something on uniData, I have to open the package, edit and compile it. And then reopen SideNote.lpr again to continue developing.
That makes no sense at all. You can have many package editors open while working with any project. You can open any unit file from those packages in editor and modify it together with project files.
Are we talking about Lazarus IDE? There is some fundamental misunderstanding now.

Quote
Also, I frequently use undo feature especially when test new idea. But if I open a new project or package, I will lost the undos.
Why would you open a new project?

Quote
The package concept is great but not very suitable for me. When I write a module I rarely just focus writing it. I usually will choose a real project, so at the same time I am developing the module I also writing a project that using it.
Yes, that is what all people do. (All programmers anyway ...)
Title: Re: Lazarus doesn't recompile changed units
Post by: Sieben on October 01, 2020, 10:45:36 pm
Yes, it works. I am changing the way I work now. Thank you.

 ;)
Title: Re: Lazarus doesn't recompile changed units
Post by: Blaazen on October 01, 2020, 10:47:30 pm
So I added the zip again, the project was saved with the max. compatibility option. Steps are the same.
Title: Re: Lazarus doesn't recompile changed units
Post by: Martin_fr on October 01, 2020, 11:02:10 pm
If I make uniData as a package. When developing SideNote.lpr and I need to edit something on uniData, I have to open the package, edit and compile it. And then reopen SideNote.lpr again to continue developing.

If you open and edit the file (even if you do not open the package), then Lazarus will still recompile the file (and all packages that depend on it).

That is, unless the "files not recompiled issue" stretches into that area too.
If that issue does affect packages, then its harder to fix, as the ppu will be in the package dir....

If you want to change debug info, or other compile options for the package => you can do that from the project, via "additions and overrides". And that will work for build-modes too.


However: Using packages or not: The other problem at hand should in either case not happen....
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko on October 02, 2020, 04:18:23 am
So I added the zip again, the project was saved with the max. compatibility option. Steps are the same.

I just downloaded and tested the recompiling2.zip. The project file can be corrected opened but I got a compile time error:
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko on October 02, 2020, 04:40:04 am
I tested the fixlp, yes it works. I now can open Blaazen's recompiling.zip. Thank you for writing the tool.

Unfortunately both recompiling and recompiling2 can't be compiled on my Lazarus 2.0.10 Linux 64-bit computer. I got a compile time error. See my previous post https://forum.lazarus.freepascal.org/index.php/topic,51388.msg379395.html#msg379395 (https://forum.lazarus.freepascal.org/index.php/topic,51388.msg379395.html#msg379395)

@JuhaManninen

The codes of my shared libraries are in its own folder. I didn't make multiple copies to other projects and I managed them well. So, the way I work without using packages works for me without any issue so far, so I didn't try or even think to change it. Using package seems good, I am going to use it from now on. The problem we're currently talking here may or maybe not caused by using shared library without using package.
Title: Re: Lazarus doesn't recompile changed units
Post by: Grahame Grieve on October 02, 2020, 09:08:18 am
Back to my original report... this is solid and reproducible for me, but only on one big project. Other projects behave as expected.. I still have no idea why
Title: Re: Lazarus doesn't recompile changed units
Post by: Handoko on October 02, 2020, 09:14:15 am
Have to tried what Blaazen said? Can you re-procedure the issue using his steps?
https://forum.lazarus.freepascal.org/index.php/topic,51388.msg379363.html#msg379363
Title: Re: Lazarus doesn't recompile changed units
Post by: egsuh on October 02, 2020, 02:28:38 pm
I had similar experience. My cause was that I forgot changing names of some units, when I was upgrading continuously. For example, I used to use myunit3, and after a while, I created new myunit4 and modified some of the content within it.  Then I should change all the references in other units of the project, but I miss some of them. Or files of same name may coexist in different folders of search paths. In that case, the file you are changing may not reflected in the actual project.
Title: Re: Lazarus doesn't recompile changed units
Post by: Blaazen on October 02, 2020, 06:05:12 pm
Did someone reproduce the issue? It should be reported, IMO.

EDIT: Bugreport: https://bugs.freepascal.org/view.php?id=37856 (https://bugs.freepascal.org/view.php?id=37856)
TinyPortal © 2005-2018