[PATCH 1 of 2] Add support for static toolchains
Bryan Hundven
bryanhundven@gmail.com
Mon Oct 18 21:17:00 GMT 2010
# HG changeset patch
# User Bryan Hundven <bryanhundven@gmail.com>
# Date 1287429308 25200
# Node ID 8091950d99a8b10bbff4b7a35518380afeefc5f6
# Parent 98b7806295cc7be717a01854a24009346c0f4fef
Add support for static toolchains
This commit does not include the statically linked "gcc_core_shared".
That will be in the next commit.
diff -r 98b7806295cc -r 8091950d99a8 config/cc/gcc.in.2
--- a/config/cc/gcc.in.2 Sat Oct 09 23:28:39 2010 +0200
+++ b/config/cc/gcc.in.2 Mon Oct 18 12:15:08 2010 -0700
@@ -41,6 +41,7 @@
prompt "Link libstdc++ statically into the gcc binary"
default y
depends on CC_GCC_4_4_or_later
+ depends on ! STATIC_TOOLCHAIN
help
Newer gcc versions use the PPL library which is C++ code. Statically
linking libstdc++ increases the likeliness that the gcc binary will
diff -r 98b7806295cc -r 8091950d99a8 config/companion_libs.in
--- a/config/companion_libs.in Sat Oct 09 23:28:39 2010 +0200
+++ b/config/companion_libs.in Mon Oct 18 12:15:08 2010 -0700
@@ -141,6 +141,7 @@
prompt "Build shared companion libraries"
default n
depends on COMPLIBS
+ depends on ! STATIC_TOOLCHAIN
select WRAPPER_NEEDED
help
By default, the companion libraries will be build static. If you want to
diff -r 98b7806295cc -r 8091950d99a8 config/debug/gdb.in.cross
--- a/config/debug/gdb.in.cross Sat Oct 09 23:28:39 2010 +0200
+++ b/config/debug/gdb.in.cross Mon Oct 18 12:15:08 2010 -0700
@@ -13,6 +13,7 @@
config GDB_CROSS_STATIC
bool
prompt "Build a static cross gdb"
+ depends on ! STATIC_TOOLCHAIN
default n
help
A static cross gdb can be usefull if you debug on a machine that is
diff -r 98b7806295cc -r 8091950d99a8 config/toolchain.in
--- a/config/toolchain.in Sat Oct 09 23:28:39 2010 +0200
+++ b/config/toolchain.in Mon Oct 18 12:15:08 2010 -0700
@@ -27,6 +27,14 @@
In fact, the sysroot path is constructed as:
${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/sys-root
+
+config STATIC_TOOLCHAIN
+ bool
+ prompt "Build Static Toolchain"
+ depends on EXPERIMENTAL
+ default n
+ help
+ Compile binutils and gcc for the host as static binaries.
comment "Tuple completion and aliasing"
diff -r 98b7806295cc -r 8091950d99a8 scripts/build/binutils/binutils.sh
--- a/scripts/build/binutils/binutils.sh Sat Oct 09 23:28:39 2010 +0200
+++ b/scripts/build/binutils/binutils.sh Mon Oct 18 12:15:08 2010 -0700
@@ -18,6 +18,7 @@
# Build binutils
do_binutils() {
local -a extra_config
+ local -a extra_make_flags
mkdir -p "${CT_BUILD_DIR}/build-binutils"
cd "${CT_BUILD_DIR}/build-binutils"
@@ -40,8 +41,14 @@
${CT_BINUTILS_EXTRA_CONFIG} \
${BINUTILS_SYSROOT_ARG}
+ if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+ extra_make_flags+=("LDFLAGS=-all-static")
+ CT_DoLog EXTRA "Prepare binutils for static build"
+ CT_DoExecLog ALL make configure-host
+ fi
+
CT_DoLog EXTRA "Building binutils"
- CT_DoExecLog ALL make ${PARALLELMFLAGS}
+ CT_DoExecLog ALL make "${extra_make_flags[@]}" ${PARALLELMFLAGS}
CT_DoLog EXTRA "Installing binutils"
CT_DoExecLog ALL make install
diff -r 98b7806295cc -r 8091950d99a8 scripts/build/cc/gcc.sh
--- a/scripts/build/cc/gcc.sh Sat Oct 09 23:28:39 2010 +0200
+++ b/scripts/build/cc/gcc.sh Mon Oct 18 12:15:08 2010 -0700
@@ -305,8 +305,8 @@
# Build final gcc
do_cc() {
local -a extra_config
+ local -a final_LDFLAGS
local tmp
- local final_LDFLAGS
# If building for bare metal, nothing to be done here, the static core conpiler is enough!
[ "${CT_BARE_METAL}" = "y" ] && return 0
@@ -389,11 +389,16 @@
# see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
+ if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+ final_LDFLAGS+=("-static")
+ extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++ -lm")
+ 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
# Ditto libm on some Fedora boxen
- final_LDFLAGS='-lstdc++ -lm'
+ final_LDFLAGS+=("-lstdc++")
+ final_LDFLAGS+=("-lm")
fi
if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
extra_config+=("--with-gmp=${CT_COMPLIBS_DIR}")
@@ -451,7 +456,7 @@
# embedded systems don't really need message catalogs...
CC_FOR_BUILD="${CT_BUILD}-gcc" \
CFLAGS="${CT_CFLAGS_FOR_HOST}" \
- LDFLAGS="${final_LDFLAGS}" \
+ LDFLAGS="${final_LDFLAGS[*]}" \
CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \
diff -r 98b7806295cc -r 8091950d99a8 scripts/build/debug/300-gdb.sh
--- a/scripts/build/debug/300-gdb.sh Sat Oct 09 23:28:39 2010 +0200
+++ b/scripts/build/debug/300-gdb.sh Mon Oct 18 12:15:08 2010 -0700
@@ -101,7 +101,8 @@
CC_for_gdb=
LD_for_gdb=
- if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
+ if [ "${CT_GDB_CROSS_STATIC}" = "y" \
+ -o "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
CC_for_gdb="gcc -static"
LD_for_gdb="ld -static"
fi
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list