views:

360

answers:

3

I'm working on migrating an old project from Delphi 2007 to Delphi 2010. One thing I've found is that the resulting executable has more than doubled in size, and the original was already quite big. (Over 50 MB.) I suspect that a lot of it has to do with extended RTTI.

Since the project predates Delphi 2010, it doesn't use extended RTTI anywhere, and I'd like to be conservative about including it. Is there any way to use the Project Options dialog to globally set {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} as the default? I'd have expected there to be an option for this (and for $WEAKLINKRTTI) somewhere, but I don't see them.

Does anyone know if this can be done from the "Additional options to pass to the compiler" field, or some other way? I'd really prefer not to have to add an include file to every single unit in the project, as there are a few thousand of them...

+2  A: 

You can try with the dcc32 –$weaklinkrtti command-line option. (like {$WEAKLINKRTTI ON}).
But that has not the impact of {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} in each unit.
Your best bet would be to have it at the top of each unit in an include file.
But then it wouldn't do it for the VCL/RTL which would still be inflated....

Update: Also make sure you compare what's comparable. For instance verify if you don't include debug information in the Linker Options in the new D2010 project where you may not have it in the D2007 one...

François
I tried putting `-weaklinkrtti` in the "Additional options to pass to the compiler" field in Project Options, but it just gave a compiler warning: [DCC Warning] W1030 Invalid compiler directive: '–weaklinkrtti'.
Mason Wheeler
Sorry Mason, you have to include the $ in the project options. My bad. Edited answer.
François
A: 

I don't know of such an option, but I still would use an include file.

I wont be a problem for any experienced Delphi programmer to write a small program to add an {$i ProjectIncludeFile.inc} to any unit in your folders (immediatly after the unit line).

And that way you can use it for whatever purpose you like.

I myself use if f.i. to set a WriteTempFiles compiler directive (which I use f.i. to save stringlist contents at various places when developing the program), that way I can disable it in one place when the program is ready for deployment.

Since most of my projects involve multiple executables and/or dll's, this is the easiest way to accomplish this globaly for the whole project.

Edelcom
+1  A: 

Are you certain this is caused by the new RTTI info? While it's a lot of data it shouldn't really double the size of your application.

Check that it's not including debug info in the release build executable. (Project options -> Delphi Compiler -> Debug information should be False)

As for the question, I use {$WEAKLINKRTTI ON} before the uses clause in the dpr file and it seems to work fine.

PetriW