Don't start a state restoration if it is not available.
Fortuitly discovered that $SECONDS is inherited from shell to sub-shells. Good!
1 # This file adds the function to build the core gcc C compiler
2 # Copyright 2007 Yann E. MORIN
3 # Licensed under the GPL v2. See COPYING in the root of this package
7 # Ah! gcc folks are kind of 'different': they store the tarballs in
8 # subdirectories of the same name! That's because gcc is such /crap/ that
9 # it is such /big/ that it needs being splitted for distribution! Sad. :-(
10 # Arrgghh! Some of those versions does not follow this convention:
11 # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
12 # subdirectory! You bastard!
13 CT_GetFile "${CT_CC_CORE_FILE}" \
14 ftp://ftp.gnu.org/gnu/gcc/${CT_CC_CORE_FILE} \
15 ftp://ftp.gnu.org/gnu/gcc/releases/${CT_CC_CORE_FILE} \
16 ftp://ftp.gnu.org/gnu/gcc
20 do_cc_core_extract() {
21 CT_ExtractAndPatch "${CT_CC_CORE_FILE}"
26 # In case we're NPTL, build the static core gcc;
27 # in any other case, do nothing.
28 case "${CT_THREADS}" in
29 nptl) do_cc_core_static;;
36 # In case we're NPTL, build the shared core gcc,
37 # in any other case, build the static core gcc.
38 case "${CT_THREADS}" in
39 nptl) do_cc_core_shared;;
40 *) do_cc_core_static;;
44 # Build static core gcc
46 mkdir -p "${CT_BUILD_DIR}/build-cc-core-static"
47 cd "${CT_BUILD_DIR}/build-cc-core-static"
49 CT_DoStep INFO "Installing static core C compiler"
51 CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
52 mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include"
53 cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
55 CT_DoLog EXTRA "Configuring static core C compiler"
58 [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
59 [ -n "${CT_ARCH_ABI}" ] && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
60 [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
61 [ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
62 [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
63 [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
64 [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
66 CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
68 # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
69 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
70 "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/configure" \
73 --target=${CT_TARGET} \
74 --prefix="${CT_CC_CORE_STATIC_PREFIX_DIR}" \
75 --with-local-prefix="${CT_SYSROOT_DIR}" \
78 ${CC_CORE_SYSROOT_ARG} \
82 --enable-symvers=gnu \
83 --enable-languages=c \
85 ${CT_CC_CORE_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
87 if [ "${CT_CANADIAN}" = "y" ]; then
88 CT_DoLog EXTRA "Building libiberty"
89 make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
92 CT_DoLog EXTRA "Building static core C compiler"
93 make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog ALL
95 CT_DoLog EXTRA "Installing static core C compiler"
96 make install-gcc 2>&1 |CT_DoLog ALL
101 # Build shared core gcc
102 do_cc_core_shared() {
103 mkdir -p "${CT_BUILD_DIR}/build-cc-core-shared"
104 cd "${CT_BUILD_DIR}/build-cc-core-shared"
106 CT_DoStep INFO "Installing shared core C compiler"
108 CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
109 mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include"
110 cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
112 CT_DoLog EXTRA "Configuring shared core C compiler"
115 [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
116 [ -n "${CT_ARCH_ABI}" ] && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
117 [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
118 [ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
119 [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
120 [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
121 [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
123 CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
125 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
126 "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/configure" \
128 --target=${CT_TARGET} \
130 --prefix="${CT_CC_CORE_SHARED_PREFIX_DIR}" \
131 --with-local-prefix="${CT_SYSROOT_DIR}" \
133 ${CC_CORE_SYSROOT_ARG} \
136 --enable-symvers=gnu \
137 --enable-languages=c \
139 ${CT_CC_CORE_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
141 # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
142 # gcc/config/t-libunwind so -lc is removed from the link for
143 # libgcc_s.so, as we do not have a target -lc yet.
144 # This is not as ugly as it appears to be ;-) All symbols get resolved
145 # during the glibc build, and we provide a proper libgcc_s.so for the
146 # cross toolchain during the final gcc build.
148 # As we cannot modify the source tree, nor override SHLIB_LC itself
149 # during configure or make, we have to edit the resultant
150 # gcc/libgcc.mk itself to remove -lc from the link.
151 # This causes us to have to jump through some hoops...
153 # To produce libgcc.mk to edit we firstly require libiberty.a,
154 # so we configure then build it.
155 # Next we have to configure gcc, create libgcc.mk then edit it...
156 # So much easier if we just edit the source tree, but hey...
157 if [ ! -f "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/gcc/BASE-VER" ]; then
158 make configure-libiberty
159 make -C libiberty libiberty.a
161 make configure-libcpp
165 make configure-libcpp
166 make configure-build-libiberty
168 make all-build-libiberty
169 fi 2>&1 |CT_DoLog ALL
170 # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
171 if [ -d "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/libdecnumber" ]; then
172 make configure-libdecnumber
173 make -C libdecnumber libdecnumber.a
174 fi 2>&1 |CT_DoLog ALL
175 make -C gcc libgcc.mk 2>&1 |CT_DoLog ALL
176 sed -r -i -e 's@-lc@@g' gcc/libgcc.mk
178 if [ "${CT_CANADIAN}" = "y" ]; then
179 CT_DoLog EXTRA "Building libiberty"
180 make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
183 CT_DoLog EXTRA "Building shared core C compiler"
184 make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog ALL
186 CT_DoLog EXTRA "Installing shared core C compiler"
187 make install-gcc 2>&1 |CT_DoLog ALL