public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Reducing size of GCC installation?
@ 2020-08-04 19:26 Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
  2020-08-04 20:24 ` Segher Boessenkool
  2020-08-04 20:50 ` Jonathan Wakely
  0 siblings, 2 replies; 4+ messages in thread
From: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] @ 2020-08-04 19:26 UTC (permalink / raw)
  To: gcc-help

All,

This might be a FAQ, but my Google-fu is being stymied by the fact that my searches are often finding issues about making executables, etc. made by GCC smaller rather than my issue: making GCC itself smaller.

To wit, I'm trying to build some Docker images and found that the code I'm eventually trying to build with gcc (gfortran, actually) doesn't like the versions from RPMs/DEBs/etc. So, my first step is usually to do what I'm quite used to and build GCC a la:

  ../gcc-10.2.0/configure --prefix=$HOME/GCC/10.2.0 --disable-multilib --enable-languages=c,c++,fortran
  make
  make install

and this works. Huzzah.

But the main issue I have is the desire to make docker images as small as possible. So I obviously remove the build directory, but the install directory itself is pretty beefy:

$ du -hsc GCC/10.2.0/*
295M GCC/10.2.0/bin
12M  GCC/10.2.0/include
24M  GCC/10.2.0/lib
221M GCC/10.2.0/lib64
1.1G GCC/10.2.0/libexec
16M  GCC/10.2.0/share
1.6G total

Ouch. 1.6G.

So I'm looking at any way to make that smaller. My first thought is using strip a posteriori to make executable smaller, but maybe this is A Bad Thing™? I know it can make some of the binaries smaller (of course) but maybe in doing so, things fall apart?

Or perhaps is there a configure option to "ensmallen GCC" upon installation?

Just thought I'd ask and thanks for any help.

Best,
Matt

--
Matt Thompson, SSAI, Ld Scientific Programmer/Analyst
NASA GSFC,    Global Modeling and Assimilation Office
Code 610.1,  8800 Greenbelt Rd,  Greenbelt,  MD 20771
Phone: 301-614-6712                 Fax: 301-614-6246
http://science.gsfc.nasa.gov/sed/bio/matthew.thompson

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Reducing size of GCC installation?
  2020-08-04 19:26 Reducing size of GCC installation? Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
@ 2020-08-04 20:24 ` Segher Boessenkool
  2020-08-04 21:10   ` [EXTERNAL] " Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
  2020-08-04 20:50 ` Jonathan Wakely
  1 sibling, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2020-08-04 20:24 UTC (permalink / raw)
  To: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
  Cc: gcc-help

Hi!

On Tue, Aug 04, 2020 at 07:26:09PM +0000, Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] via Gcc-help wrote:
> To wit, I'm trying to build some Docker images and found that the code I'm eventually trying to build with gcc (gfortran, actually) doesn't like the versions from RPMs/DEBs/etc. So, my first step is usually to do what I'm quite used to and build GCC a la:
> 
>   ../gcc-10.2.0/configure --prefix=$HOME/GCC/10.2.0 --disable-multilib --enable-languages=c,c++,fortran
>   make
>   make install
> 
> and this works. Huzzah.

make install-strip

> Ouch. 1.6G.

How much does install-strip safe?

> Or perhaps is there a configure option to "ensmallen GCC" upon installation?

Yes :-)  It is documented on

https://gcc.gnu.org/install/finalinstall.html

There may be other tricks in the installation manual you missed as well?

Good luck and have fun,


Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Reducing size of GCC installation?
  2020-08-04 19:26 Reducing size of GCC installation? Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
  2020-08-04 20:24 ` Segher Boessenkool
@ 2020-08-04 20:50 ` Jonathan Wakely
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2020-08-04 20:50 UTC (permalink / raw)
  To: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
  Cc: gcc-help

On Tue, 4 Aug 2020 at 20:28, Thompson, Matt (GSFC-610.1)[SCIENCE
SYSTEMS AND APPLICATIONS INC] via Gcc-help <gcc-help@gcc.gnu.org>
wrote:
>
> All,
>
> This might be a FAQ, but my Google-fu is being stymied by the fact that my searches are often finding issues about making executables, etc. made by GCC smaller rather than my issue: making GCC itself smaller.
>
> To wit, I'm trying to build some Docker images and found that the code I'm eventually trying to build with gcc (gfortran, actually) doesn't like the versions from RPMs/DEBs/etc. So, my first step is usually to do what I'm quite used to and build GCC a la:
>
>   ../gcc-10.2.0/configure --prefix=$HOME/GCC/10.2.0 --disable-multilib --enable-languages=c,c++,fortran

If you're not going to need them you can disable a number of features:

--disable-nls
--disable-libstdcxx-pch
--disable-libcc1
--disable-libsanitizer
--disable-libssp
--disable-libgomp
--disable-libvtv
--disable-libstdcxx-filesystem-ts

I wouldn't recommend this one, despite shrinking the size of
libstdc++.so and libstdc++.a, because it is an ABI break:
--disable-libstdcxx-dual-abi

If this one still works it would also be an ABI break (and make C++
code compile slower):
--disable-extern-template

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [EXTERNAL] Re: Reducing size of GCC installation?
  2020-08-04 20:24 ` Segher Boessenkool
@ 2020-08-04 21:10   ` Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
  0 siblings, 0 replies; 4+ messages in thread
From: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] @ 2020-08-04 21:10 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-help

Well, don't I feel dumb. I'd seen install-strip before on that page long ago, but I guess I just forgot about it (plus I got used to using strip with rustup/cargo builds which don't strip by default).

And per your question, building with install-strip (in a different, but similar image):

$ du -hsc gcc/*
35M	gcc/bin
12M	gcc/include
22M	gcc/lib
29M	gcc/lib64
119M	gcc/libexec
15M	gcc/share
230M	total

I will take a 1.3G reduction in space. 

I guess it's time to start using install-strip like a madman and see what I can break in other codes! :D 

-- 
Matt Thompson, SSAI, Ld Scientific Programmer/Analyst
NASA GSFC,    Global Modeling and Assimilation Office
Code 610.1,  8800 Greenbelt Rd,  Greenbelt,  MD 20771
Phone: 301-614-6712                 Fax: 301-614-6246
http://science.gsfc.nasa.gov/sed/bio/matthew.thompson

On 8/4/20, 4:24 PM, "Segher Boessenkool" <segher@kernel.crashing.org> wrote:

    Hi!

    On Tue, Aug 04, 2020 at 07:26:09PM +0000, Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] via Gcc-help wrote:
    > To wit, I'm trying to build some Docker images and found that the code I'm eventually trying to build with gcc (gfortran, actually) doesn't like the versions from RPMs/DEBs/etc. So, my first step is usually to do what I'm quite used to and build GCC a la:
    > 
    >   ../gcc-10.2.0/configure --prefix=$HOME/GCC/10.2.0 --disable-multilib --enable-languages=c,c++,fortran
    >   make
    >   make install
    > 
    > and this works. Huzzah.

    make install-strip

    > Ouch. 1.6G.

    How much does install-strip safe?

    > Or perhaps is there a configure option to "ensmallen GCC" upon installation?

    Yes :-)  It is documented on

    https://urldefense.proofpoint.com/v2/url?u=https-3A__gcc.gnu.org_install_finalinstall.html&d=DwIBAg&c=ApwzowJNAKKw3xye91w7BE1XMRKi2LN9kiMk5Csz9Zk&r=t-_8LOcT3mR0eRjGIhNBgNcMPWsPBrZlJ8ZiJNKcEVg&m=6Ev8kbRqoawi75HbJkraV_KIXPl6EzRDJK_UzsUpl4Q&s=Jd1M-j9kKHFNkzzM7aJ4Ws2_9iGeEYxw0x9qsmP2JYg&e= 

    There may be other tricks in the installation manual you missed as well?

    Good luck and have fun,


    Segher


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-04 21:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 19:26 Reducing size of GCC installation? Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
2020-08-04 20:24 ` Segher Boessenkool
2020-08-04 21:10   ` [EXTERNAL] " Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
2020-08-04 20:50 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).