Re: what is fast dynamically linked executable or statically linked executable ?how to decide?



"pratap" <pratappai78@xxxxxxxxx> wrote in message
news:1173075717.793186.290080@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Could someone clarify how could one reduce the size of an
executable code during compile time.
Could one use specific compile time flag with makefile or is it
advisable to go for dynamic linking.
The idea here is that smaller the code size the faster is the code.
Is Dynamically linked executable really faster than a single
executable file which is not linked dynamically.?

Your whole premise here is flawed; smaller does not mean faster. In fact,
most compilers have options to either compile for speed (e.g. gcc's -O3) or
for size (e.g. gcc's -Os), and the two are mutually exclusive. There are
lots of tricks modern compilers use to speed up code that actually make the
executable (sometimes significantly) bigger. Likewise, the tricks they use
to make code small often make executables significantly slower.

Dynamic linking may make your code faster or slower; it will almost always
make it smaller. The potential speed boost comes not from the size, though;
it comes from multiple copies of the same code being shared in memory
instead of duplicated, which reduces swapping and cache misses.

However, it all boils down to this: if you have to care about optimizations
at this level, you're most likely doing something seriously wrong.

S

--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov



--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: Cobol object code compare
    ... cobol compile codes or re-creates the source from the object. ... least slightly different executables. ... make dramatic differences in the object code, ... production executables, make sure that your source code and documentation is ...
    (comp.sys.hp.mpe)
  • Re: Another game to analyze.
    ... He didn't say within a browser. ... You provide three executables, and that takes care of 99% of all platforms. ... It's also possible to take a C program and compile ... There are also other compilers that can do that to Java bytecode too. ...
    (rec.games.chess.computer)
  • [7/12] kbuild: Separate out host-progs handling
    ... # Concentrating all host-progs functionality in one file made a more ... -# Will compile bin2hex.c and create an executable named bin2hex ... -$: %: $(host-cshobjs) FORCE ... +# C executables linked based on several .o files ...
    (Linux-Kernel)
  • Re: rtld + static linking
    ... >> Dynamic linking works because the kernel loads and runs the dynamic ... Implementations may also impose specific constraints on the ... Note that staticly linked executables can be in violation of platform ...
    (freebsd-current)
  • Re: New C++ standard
    ... There is also Cygwin support mentioned in ConceptGCC homepage..., but I haven't tested it and perhaps I'm not going to do it in near future. ... remain correct, so trivial executables can be created, and it is quite ... So, maybe i don't understand any, but there is way to compile the ... It may be easier to build for example Linux to DJGPP cross-compiler. ...
    (comp.os.msdos.djgpp)