简体   繁体   中英

Does C++ Builder linker support function-level linking?

I work almost two years on various projects written in C++ Builder. During this time I noticed a few things related to size of resulting executable. I try to describe it on two examples:

1.Today I converted one project from C++ Builder 6 to C++ Builder XE4. Here is the comparison of DLL sizes:

Old DLL      531 968 B

New DLL    3 422 720 B (or more than 6x larger than old one!)

Both binaries are compiled as release with static linking of additional libraries. No source code changes between these two versions except changing the global variable defining the library version and executable properties containing product info (version, description, company and so on).

2.I added to VCL project written in C++ Builder XE2 some files from JCL (JEDI Code Library) project. No object from JCL is created in my code so I would think the linker shouldnt link the new methods even when they are part of code. Nevertheless the binary size increased from 17 900 000 to 19 300 000. I don't have exact numbers because there were also other minor changes. Small part of this increase could be attributed to linking resource file JclUnicode.res which is 170 kB large. Nevertheless this is consistent with my long-term experience that when adding some external component to project the resulting change in binary size is not appropriate if we compare it with new functions for end-user.

I have suspicion that there are large part of code in resulting binary that are never called. Unfortunately I don't know how to verify this hypothesis. Is there some tool that could analyse the resulting binary for never used code / data? Does C++ Builder linker support function-level linking? This is a very practical issue if we take into consideration time needed for reading the executable from hard-drive to memory and size of RAM memory occuppied by program. My colleague who is developping embedded software said me a story how by removing never called functions from firmware reduced its size by 80%.

There have been numerous discussions on Embarcadero's forums related to the increase of executable file sizes in various versions. There have been substantial changes to the RTL/VCL between BCB6 and XE4. The switch to Unicode, the introduction of Delphi Generics and Extended RTTI, etc. They all contribute to file size. Especially in C++Builder, which cannot filter out unused RTL/VCL code as well as Delphi can, especially the Enhanced RTTI in particular, but also Delphi Generics are not very well optimized yet compared to C++ templates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM