[PATCH] add CC_STATIC_LIBSTDCXX option for gcc-4.4 and newer
Yann E. MORIN
yann.morin.1998@anciens.enib.fr
Thu Jul 29 17:03:00 GMT 2010
Johannes, All,
On Thursday 29 July 2010 17:26:39 Johannes Stezenbach wrote:
> add CC_STATIC_LIBSTDCXX option for gcc-4.4 and newer
There had already been some trials at that, and I was not very happy
with the outcome. That one I like much better because we can then
have config knobs 'select' that if needed.
Eventually, I'd like that we push the idea a bit further. It seems
that on some hosts (eg. cygwin or mingw32), we always need to link
with libstdc++ statically (or at least it is an easy workaround).
But that will have to wait post-1.8.0.
> Idea and know-how taken from CodeSourcery build script.
>
> Normal build:
> $ ldd arm-unknown-linux-uclibcgnueabi-gcc
> linux-gate.so.1 => (0xb77f3000)
> libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb76e8000)
> libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb75a1000)
> libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb757a000)
> /lib/ld-linux.so.2 (0xb77f4000)
> libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb755c000)
>
> CC_STATIC_LIBSTDCXX=y:
> $ ldd arm-unknown-linux-uclibcgnueabi-gcc
> linux-gate.so.1 => (0xb7843000)
> libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb76e6000)
> /lib/ld-linux.so.2 (0xb7844000)
>
> I made CC_STATIC_LIBSTDCXX default=y since I think
> it is always desirable.
>
> Signed-off-by: Johannes Stezenbach <js@sig21.net>
>
> diff -r 8ed7bda0e44d config/cc/gcc.in
> --- a/config/cc/gcc.in Thu Jul 29 14:38:58 2010 +0200
> +++ b/config/cc/gcc.in Thu Jul 29 16:44:29 2010 +0200
> @@ -183,6 +183,18 @@
> default "4.0.4" if CC_V_4_0_4
> default "3.4.6" if CC_V_3_4_6
>
> +config CC_STATIC_LIBSTDCXX
> + bool
> + prompt "link libstdc++ statically into the gcc binary"
> + default y
> + depends on CC_GCC_4_4_or_later
> + help
> + Newer gcc versions use the PPL library which is C++ code. Statically
> + linking libstdc++ increases the likeliness that the gcc binary will
> + run on machines other than the one which it was built on, without
> + having to worry about distributing the matching version of libstdc++
> + along with it.
> +
> config CC_CXA_ATEXIT
> bool
> prompt "Use __cxa_atexit"
> diff -r 8ed7bda0e44d scripts/build/cc/gcc.sh
> --- a/scripts/build/cc/gcc.sh Thu Jul 29 14:38:58 2010 +0200
> +++ b/scripts/build/cc/gcc.sh Thu Jul 29 16:44:29 2010 +0200
> @@ -338,10 +338,16 @@
> extra_config+=("--enable-cxx-flags=${CC_ENABLE_CXX_FLAGS}")
> fi
>
> - # When companion libraries are build static (eg !shared),
> - # the libstdc++ is not pulled automatically, although it
> - # is needed. Shoe-horn it in our LDFLAGS
> - if [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
> + if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
> + # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
> + # build script
> + # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
> + # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
Yes. Post-1.8.0.
> + extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
> + elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
> + # When companion libraries are build static (eg !shared),
> + # the libstdc++ is not pulled automatically, although it
> + # is needed. Shoe-horn it in our LDFLAGS
> final_LDFLAGS='-lstdc++'
> fi
> if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
Queued for 1.8.0! :-)
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
More information about the crossgcc
mailing list