public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0 of 1] Static gcc/binutils
@ 2010-02-07  5:23 Josh Henderson
  2010-02-16 18:04 ` Yann E. MORIN
  0 siblings, 1 reply; 2+ messages in thread
From: Josh Henderson @ 2010-02-07  5:23 UTC (permalink / raw)
  To: yann.morin.1998; +Cc: crossgcc

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.  zlib added
because most distributions do not include a static zlib.

Signed-Off by Joshua Henderson <digitalpeer@digitalpeer.com>


diff -Naur crosstool-ng-1.5.1/config/companion_libs/zlib.in
crosstool-ng-1.5.1-static/config/companion_libs/zlib.in
--- crosstool-ng-1.5.1/config/companion_libs/zlib.in	1969-12-31
16:00:00.000000000 -0800
+++ crosstool-ng-1.5.1-static/config/companion_libs/zlib.in	2010-01-26
21:38:43.000000000 -0800
@@ -0,0 +1,19 @@
+# ZLIB options
+
+choice
+    bool
+    prompt "ZLIB version"
+# Don't remove next line
+# CT_INSERT_VERSION_BELOW
+
+config ZLIB_V_1_2_3
+    bool
+    prompt "1.2.3"
+
+endchoice
+
+config ZLIB_VERSION
+    string
+# Don't remove next line
+# CT_INSERT_VERSION_STRING_BELOW
+    default "1.2.3" if ZLIB_V_1_2_3
diff -Naur crosstool-ng-1.5.1/config/companion_libs.in
crosstool-ng-1.5.1-static/config/companion_libs.in
--- crosstool-ng-1.5.1/config/companion_libs.in	2009-10-28
11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/config/companion_libs.in	2010-01-26
21:44:03.000000000 -0800
@@ -30,6 +30,16 @@
 source config/companion_libs/mpfr.in
 endif

+config ZLIB
+    bool
+    prompt "ZLIB"
+    help
+      zlib
+
+if ZLIB
+source config/companion_libs/zlib.in
+endif
+
 config PPL_CLOOG_MPC
     bool
     prompt "PPL, GLooG/PPL and MPC"
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.
+
 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"
+    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}
+
     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
+
     CT_DoLog EXTRA "Configuring GMP"

     CFLAGS="${CT_CFLAGS_FOR_HOST} -fexceptions"     \
@@ -36,8 +43,8 @@
         --build=${CT_BUILD}                         \
         --host=${CT_HOST}                           \
         --prefix="${CT_PREFIX_DIR}"                 \
+        ${gmp_opt}                                  \
         --enable-shared                             \
-        --disable-static                            \
         --enable-fft                                \
         --enable-mpbsd                              \
         --enable-cxx
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
+
     CT_DoLog EXTRA "Configuring MPFR"
     CC="${CT_HOST}-gcc"                                 \
     CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
@@ -88,7 +94,6 @@
         --prefix="${CT_PREFIX_DIR}"                     \
         ${mpfr_opt}                                     \
         --enable-shared                                 \
-        --disable-static                                \
         --with-gmp="${CT_PREFIX_DIR}"

     CT_DoLog EXTRA "Building MPFR"
diff -Naur crosstool-ng-1.5.1/scripts/build/companion_libs/zlib.sh
crosstool-ng-1.5.1-static/scripts/build/companion_libs/zlib.sh
--- crosstool-ng-1.5.1/scripts/build/companion_libs/zlib.sh	1969-12-31
16:00:00.000000000 -0800
+++ crosstool-ng-1.5.1-static/scripts/build/companion_libs/zlib.sh	2010-01-26
22:10:15.000000000 -0800
@@ -0,0 +1,45 @@
+# This file adds the functions to build the ZLIB library
+# Copyright 2009 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+do_zlib_get() { :; }
+do_zlib_extract() { :; }
+do_zlib() { :; }
+do_zlib_target() { :; }
+
+# Overide functions depending on configuration
+if [ "${CT_ZLIB}" = "y" ]; then
+
+# Download ZLIB
+do_zlib_get() {
+    CT_GetFile "zlib-${CT_ZLIB_VERSION}" .tar.bz2 http://www.zlib.net/
+}
+
+# Extract ZLIB
+do_zlib_extract() {
+    CT_Extract "zlib-${CT_ZLIB_VERSION}"
+    CT_Patch "zlib-${CT_ZLIB_VERSION}"
+}
+
+do_zlib() {
+    cd "${CT_SRC_DIR}/zlib-${CT_ZLIB_VERSION}/"
+
+    CT_DoStep INFO "Installing ZLIB"
+
+    CT_DoLog EXTRA "Configuring ZLIB"
+    CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
+    CXXFLAGS="${CT_CFLAGS_FOR_HOST}"                \
+    CT_DoExecLog ALL                                \
+    "./configure" \
+        --prefix="${CT_PREFIX_DIR}"
+
+    CT_DoLog EXTRA "Building ZLIB"
+    CT_DoExecLog ALL make ${PARALLELMFLAGS}
+
+    CT_DoLog EXTRA "Installing ZLIB"
+    CT_DoExecLog ALL make install
+
+    CT_EndStep
+}
+
+fi # CT_ZLIB
diff -Naur crosstool-ng-1.5.1/scripts/crosstool-NG.sh.in
crosstool-ng-1.5.1-static/scripts/crosstool-NG.sh.in
--- crosstool-ng-1.5.1/scripts/crosstool-NG.sh.in	2009-10-28
11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/scripts/crosstool-NG.sh.in	2010-01-26
21:53:02.000000000 -0800
@@ -120,6 +120,7 @@
 . "${CT_LIB_DIR}/scripts/build/companion_libs/ppl.sh"
 . "${CT_LIB_DIR}/scripts/build/companion_libs/cloog.sh"
 . "${CT_LIB_DIR}/scripts/build/companion_libs/mpc.sh"
+. "${CT_LIB_DIR}/scripts/build/companion_libs/zlib.sh"
 . "${CT_LIB_DIR}/scripts/build/binutils/binutils.sh"
 . "${CT_LIB_DIR}/scripts/build/binutils/elf2flt.sh"
 . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
@@ -491,6 +492,7 @@
     do_ppl_get
     do_cloog_get
     do_mpc_get
+    do_zlib_get
     do_binutils_get
     do_cc_get
     do_libc_get
@@ -510,6 +512,7 @@
         do_ppl_extract
         do_cloog_extract
         do_mpc_extract
+        do_zlib_extract
         do_binutils_extract
         do_cc_extract
         do_libc_extract
diff -Naur crosstool-ng-1.5.1/steps.mk crosstool-ng-1.5.1-static/steps.mk
--- crosstool-ng-1.5.1/steps.mk	2009-10-28 11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/steps.mk	2010-01-26 21:58:20.000000000 -0800
@@ -23,6 +23,7 @@
             ppl                 \
             cloog               \
             mpc                 \
+            zlib                \
             binutils            \
             elf2flt             \
             cc_core_pass_1      \

--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

* Re: [PATCH 0 of 1] Static gcc/binutils
  2010-02-07  5:23 [PATCH 0 of 1] Static gcc/binutils Josh Henderson
@ 2010-02-16 18:04 ` Yann E. MORIN
  0 siblings, 0 replies; 2+ messages in thread
From: Yann E. MORIN @ 2010-02-16 18:04 UTC (permalink / raw)
  To: crossgcc; +Cc: Josh Henderson

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

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

end of thread, other threads:[~2010-02-16 18:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-07  5:23 [PATCH 0 of 1] Static gcc/binutils Josh Henderson
2010-02-16 18:04 ` Yann E. MORIN

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).