Recent

Author Topic: [SOLVED] Recompiling Units because of Generic/ Include/ Inline changes  (Read 550 times)

Okoba

  • Hero Member
  • *****
  • Posts: 528
Hello,

I have multiple generic types, and they are used in many units.
The problem is, if I change my generic type (Like TGenericList), I need to force recompile all dependant units, so all packages and open project need to be explicitly cleaned and recompiled.
This issue is similar to include files, and changing inline functions too, other dependant units to those include files or inline functions need to be recompiled.

This problem beside the time wasting, made me fall into many pseudo bugs, that I think something is wrong, but there is only a need to clean and recompile all units.

Is there a way to prevent this?
« Last Edit: January 07, 2023, 12:42:05 pm by Okoba »

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Recompiling Units because of Generic/ Include/ Inline changes
« Reply #1 on: January 07, 2023, 11:56:31 am »
You can compile units that you don't want to be changed with -Ur. such units are never automatically recompiled. But the compiler may complain if it really needs such units to be compiled again. That is only the case if you are sure that there is no dependency on your modified code at all.
But all packages and units that are really not dependent on your altered code can be compiled with -Ur. -Ur stands for release build. E.g. the rtl is by default compiled like that.
In fact, after debugging, this is a good idea for any package.

You could also try -B-, which turns full rebuild off for your project. The latter is only necessary if -B is specified either on the command line or in Lazarus compiler settings. Then again, you also specified -Sew, maybe without knowing, so that may be likely be the case. But even if -B is specified, code that is compiled with -Ur will not be part of the rebuild.
« Last Edit: January 07, 2023, 12:12:04 pm by Thaddy »
Specialize a type, not a var.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Recompiling Units because of Generic/ Include/ Inline changes
« Reply #2 on: January 07, 2023, 12:15:55 pm »
Thaddy, I think you misread my post. I want Lazarus to recompile all dependant units, not prevent it. For now, Lazarus does not recompile units if the generic unit changes, so they still use an old generic.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Recompiling Units because of Generic/ Include/ Inline changes
« Reply #3 on: January 07, 2023, 12:21:14 pm »
Thaddy, I think you misread my post. I want Lazarus to recompile all dependant units, not prevent it. For now, Lazarus does not recompile units if the generic unit changes, so they still use an old generic.
Then make sure -B is specified and the affected units and packages are NOT marked as release build, so -Ur-. So the reverse from my first answer. :D
I interpreted your question that those units / packages should NOT be rebuild, in that case there is no possibility to skip rebuilding, since now you tell me they ARE dependent on the changed code....
And that is absolutely not clear in your question.
You could have found that out yourself. Well, you did, but found it cumbersome?
Stick to the rules.... O:-) 8-) If code is dependent on your changes, that code MUST be rebuild.
« Last Edit: January 07, 2023, 12:28:09 pm by Thaddy »
Specialize a type, not a var.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Recompiling Units because of Generic/ Include/ Inline changes
« Reply #4 on: January 07, 2023, 12:26:56 pm »
-B works! Thanks.
But what -B means? In Lazarus it says "Build all modules", but what does it mean? Will it build dependant units of what changed? all packages?

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Recompiling Units because of Generic/ Include/ Inline changes
« Reply #5 on: January 07, 2023, 12:28:46 pm »
-B works! Thanks.
But what -B means? In Lazarus it says "Build all modules", but what does it mean? Will it build dependant units of what changed? all packages?
It means "do a full rebuild" BUT compiled code that is compiled with -Ur is excluded from -B. (e.g. the rtl)
So, -B really means build all modules except when they are release builds marked with -Ur.
I thought my answers were clear enough.
« Last Edit: January 07, 2023, 12:33:55 pm by Thaddy »
Specialize a type, not a var.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Recompiling Units because of Generic/ Include/ Inline changes
« Reply #6 on: January 07, 2023, 12:33:04 pm »
Do a full build of what? Changed units? So other dependant units force to rebuild too?
AS I checked and other independent packages are not rebuilt. So somehow, it compiles my changed unit and dependant ones. That solves my issue, but I like to know how it works and what does it mean by "Build all modules", what modules?

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Recompiling Units because of Generic/ Include/ Inline changes
« Reply #7 on: January 07, 2023, 12:39:48 pm »
Any code that is not dependent on your code should not be dependent on a recomple.
Any code that HAS a dependency should be rebuild if it uses your code. Hence -B. The ONLY way to exclude code that has NO dependencies on Your changed code, direct or indirect, MUST be compiled with -Ur to prevent -B from recompiling them.

Personally I would simply compile with -B and won't go through the hassle of release builds, except for code I did not write or changed myself. A dependency is a dependency.... take it or leave it.
« Last Edit: January 07, 2023, 12:45:23 pm by Thaddy »
Specialize a type, not a var.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: [SOLVED] Recompiling Units because of Generic/ Include/ Inline changes
« Reply #8 on: January 07, 2023, 12:42:22 pm »
Thank you Thaddy. Very helpful.

 

TinyPortal © 2005-2018