Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need to recompile a VCL source file

647 views
Skip to first unread message

Tony Mountifield

unread,
Mar 4, 2009, 5:57:23 PM3/4/09
to
In order to fix a small bug in Delphi 6, I need to recompile one of the
VCL source files (AxCtrls.pas) after making a small change to it.

I found the following information on Experts Exchange:

+---
|- Add the source unit to your project by pressing shift+F11 or
| clicking Add to project in Project menu.
|- Click Project-Options-Directory/conditional
|- In Unit Output directory select c:\Program Files\Borland\Delphi6\lib
|
|Compile it and it will produce .dcu file in lib path.
+---

So what I did was:

1. In C:\Program Files\Borland\Delphi6\Source\VCL\, copied AxCtrls.pas
to AxCtrls.pas.original, and then made the change to AxCtrls.pas

2. In C:\Program Files\Borland\Delphi6\Lib\, copied AxCtrls.dcu to
AxCtrls.dcu.original

3. File/New/Application

4. Removed Unit1.pas from the project (project is now empty).

5. Saved the project in My Documents\Delphi\DaxFix\DaxFix.dpr

6. Added C:\Program Files\Borland\Delphi6\Source\VCL\AxCtrls.pas to my
project.

7. Set the Unit Output directory to C:\Program Files\Borland\Delphi6\Lib

8. Did "Build Project".

9. Examined C:\Program Files\Borland\Delphi6\Lib and found the updated
.dcu file. Not yet tried building a project with it.

However, since this will be used in a critical production application,
I want to be sure I haven't missed anything out, and am thinking
particularly of the compiler options:

Please could anyone tell me exactly which compiler options should be
enabled and disabled, (a) for compiling a normal DCU to ...\Lib\, and
(b) for compiling a debug DCU to ...\Lib\Debug\

And anything else that might be wrong with the above procedure?

Thanks for any help!

Cheers
Tony
--
Tony Mountifield
Work: to...@softins.co.uk - http://www.softins.co.uk
Play: to...@mountifield.org - http://tony.mountifield.org

Rob Kennedy

unread,
Mar 4, 2009, 6:39:19 PM3/4/09
to
Tony Mountifield wrote:
> In order to fix a small bug in Delphi 6, I need to recompile one of the
> VCL source files (AxCtrls.pas) after making a small change to it.
>
> I found the following information on Experts Exchange:
>
> +---
> |- Add the source unit to your project by pressing shift+F11 or
> | clicking Add to project in Project menu.
> |- Click Project-Options-Directory/conditional
> |- In Unit Output directory select c:\Program Files\Borland\Delphi6\lib

Oh dear. I *really* don't recommend that. Always leave the
Borland-provided DCU files untouched.

> |Compile it and it will produce .dcu file in lib path.
> +---
>
> So what I did was:
>
> 1. In C:\Program Files\Borland\Delphi6\Source\VCL\, copied AxCtrls.pas
> to AxCtrls.pas.original, and then made the change to AxCtrls.pas
>
> 2. In C:\Program Files\Borland\Delphi6\Lib\, copied AxCtrls.dcu to
> AxCtrls.dcu.original

Good. I recommend you put it back to the original. Same for the source code.

Copy the unit you wish to change into your project directory and then
use it as though it were just another unit of your project, including
storing the DCU with the DCUs of the rest of your units.

> 3. File/New/Application
>
> 4. Removed Unit1.pas from the project (project is now empty).
>
> 5. Saved the project in My Documents\Delphi\DaxFix\DaxFix.dpr
>
> 6. Added C:\Program Files\Borland\Delphi6\Source\VCL\AxCtrls.pas to my
> project.
>
> 7. Set the Unit Output directory to C:\Program Files\Borland\Delphi6\Lib
>
> 8. Did "Build Project".
>
> 9. Examined C:\Program Files\Borland\Delphi6\Lib and found the updated
> .dcu file. Not yet tried building a project with it.
>
> However, since this will be used in a critical production application,
> I want to be sure I haven't missed anything out, and am thinking
> particularly of the compiler options:

