[PATCH 0 of 1] Static gcc/binutils

Yann E. MORIN yann.morin.1998@anciens.enib.fr
Tue Feb 16 18:04:00 GMT 2010


Hello Josh, All!

Sorry for the delay, I've had quite a few things to address IRL.

On Sunday 07 February 2010 06:23:32 Josh Henderson wrote:
> Adds the ability to build a static gcc/binutils.  It does not apply to
> anything else, but is a start to this request:
> http://sourceware.org/ml/crossgcc/2008-06/msg00021.html.

Thanks for the effort!

> zlib added because most distributions do not include a static zlib.

Debian at least has it in package: zlib1-dev; Fedora has it in zlib-static.
I do thing that most distribution do have a static zlib packaged.

zlib has had quite a few security isues, and I'd a bit uneasy to see a
static zlib being built as part of the toolchain. I would always wonder
whether it is appropriatley patched.

So better rely on the distributions' correctly doing their jobs, rather
than trying to be smarter than they are, and miss some security fixes
because we don't have time to properly follow...

> diff -Naur crosstool-ng-1.5.1/config/toolchain.in
> crosstool-ng-1.5.1-static/config/toolchain.in
> --- crosstool-ng-1.5.1/config/toolchain.in	2009-10-28 11:43:37.000000000 -0700
> +++ crosstool-ng-1.5.1-static/config/toolchain.in	2010-01-28
> 22:04:46.000000000 -0800
> @@ -12,6 +12,13 @@
> 
>        You definitely want to say 'Y' here. Yes you do. I know you do. Say 'Y'.
> 
> +config STATIC_TOOLCHAIN
> +    bool
> +    prompt "Build Static Toolchain"
> +    default y
> +    help
> +      Compile binutils and gcc as static binaries.
> +

Not the correct place: SYSROOT_PREFIX_DIR must really be a sub-options
of SYSROOT. Having STATIC_TOOLCHAIN in-between is really weird.

>  config SYSROOT_DIR_PREFIX
>      string
>      prompt "sysroot prefix dir (READ HELP)"
> diff -Naur crosstool-ng-1.5.1/scripts/build/binutils/binutils.sh
> crosstool-ng-1.5.1-static/scripts/build/binutils/binutils.sh
> --- crosstool-ng-1.5.1/scripts/build/binutils/binutils.sh	2009-10-28
> 11:43:37.000000000 -0700
> +++ crosstool-ng-1.5.1-static/scripts/build/binutils/binutils.sh	2010-01-26
> 22:22:59.000000000 -0800
> @@ -48,7 +48,12 @@
>          ${BINUTILS_SYSROOT_ARG}
> 
>      CT_DoLog EXTRA "Building binutils"
> -    CT_DoExecLog ALL make ${PARALLELMFLAGS}
> +    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
> +	CT_DoExecLog ALL make configure-host
> +	CT_DoExecLog ALL make ${PARALLELMFLAGS} LDFLAGS="-all-static
> -L${CT_PREFIX_DIR}/lib"

Space damage.

> +    else
> +	CT_DoExecLog ALL make ${PARALLELMFLAGS}
> +    fi
> 
>      CT_DoLog EXTRA "Installing binutils"
>      CT_DoExecLog ALL make install
> diff -Naur crosstool-ng-1.5.1/scripts/build/cc/gcc.sh
> crosstool-ng-1.5.1-static/scripts/build/cc/gcc.sh
> --- crosstool-ng-1.5.1/scripts/build/cc/gcc.sh	2009-10-28
> 11:43:37.000000000 -0700
> +++ crosstool-ng-1.5.1-static/scripts/build/cc/gcc.sh	2010-01-29
> 00:14:34.000000000 -0800
> @@ -346,9 +346,14 @@
>          CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
>      fi
> 
> -    CT_DoLog EXTRA "Building final compiler"
> -    CT_DoExecLog ALL make ${PARALLELMFLAGS} all
> +    extra_make_flags=
> +    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
> +	extra_make_flags="LDFLAGS=-static"
> +    fi
> 
> +    CT_DoLog EXTRA "Building final compiler"
> +    CT_DoExecLog ALL make ${PARALLELMFLAGS} ${extra_make_flags}

Keep the 'all' make target, please.

> +
>      CT_DoLog EXTRA "Installing final compiler"
>      CT_DoExecLog ALL make install
> 
> diff -Naur crosstool-ng-1.5.1/scripts/build/companion_libs/gmp.sh
> crosstool-ng-1.5.1-static/scripts/build/companion_libs/gmp.sh
> --- crosstool-ng-1.5.1/scripts/build/companion_libs/gmp.sh	2009-10-28
> 11:43:37.000000000 -0700
> +++ crosstool-ng-1.5.1-static/scripts/build/companion_libs/gmp.sh	2010-01-29
> 00:11:52.000000000 -0800
> @@ -28,6 +28,13 @@
> 
>      CT_DoStep INFO "Installing GMP"
> 
> +    gmp_opt=
> +    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
> +	gmp_opt="$gmp_opt --enable-static"
> +    else
> +	gmp_opt="$gmp_opt --disable-static"
> +    fi
> +

Unfortunately, I was not able to properly build a static GMP (and MPFR),
as the other companion libraries (at least CLooG) complains. So we're
stick to using shared companion libraries for now. If you manage to
build static complibs, please provide a separate patch.

> diff -Naur crosstool-ng-1.5.1/scripts/build/companion_libs/mpfr.sh
> crosstool-ng-1.5.1-static/scripts/build/companion_libs/mpfr.sh
> --- crosstool-ng-1.5.1/scripts/build/companion_libs/mpfr.sh	2009-10-28
> 11:43:37.000000000 -0700
> +++ crosstool-ng-1.5.1-static/scripts/build/companion_libs/mpfr.sh	2010-01-29
> 00:12:01.000000000 -0800
> @@ -78,6 +78,12 @@
>          *)          mpfr_opt="--enable-thread-safe";;
>      esac
> 
> +    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
> +	mpfr_opt="$mpfr_opt --enable-static"
> +    else
> +	mpfr_opt="$mpfr_opt --disable-static"
> +    fi

Ditto.

Don't take me wrong: I am all for adding the possibility to build static
toolchains, but this not curently possible, most notably because of the
companion libraries... Sigh... :-(

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