Sign in Join

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

Mailing lists / lazarus / 2017-11

Compiling/linking/debugging package with generics

17 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Donald Ziesig

Hi All!

I have been having a problem for a long, long time when developing/debugging code which is included in a *package* and which contains *generics*.

It took me years :'(, but I finally figured out what I was doing so that I could cause the issue to appear consistently. :-[

My usual debugging process is:

1. Edit the library code
2. Compile/Run
3. Debug.

My current insight is:

What would happen was that changes made to the library code would compile, but not be included in the code which specializes the generic item.  When I entered the debugger, I could see the newly changed code, but single-stepping *ignored* my changes.  If I let the program run without debugging, the resulting behavior was the *same as it was before the edit*.

I have a work around for this (when I remember to use it):

1. Edit the library code
2. Compile the package
3. Use *Run | **Cleanup and build ...*
4. Debug

TL;DR   Library packages which declare generics do compile, but do not get included in the code that specializes them unless I "Cleanup and build" the whole program.  (Workable, but much *slower* than programs without generics).

I searched the bug tracker, but did not see anything resembling this problem.  I would submit a bug report but I'm not sure whether this is an IDE problem, a package problem or a compiler/linker problem.  Would someone more familiar with this part of the architecture give me pointers?

Thanks,

Don Ziesig

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171127/5a2a7e72/attachment.html>

Reply by email

Mattias Gaertner
to Donald Ziesig
Show quoted text 10 lines
[...] TL;DR   Library packages which declare generics do compile, but do not get included in the code that specializes them unless I "Cleanup and build" the whole program.  (Workable, but much *slower* than programs without generics). I searched the bug tracker, but did not see anything resembling this problem.  I would submit a bug report but I'm not sure whether this is an IDE problem, a package problem or a compiler/linker problem.  Would someone more familiar with this part of the architecture give me pointers?

When you change a pas file of your package and you compile your project, does the IDE automatically compile your package?

Mattias

Reply by email

Donald Ziesig
to Mattias Gaertner
Mattias Gaertner wrote 15 lines
On Mon, 27 Nov 2017 13:15:36 -0500 Donald Ziesig via Lazarus wrote: > [...] > TL;DR   Library packages which declare generics do compile, but do not > get included in the code that specializes them unless I "Cleanup and > build" the whole program.  (Workable, but much *slower* than programs > without generics). > > I searched the bug tracker, but did not see anything resembling this > problem.  I would submit a bug report but I'm not sure whether this is > an IDE problem, a package problem or a compiler/linker problem.  Would > someone more familiar with this part of the architecture give me pointers? When you change a pas file of your package and you compile your project, does the IDE automatically compile your package?

Yes (at least it catches typos).  Also, the same problem occurs when I compile the package manually, then run the program without using "cleanup and build".  (I am gradually discovering the extent of the problem ;-)).

Mattias

Reply by email

Mattias Gaertner
to Donald Ziesig
Show quoted text 7 lines
[...] > When you change a pas file of your package and you compile your project, > does the IDE automatically compile your package? Yes (at least it catches typos).  Also, the same problem occurs when I compile the package manually, then run the program without using "cleanup and build".  (I am gradually discovering the extent of the problem ;-)).

Are your 'Other unit files (-Fu)' paths in project inspector and your package empty?

Mattias

Reply by email

Donald Ziesig
to Mattias Gaertner
Mattias Gaertner wrote 12 lines
On Mon, 27 Nov 2017 13:33:13 -0500 Donald Ziesig via Lazarus wrote: > [...] >> When you change a pas file of your package and you compile your project, >> does the IDE automatically compile your package? > Yes (at least it catches typos).  Also, the same problem occurs when I > compile the package manually, then run the program without using > "cleanup and build".  (I am gradually discovering the extent of the > problem ;-)). Are your 'Other unit files (-Fu)' paths in project inspector and your package empty?

Yes, both are empty.

Mattias

Reply by email

Mattias Gaertner
to Donald Ziesig
[...] > Are your 'Other unit files (-Fu)' paths in project inspector and > your package empty? Yes, both are empty.

Good.
If your project and packages have their own directories, it seems you found a compiler bug.
Can you reproduce it in a small example?

Mattias

Reply by email