What you've missed is that anything else that uses AxCtrls will need to
be recompiled as well. That's the dange when you start messing with the
provided VCL and RTL units. You'll compiler errors about "Unix X was
compiled with a different version of Y.Z," where X and Y are units and Z
is a type.

> Please could anyone tell me exactly which compiler options should be
> enabled and disabled, (a) for compiling a normal DCU to ...\Lib\, and
> (b) for compiling a debug DCU to ...\Lib\Debug\

The source file already has a handful of compiler settings listed. The
others that could affect compatibility with other code are the following:

$A for alignment of fields in records (irrelevant since the unit
declares no record types)

$B for short-circuit Boolean evaluation (should always be off anyway)

$M for presence of run-time type information on classes that don't
descend from TPersistent. (irrelevant since it declares no published
properties that aren't in descendants of TPersistent)

--
Rob

alang...@aol.com

unread,
Mar 5, 2009, 1:58:05 AM3/5/09
to
I'm not sure if it is still relevant to the latest versions, but
Delphi Magazine for May 2002 (Issue 81 - in "Tightening the Strings")
had the following notes on recompiling a system unit (System.pas in
that case).

1 Recompile with ...

"...\Delphi6\bin\dcc32 system.pas -m -y -$D+

The -y option is a 'magic' undocumented option to get the compiler to
compile a system unit"

2 "make sure you don't change anything in the interface section, as
this would make all other compiled .dcu files incompatible."

Much better to call your changed system code a different name and put
that in your using units.

Alan Lloyd

Maarten Wiltink

unread,
Mar 5, 2009, 3:14:10 AM3/5/09
to
"Rob Kennedy" <m...@privacy.net> wrote in message
news:718hp9F...@mid.individual.net...
[...]

> $B for short-circuit Boolean evaluation (should always be off anyway)

Just to be sure: $B+ specifies _complete_ Boolean evaluation, and
should be off unless you know what you're doing, right?

Groetjes,
Maarten Wiltink

Hans-Peter Diettrich

unread,
Mar 5, 2009, 3:52:54 AM3/5/09
to
Tony Mountifield schrieb:

> And anything else that might be wrong with the above procedure?

You'll have to rebuild most of the standard packages as well, in case
they are used by some project or by the IDE. I never updated the Delphi
libraries myself, just to prevent such complications. Dunno what will
happen to the IDE itself (component palette...), when you have to
re-install the updated packages.

Aren't there Makefiles in the Delphi source directory, for rebuilding
the libraries?

DoDi

Rob Kennedy

unread,
Mar 5, 2009, 8:40:10 AM3/5/09
to

Yes.

--
Rob

Tony Mountifield

unread,
Mar 7, 2009, 4:42:39 PM3/7/09
to
In article <gon10j$8bu$1...@softins.clara.co.uk>,

Tony Mountifield <to...@softins.clara.co.uk> wrote:
> In order to fix a small bug in Delphi 6, I need to recompile one of the
> VCL source files (AxCtrls.pas) after making a small change to it.

Thanks to all for the various replies!

Tony Mountifield

unread,
Mar 15, 2009, 1:50:47 PM3/15/09
to
In article <24bff74f-ca75-4620...@r28g2000vbp.googlegroups.com>,

Well, after quite a bit of experientation, I discovered a few things:

1. The options given above only apply to RTL modules, or perhaps even
only to system.pas, but definitely not to VCL modules.

2. I copied an original VCL source module, AxCtrls.pas, to an empty
directory, and could reproduce a DCU with an identical size to the supplied
one in the Delphi6/Lib directory, and only a few bytes different near the
beginning of the DCU (presumably a compilation timestamp). I used this:

dcc32 -q AxCtrls -$D- -$L-

So this gives me confidence I have found the correct options for compiling
a non-debug VCL DCU.

3. I have not yet been able to find the correct compilation options to
reproduce a debug DCU with the same size as in the Delphi6/Lib/Debug
directory.

dcc32 -q AxCtrls -$D+ -$L+

doesn't make the file quite large enough, and I have also tried various
combinations of -$M+, -$O-, -$Q+, -$R+ and -$W+, but have not succeeded
in hitting the exact size.

Does anyone here know for certain what compiler options were used when
compiling the original Debug DCUs?

0 new messages