[PATCH 2 of 2] cc/gcc: add support for a statcally linked shared core for static toolchain
Bryan Hundven
bryanhundven@gmail.com
Wed Dec 8 23:38:00 GMT 2010
On Wed, Dec 8, 2010 at 2:58 PM, Yann E. MORIN
<yann.morin.1998@anciens.enib.fr> wrote:
> Bryan, All,
>
> On Monday 18 October 2010 23:12:04 Bryan Hundven wrote:
>> # HG changeset patch
>> # User Bryan Hundven <bryanhundven@gmail.com>
>> # Date 1287435325 25200
>> # Node ID fa5bd6f1ea1aa117771e4c53fefaba16ba603d82
>> # Parent 8091950d99a8b10bbff4b7a35518380afeefc5f6
>> cc/gcc: add support for a statcally linked shared core for static toolchain
>
>> diff -r 8091950d99a8 -r fa5bd6f1ea1a scripts/build/cc/gcc.sh
>> --- a/scripts/build/cc/gcc.sh Mon Oct 18 12:15:08 2010 -0700
>> +++ b/scripts/build/cc/gcc.sh Mon Oct 18 13:55:25 2010 -0700
>> @@ -66,9 +66,18 @@
>> y,*,*) do_cc_core mode=baremetal build_libgcc=yes build_libstdcxx=yes;;
>> ,y,*) ;;
>> ,,nptl)
>> - do_cc_core mode=shared build_libgcc=yes
>> + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
>> + do_cc_core mode=shared build_libgcc=yes build_staticlinked=yes
>> + else
>> + do_cc_core mode=shared build_libgcc=yes
>> + fi
>> ;;
>> - ,,win32) do_cc_core mode=static build_libgcc=yes
>> + ,,win32)
>> + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
>> + do_cc_core mode=static build_libgcc=yes build_staticlinked=yes
>> + else
>> + do_cc_core mode=static build_libgcc=yes
>> + fi
>
> Unfortunately, you got it wrong:
>
> - when not bare-metal, the core pass 1 & 2 gcc are discarded, and only the
> final gcc is part of the toolchain. And that is the final gcc we want to
> be statically linked. You got it right in your first patch.
>
> - but when doing bare-metal, the final gcc is coming from the core_cc_pass_2
> (yes, that's odd, but that's the way it goes). And that is that pass 2 gcc
> we want to be statically linked.
>
> Unfortunately, your patch #2 only builds static core gcc when not bare-metal.
> So, for bare-metal (the first match in the case statement) the useful gcc
> will never be statically linked.
>
> Don't worry, I've fixed this in my local copy. ;-)
>
>> ;;
>> *) if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
>> do_cc_core mode=static build_libgcc=yes
>> @@ -84,18 +93,20 @@
>> # This function is used to build both the static and the shared core C conpiler,
>> # with or without the target libgcc. We need to know wether:
>> # - we're building static, shared or bare metal: mode=[static|shared|baremetal]
>> -# - we need to build libgcc or not : build_libgcc=[yes|no] (default: no)
>> -# - we need to build libstdc++ or not : build_libstdcxx=[yes|no] (default: no)
>> -# Usage: do_cc_core_static mode=[static|shared|baremetal] build_libgcc=[yes|no]
>> +# - we need to build libgcc or not : build_libgcc=[yes|no] (default: no)
>> +# - we need to build libstdc++ or not : build_libstdcxx=[yes|no] (default: no)
>> +# - we need to build statically linked or not : build_staticlinked=[yes|no] (default: no)
>> +# Usage: do_cc_core mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no]
>> do_cc_core() {
>> local mode
>> local build_libgcc=no
>> local build_libstdcxx=no
>> + local build_staticlinked=no
>> local core_prefix_dir
>> local lang_opt
>> local tmp
>> local -a extra_config
>> - local core_LDFLAGS
>> + local -a core_LDFLAGS
>> local -a core_targets
>>
>> while [ $# -ne 0 ]; do
>> @@ -163,7 +174,12 @@
>> # is needed. Shoe-horn it in our LDFLAGS
>> # Ditto libm on some Fedora boxen
>> if [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
>> - core_LDFLAGS='-lstdc++ -lm'
>> + if [ "${build_staticlinked}" = "yes" ]; then
>> + core_LDFLAGS+=("-static")
>> + extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++ -lm")
>> + fi
>> + core_LDFLAGS+=("-lstdc++")
>> + core_LDFLAGS+=("-lm")
>
> Well, not your fault, but this part of the code is incomplete.
> I've fixed it as well.
>
> 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. |
> '------------------------------^-------^------------------^--------------------'
>
I'd love to see your patch.
--
Bryan Hundven
bryanhundven@gmail.com
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list