Donald Ziesig
to Mattias Gaertner
Mattias Gaertner wrote 11 lines
On Mon, 27 Nov 2017 15:52:09 -0500 Donald Ziesig via Lazarus wrote: > [...] >> Are your 'Other unit files (-Fu)' paths in project inspector and >> your package empty? > Yes, both are empty. Good. If your project and packages have their own directories, it seems you found a compiler bug. Can you reproduce it in a small example?

Will do.

Mattias

Reply by email

Marcos Douglas B. Santos
to Mattias Gaertner: On Mon, 27 Nov 2017 13:33:13 -0500 Are your 'Other unit files (-Fu)' paths in project…
Mattias Gaertner wrote 13 lines
On Mon, 27 Nov 2017 13:33:13 -0500 Donald Ziesig via Lazarus wrote: >[...] > > When you change a pas file of your package and you compile your project, > > does the IDE automatically compile your package? > Yes (at least it catches typos). Also, the same problem occurs when I > compile the package manually, then run the program without using > "cleanup and build". (I am gradually discovering the extent of the > problem ;-)). Are your 'Other unit files (-Fu)' paths in project inspector and your package empty?

And is this correct, package empty?

Best regards,
Marcos Douglas

Reply by email

Mattias Gaertner
to Marcos Douglas B. Santos

On Tue, 28 Nov 2017 08:41:05 -0200
"Marcos Douglas B. Santos via Lazarus"

Show quoted text 5 lines
[...] > Are your 'Other unit files (-Fu)' paths in project inspector and > your package empty? And is this correct, package empty?

It is normal.

Mattias

Reply by email

Marcos Douglas B. Santos
to Mattias Gaertner
Mattias Gaertner wrote 11 lines
On Tue, 28 Nov 2017 08:41:05 -0200 "Marcos Douglas B. Santos via Lazarus" wrote: >[...] > > Are your 'Other unit files (-Fu)' paths in project inspector and > > your package empty? > > And is this correct, package empty? It is normal.

Ok... but is there some "advantages" adding files in the package? If there is not, why do we have this option?

Thanks,

Best regards,
Marcos Douglas

Reply by email

Mattias Gaertner
to Marcos Douglas B. Santos

On Tue, 28 Nov 2017 09:01:56 -0200
"Marcos Douglas B. Santos via Lazarus"

Show quoted text 16 lines
On Tue, Nov 28, 2017 at 8:50 AM, Mattias Gaertner via Lazarus wrote: > On Tue, 28 Nov 2017 08:41:05 -0200 > "Marcos Douglas B. Santos via Lazarus" > wrote: > >>[...] >> > Are your 'Other unit files (-Fu)' paths in project inspector and >> > your package empty? >> >> And is this correct, package empty? > > It is normal. Ok... but is there some "advantages" adding files in the package? If there is not, why do we have this option?

The 'Other unit files (-Fu)' paths are usually empty. It is not empty if a package has multiple source directories.

You should add all source files to the package.

Mattias

Reply by email

R0b0t1
to Donald Ziesig: Hi All! I have been having a problem for a long, long time when developing/debugging code…

Hello,

Donald Ziesig wrote 38 lines
Hi All! I have been having a problem for a long, long time when developing/debugging code which is included in a package and which contains generics. It took me years :'(, but I finally figured out what I was doing so that I could cause the issue to appear consistently. :-[ My usual debugging process is: Edit the library code Compile/Run Debug. My current insight is: What would happen was that changes made to the library code would compile, but not be included in the code which specializes the generic item. When I entered the debugger, I could see the newly changed code, but single-stepping ignored my changes. If I let the program run without debugging, the resulting behavior was the same as it was before the edit. I have a work around for this (when I remember to use it): Edit the library code Compile the package Use Run | Cleanup and build ... Debug TL;DR Library packages which declare generics do compile, but do not get included in the code that specializes them unless I "Cleanup and build" the whole program. (Workable, but much slower than programs without generics). I searched the bug tracker, but did not see anything resembling this problem. I would submit a bug report but I'm not sure whether this is an IDE problem, a package problem or a compiler/linker problem. Would someone more familiar with this part of the architecture give me pointers?

I think this may be a bug, but I do not think it has to do with generics or packages. I encountered a very similar issue with a project I help maintain, where I fixed some issue in a unit but that unit was not automatically recompiled after being changed. I had to clean and rebuild the project. As you say, this is not extremely expedient.

My apologies for not keeping more details, but I was quite happy to have gotten it working at the time.

Cheers,
R0b0t1

Reply by email

R0b0t1
to R0b0t1

Apologies for the additional post:

