Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How to remove RTL from compiled EXE?


This question is not answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 14 - Last Post: Feb 22, 2017 1:31 AM Last Post By: Fikret Hasovic
Yogi Yang

Posts: 57
Registered: 12/23/06
How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 7, 2016 3:49 AM
Hello,

I want to force the compiler to not include the RTL in XE6 when compiling my code.

How to do this?

TIA

Yogi Yang
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 7, 2016 9:31 AM   in response to: Yogi Yang in response to: Yogi Yang
Am 07.12.2016 um 12:49 schrieb Yogi Yang:
Hello,

I want to force the compiler to not include the RTL in XE6 when compiling my code.

How to do this?

Hello,

not quite sure what you want to achieve, but since quite a lot of your
program parts rely on the RTL because they call functions of it it
cannot be removed completely.

But rest assured that the compiler employs smart linking which normally
removes unused functions/procedures so only those parts of RTL stay in
your program which you actually use.

Greetings

Markus
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 7, 2016 9:51 AM   in response to: Yogi Yang in response to: Yogi Yang
Yogi wrote:

I want to force the compiler to not include the RTL
in XE6 when compiling my code.

How to do this?

Why would you ever need to do this? The compiler/linker will discard any
code that is not used, and the RTL includes code that supports various compiler
language features, so you can't remove it completely if you need to use features
that must be managed at runtime (like string handling, etc).

What are you really trying to accomplish?

--
Remy Lebeau (TeamB)
Alex Belo

Posts: 626
Registered: 10/8/06
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 8, 2016 7:19 AM   in response to: Yogi Yang in response to: Yogi Yang
Yogi Yang wrote:

I want to force the compiler to not include the RTL in XE6 when
compiling my code.

How to do this?

Set "Dynamic RTL" checkbox in project's options? (This option exists in
CB, I don't know about Delphi for sure)

--
Alex
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 8, 2016 9:09 AM   in response to: Alex Belo in response to: Alex Belo
Alex wrote:

Set "Dynamic RTL" checkbox in project's options? (This option
exists in CB, I don't know about Delphi for sure)

That is a C++ only option. In Delphi, you can only enable/disable use of
Runtime packages.

--
Remy Lebeau (TeamB)
Arthur Hoornweg

Posts: 414
Registered: 6/2/98
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2016 2:32 AM   in response to: Yogi Yang in response to: Yogi Yang
Yogi Yang wrote:
Hello,

I want to force the compiler to not include the RTL in XE6 when compiling my code.

How to do this?

Compile with packages. You will need to deploy the used packages or the application will not run.

Fikret Hasovic

Posts: 6
Registered: 10/13/99
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 13, 2017 3:38 AM   in response to: Yogi Yang in response to: Yogi Yang
Yogi Yang wrote:
Hello,

I want to force the compiler to not include the RTL in XE6 when compiling my code.

How to do this?

TIA

Yogi Yang

Perhaps you mean RTTI?
Yogi Yang

Posts: 57
Registered: 12/23/06
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 18, 2017 8:32 PM   in response to: Yogi Yang in response to: Yogi Yang
Hello,

I really want to get rid of RTL/RTTI so that I can reduce the size of the final exe as the software that we compile generates the EXE of wooping 98 MB size.

I think removing the RTL/RTTI should help in reducing the size by at least 40%.

TIA

Yogi Yang
Arthur Hoornweg

Posts: 414
Registered: 6/2/98
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 18, 2017 11:49 PM   in response to: Yogi Yang in response to: Yogi Yang
Yogi Yang wrote:

I think removing the RTL/RTTI should help in reducing the size by at least 40%.

The RTL is the runtime library (unit System etc) and you really can't do without it. But 98 MB is tremendous. First of all, verify that you aren't linking any debugging info or remote debug symbols, then perform a full build. Does that make any difference?
Then there's resources. Do you use any large resources on your forms (images etc)? Check your directories for very large *.DFM files. Often such bitmaps occupy more space than the code itself. There are ways around that (compressed bitmap formats).

If you really want to get rid of most of the RTTI then you need to re-compile most of the RTL and VCL without RTTI. This was still possible in Delphi XE but it wasn't very easy, I had to write a FinalBuilder script to do it.

But I really don't believe you'll save any significant footprint in a 98 MB executable. In my own applications (using XE) eliminating RTTI saves an average of 0.5 MB per executable and DLL.

