Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 Jun 2008 16:07:23 +0200
From:      Kris Kennaway <kris@FreeBSD.org>
To:        Tobias Hoellrich <thoellri@adobe.com>, freebsd-questions@freebsd.org
Subject:   Re: size of executable - g95 vs gfortran42 - shared libs?
Message-ID:  <4847F31B.7090404@FreeBSD.org>
In-Reply-To: <20080605135015.GA52233@mech-aslap33.men.bris.ac.uk>
References:  <20080605132106.GA51988@mech-aslap33.men.bris.ac.uk>	<E891374F64B9194FB5BFFF28935811CA02A3EC77@namail2.corp.adobe.com> <20080605135015.GA52233@mech-aslap33.men.bris.ac.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
Anton Shterenlikht wrote:
> On Thu, Jun 05, 2008 at 06:29:35AM -0700, Tobias Hoellrich wrote:
>>> I use two different fortran90 compiler on a simple input file
>>> and get executables which differ in size by almost 3 orders of
>>> magnitude, see below. Is this something to do with the use
>>> of shared libraries?
>> Run "file" and "ldd" on the executables to see the difference:
>>
>> [root@santafe ~]# file `which ls`
>> /bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD),
>> for FreeBSD 8.0 (800038), dynamically linked (uses shared libs),
>> FreeBSD-style, stripped
>>
>> [root@santafe ~]# ldd `which ls`
>> /bin/ls:
>>         libutil.so.7 => /lib/libutil.so.7 (0x28082000)
>>         libncurses.so.7 => /lib/libncurses.so.7 (0x28090000)
>>         libc.so.7 => /lib/libc.so.7 (0x280cf000)
>> [root@santafe ~]#
> 
> Many thanks, the ldd resuts differ,
> but how does this translate into size?
> 
> % ls -al *out
> -rwxr-xr-x  1 mexas  wheel  546413  5 Jun 14:39 g95.out
> -rwxr-xr-x  1 mexas  wheel    9179  5 Jun 14:39 gf42.out
> 
> % file *out
> g95.out:  ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD),
> for FreeBSD 7.0 (700109), dynamically linked (uses shared libs),
> FreeBSD-style, not stripped
> 
> gf42.out: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD),
> for FreeBSD 7.0 (700109), dynamically linked (uses shared libs),
> FreeBSD-style, not stripped

Both files have debugging symbols enabled.  You can remove these with 
strip, at the cost of not being able to use gdb to obtain backtraces if 
you run into a bug.

> % ldd *.out
> g95.out:
>         libm.so.5 => /lib/libm.so.5 (0x280c5000)
>         libc.so.7 => /lib/libc.so.7 (0x280db000)

^-- this one doesn't link to a dynamic fortran library, so it is 
presumably statically linked, explaining the size.  Look into how the 
file was constructed (e.g. the command used to link the binary).

> gf42.out:
>         libgfortran.so.2 => /usr/local/lib/gcc-4.2.4/libgfortran.so.2 (0x2807e000)
>         libm.so.5 => /lib/libm.so.5 (0x28103000)
>         libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x28119000)
>         libc.so.7 => /lib/libc.so.7 (0x28124000)
> % 
> 

Kris



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4847F31B.7090404>