Make the compiler only build static. . .

Reiland, Doug doug.reiland@intel.com
Thu May 5 22:04:00 GMT 2011


Isn't there a gcc specfile somewhere that <you> could add --static to?
Seems like one could just add that to where all the default defines and stuff get set.


-----Original Message-----
From: crossgcc-owner@sourceware.org [mailto:crossgcc-owner@sourceware.org] On Behalf Of Yann E. MORIN
Sent: Thursday, May 05, 2011 4:27 PM
To: crossgcc@sourceware.org
Cc: ANDY KENNEDY
Subject: Re: Make the compiler only build static. . .

On Thursday 05 May 2011 21:53:47 ANDY KENNEDY wrote:
> Note:  I don't want a static toolchain.
> 
> I have a requirement that the toolchain be eglibc which is too large
> for my tastes.  So, I want the RFS to use statically linked uClibC
> (which, when my patch is done, is easy enough to do through BuildRoot).
> I want to FORCE the toolchain I build to link all binaries STATIC since
> there will not be eglibc on the RFS.
> 
> I've seen in the gcc options that there is a way to force LD options to
> be -static, however, when I attempted to do this, it didn't work.  I'd
> rather not depend on the makefiles that build the "external" apps to
> pass an LDFLAGS=-static to the make system.
> 
> Is there an option I can configure in crosstool that will allow me to
> do this?

Not in crosstool-NG, but you can configure uClibc to build only the
static libraries.

But beware. If you are really size-constrained, and you have many programs,
then static linking could make your file system grow.

If you have many programs on your file system, and those programs call many
of the C libraryu functions, then those functiopns bodies will be duplicated
into every program that uses it. Which will make your file system grow. Now,
if you have a single program, then static linking could be a solution. YMMV.

But there are other options.

For example, there is a script called mklibs that will scan your file system
for every executable programs, list all UNDefined symbols in them, search
for those symbols in every shared libraries. Then for each shared library,
it will try to recreate that library from the static version, but only with
the symbols listed before. Rince and repeat until there are no more any
UNDefined symbols.

Of course, if the static version of the library does not exist, then the
shared library is used as-is, as there is no way to remove function bodies
(or other objects, for that matters) from a shared library.

That way, you get the best of both worlds:
 - space gained using shared libs
 - space gained from including only required symbols

You can find a version of mklibs in different places: buildroot, debian...
Google is your friend there...

I am also planning on adding such a script (perhaps mklibs itself) to
crosstool-NG, along with populate.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

--
For unsubscribe information see http://sourceware.org/lists.html#faq


--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list