Edited by: Arthur Hoornweg on Jan 18, 2017 11:49 PM

Steve Faleiro

Posts: 77
Registered: 3/11/01
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 21, 2017 7:10 AM   in response to: Yogi Yang in response to: Yogi Yang
Yogi Yang wrote:
Hello,

I really want to get rid of RTL/RTTI so that I can reduce the size of the final exe as the software that we compile generates the EXE of wooping 98 MB size.

I think removing the RTL/RTTI should help in reducing the size by at least 40%.

TIA

Yogi Yang

Yogi,

Use upx.exe to compress the generated executable..

Edited by: Steve Faleiro on Jan 21, 2017 7:11 AM
Steve Faleiro

Posts: 77
Registered: 3/11/01
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 21, 2017 7:10 AM   in response to: Yogi Yang in response to: Yogi Yang
Yogi Yang wrote:
Hello,

I really want to get rid of RTL/RTTI so that I can reduce the size of the final exe as the software that we compile generates the EXE of wooping 98 MB size.

I think removing the RTL/RTTI should help in reducing the size by at least 40%.

TIA

Yogi Yang

Yogi,

Use upx.exe to compress the generated executable..
Luigi Sandon

Posts: 74
Registered: 2/22/08
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 23, 2017 3:32 AM   in response to: Yogi Yang in response to: Yogi Yang
I think removing the RTL/RTTI should help in reducing the size by at least 40%.

The size of the RTLxxx.bpl package will give you an idea of the size of the full RTL itself once compiled - far less than the 50MB you hope.

Unless you also include in the "RTL" all the components/control code - which actually isn't the "RTL" - and the size of code, resources, etc. depends on what you're using and which compilation settings are used. Using lots of third party libraries, maybe for a few components, may increase the exe size despite what the linker can remove. Often libraries include many large resources the linker may not remove.

You can't remove the RTL itself because it is where critical features like memory and exception management, etc are implemented. Once there as been attempt to replace it with a smaller, leaner version, but I don't know if those projects are still alive, and there's an inherent risk something can break.

The best way to control the exe size, if a single monolithic exe is not needed for specific needs, is to break it into pieces using DLLs or BPLs. In the latter case, using run-time packages, the RTL too becomes a separate BPL (very much alike the dynamic linking of the RTL C/C++ compilers use). The overall size of the whole application will be bigger (BPLs include the full code of the units they contain), but then exe sizes will be far smaller.

I would avoid to install BPLs in a "common" folder, and especially not in any of the system directories. Install a private copy for your own application, in the same folder or set an application private path (see https://msdn.microsoft.com/en-us/library/windows/desktop/ee872121(v=vs.85).aspx) accordingly, if you wish to share them with some applications of yours.

Run-time packages are a very useful feature of Delphi but they never got enough "love", especially from a documentation, project management and deployment perspectives.

Many library developers also stubbornly and lazily kept putting the Delphi version in the package file name (instead of the package options), crippling forward and backward application projects compatibility because the version ends in the .dcp name too (and thereby in the project settings). Their DLL (packages are DLLs) version numbers are rarely properly set also, leading to the risk of older packages overwriting newer ones if a shared location is used - and makes identifying issues harder.

Then people blame Windows - but often the reason is (bad) developers not following proper guidelines just because they require a little more work and care.
Eli M

Posts: 1,346
Registered: 11/9/13
Re: How to remove RTL from compiled EXE?
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2017 6:33 AM   in response to: Yogi Yang in response to: Yogi Yang
Yogi Yang

Posts: 57
Registered: 12/23/06
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 7, 2017 11:42 PM   in response to: Eli M in response to: Eli M

Thanks for the useful link.

So there are possibilities using compiler directives. Will have to explore.

TIA

Yogi Yang
Fikret Hasovic

Posts: 6
Registered: 10/13/99
Re: How to remove RTL from compiled EXE?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 22, 2017 1:31 AM   in response to: Yogi Yang in response to: Yogi Yang
Yogi Yang wrote:


So there are possibilities using compiler directives. Will have to explore.

Try this, in your project dpr file:
program Project1;

{$SetPEFlags 1}
{$WEAKLINKRTTI ON}
{$RTTI EXPLICIT METHODS([]) FIELDS([]) PROPERTIES([])}

Best regards
Fikret Hasovic
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02