R0b0t1 wrote 50 lines
Hello, On Mon, Nov 27, 2017 at 12:15 PM, Donald Ziesig via Lazarus wrote: > Hi All! > > I have been having a problem for a long, long time when developing/debugging > code which is included in a package and which contains generics. > > It took me years :'(, but I finally figured out what I was doing so that I > could cause the issue to appear consistently. :-[ > > My usual debugging process is: > > Edit the library code > Compile/Run > Debug. > > My current insight is: > > What would happen was that changes made to the library code would compile, > but not be included in the code which specializes the generic item. When I > entered the debugger, I could see the newly changed code, but > single-stepping ignored my changes. If I let the program run without > debugging, the resulting behavior was the same as it was before the edit. > > I have a work around for this (when I remember to use it): > > Edit the library code > Compile the package > Use Run | Cleanup and build ... > Debug > > TL;DR Library packages which declare generics do compile, but do not get > included in the code that specializes them unless I "Cleanup and build" the > whole program. (Workable, but much slower than programs without generics). > > I searched the bug tracker, but did not see anything resembling this > problem. I would submit a bug report but I'm not sure whether this is an > IDE problem, a package problem or a compiler/linker problem. Would someone > more familiar with this part of the architecture give me pointers? > I think this may be a bug, but I do not think it has to do with generics or packages. I encountered a very similar issue with a project I help maintain, where I fixed some issue in a unit but that unit was not automatically recompiled after being changed. I had to clean and rebuild the project. As you say, this is not extremely expedient.

To be clear, for some reason most of the time the unit (and every other unit) was rebuilding properly, but one time it didn't. Perhaps it is a linking issue?

Cheers,
R0b0t1

Reply by email

Mattias Gaertner
to R0b0t1
[...] To be clear, for some reason most of the time the unit (and every other unit) was rebuilding properly, but one time it didn't. Perhaps it is a linking issue?

If you cannot reproduce it then your issue is not related to this thread.

Mattias

Reply by email

Donald Ziesig
to Mattias Gaertner: On Tue, 28 Nov 2017 08:41:05 -0200 "Marcos Douglas B. Santos via Lazarus" It is normal.…
Mattias Gaertner wrote 11 lines
On Tue, 28 Nov 2017 08:41:05 -0200 "Marcos Douglas B. Santos via Lazarus" wrote: > [...] >> Are your 'Other unit files (-Fu)' paths in project inspector and >> your package empty? > And is this correct, package empty? It is normal. Mattias

I posted a bug-tracker entry (twice, the first one was rejected due tothe size of the demo).  Issue 32739 is the correct one

Don

Reply by email

R0b0t1
to Mattias Gaertner: On Tue, 28 Nov 2017 10:46:01 -0600 If you cannot reproduce it then your issue is not…

Hello,

On Tuesday, November 28, 2017, Mattias Gaertner via Lazarus <

Show quoted text 12 lines
wrote: On Tue, 28 Nov 2017 10:46:01 -0600 R0b0t1 via Lazarus wrote: >[...] > To be clear, for some reason most of the time the unit (and every > other unit) was rebuilding properly, but one time it didn't. Perhaps > it is a linking issue? If you cannot reproduce it then your issue is not related to this thread.

Seeing as the OP took years to reproduce his issue, I may not have that informatuon for a long time. I realize what I experienced may not be precisely relevant but it seemed close enough that I felt I shouldn't remain silent.

Cheers,
R0b0t1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171128/372ac6a9/attachment.html>

Reply by email

R0b0t1
to R0b0t1

Sorry list, I'm trying to stop my double posting.

R0b0t1 wrote 17 lines
Hello, On Tuesday, November 28, 2017, Mattias Gaertner via Lazarus < wrote: > On Tue, 28 Nov 2017 10:46:01 -0600 > R0b0t1 via Lazarus wrote: > >>[...] >> To be clear, for some reason most of the time the unit (and every >> other unit) was rebuilding properly, but one time it didn't. Perhaps >> it is a linking issue? > > If you cannot reproduce it then your issue is not related to this > thread. > Seeing as the OP took years to reproduce his issue, I may not have that

informatuon for a long time. I realize what I experienced may not be precisely relevant but it seemed close enough that I felt I shouldn't remain silent.

It looks like I came across https://bugs.freepascal.org/view.php?id=25797, this issue but with inline functions.

R0b0t1.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171128/030c0bd9/attachment.html>

Reply by email