This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2 of 2] cc/gcc: add support for a statcally linked shared core for static toolchain


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]