Add support for building toolchains with gcc-4.4 snapshots.
Initial patch by Dmitry PLOTNIKOV: http://sourceware.org/ml/crossgcc/2009-03/msg00053.html
It [the toolchain] uses current ct-ng (nightly snapshot 20090324, latest
release 1.3.2 work also), glibc 2.9 (from CVS), binutils 2.19 and latest
snapshot of GCC 4.4.0 (as of March 20, 2009).
We have successfully built linux kernel 2.6.29 and a lot of other stuff
with this toolchain.
Here's the patch that adds GCC 4.4.0 to the ct-ng menu and enables it to
download a 4.4.0 snapshot from ftp.
Patch was adpated by me, mostly to better fit the configuration layout.
/trunk/scripts/build/cc/gcc.sh | 34 22 12 0 ++++++++++++++++++++++------------
/trunk/config/cc/gcc.in | 35 30 5 0 ++++++++++++++++++++++++++++++-----
2 files changed, 52 insertions(+), 17 deletions(-)
1 # This file adds the function to build the gcc C compiler
2 # Copyright 2007 Yann E. MORIN
3 # Licensed under the GPL v2. See COPYING in the root of this package
7 local version="${CT_CC_VERSION}${CT_CC_GCC_4_4_snapshot_date}"
9 # Ah! gcc folks are kind of 'different': they store the tarballs in
10 # subdirectories of the same name! That's because gcc is such /crap/ that
11 # it is such /big/ that it needs being splitted for distribution! Sad. :-(
12 # Arrgghh! Some of those versions does not follow this convention:
13 # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
14 # subdirectory! You bastard!
15 CT_GetFile "gcc-${version}" \
16 {ftp,http}://ftp.gnu.org/gnu/gcc{,{,/releases}/gcc-${version}} \
17 ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/releases/gcc-${version} \
18 ftp://ftp.uvsq.fr/pub/gcc/snapshots/${version}
20 # Starting with GCC 4.3, ecj is used for Java, and will only be
21 # built if the configure script finds ecj.jar at the top of the
22 # GCC source tree, which will not be there unless we get it and
23 # put it there ourselves
24 if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then
25 CT_GetFile ecj-latest .jar ftp://gcc.gnu.org/pub/java \
26 ftp://sourceware.org/pub/java
32 local version="${CT_CC_VERSION}${CT_CC_GCC_4_4_snapshot_date}"
34 CT_Extract "gcc-${version}"
35 CT_Patch "gcc-${version}"
37 # Copy ecj-latest.jar to ecj.jar at the top of the GCC source tree
38 if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" \
39 -a ! -f "${CT_SRC_DIR}/gcc-${version}/ecj.jar" \
41 CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${version}/ecj.jar"
45 #------------------------------------------------------------------------------
48 # If we're building for bare metal, build the static core gcc,
50 # In case we're not bare metal, and we're NPTL, build the static core gcc.
51 # In any other case, do nothing.
52 case "${CT_BARE_METAL},${CT_THREADS}" in
53 y,*) do_cc_core mode=baremetal build_libgcc=yes;;
54 ,nptl) do_cc_core mode=static build_libgcc=no;;
61 # In case we're building for bare metal, do nothing, we already have
63 # In case we're NPTL, build the shared core gcc and the target libgcc.
64 # In any other case, build the static core gcc and, if using gcc-4.3+,
65 # also build the target libgcc.
66 case "${CT_BARE_METAL},${CT_THREADS}" in
69 do_cc_core mode=shared build_libgcc=yes
71 *) if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
72 do_cc_core mode=static build_libgcc=yes
74 do_cc_core mode=static build_libgcc=no
80 #------------------------------------------------------------------------------
82 # This function is used to build both the static and the shared core C conpiler,
83 # with or without the target libgcc. We need to know wether:
84 # - we're building static, shared or bare metal: mode=[static|shared|baremetal]
85 # - we need to build libgcc or not : build_libgcc=[yes|no]
86 # Usage: do_cc_core_static mode=[static|shared|baremetal] build_libgcc=[yes|no]
93 local version="${CT_CC_VERSION}${CT_CC_GCC_4_4_snapshot_date}"
97 CT_TestOrAbort "Internal Error: 'mode' must either 'static', 'shared' or 'baremetal', not '${mode:-(empty)}'" "${mode}" = "static" -o "${mode}" = "shared" -o "${mode}" = "baremetal"
98 CT_TestOrAbort "Internal Error: 'build_libgcc' must be either 'yes' or 'no', not '${build_libgcc:-(empty)}'" "${build_libgcc}" = "yes" -o "${build_libgcc}" = "no"
99 # In normal conditions, ( "${mode}" = "shared" ) implies
100 # ( "${build_libgcc}" = "yes" ), but I won't check for that
102 CT_DoStep INFO "Installing ${mode} core C compiler"
103 mkdir -p "${CT_BUILD_DIR}/build-cc-core-${mode}"
104 cd "${CT_BUILD_DIR}/build-cc-core-${mode}"
109 core_prefix_dir="${CT_CC_CORE_STATIC_PREFIX_DIR}"
110 extra_config="${extra_config} --with-newlib --enable-threads=no --disable-shared"
114 core_prefix_dir="${CT_CC_CORE_SHARED_PREFIX_DIR}"
115 extra_config="${extra_config} --enable-shared"
119 core_prefix_dir="${CT_PREFIX_DIR}"
120 extra_config="${extra_config} --with-newlib --enable-threads=no --disable-shared"
121 [ "${CT_CC_LANG_CXX}" = "y" ] && lang_opt="${lang_opt},c++"
126 if [ "${copy_headers}" = "y" ]; then
127 CT_DoLog DEBUG "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
128 CT_DoExecLog ALL mkdir -p "${core_prefix_dir}/${CT_TARGET}/include"
129 CT_DoExecLog ALL cp -r "${CT_HEADERS_DIR}"/* "${core_prefix_dir}/${CT_TARGET}/include"
132 CT_DoLog EXTRA "Configuring ${mode} core C compiler"
134 extra_config="${extra_config} ${CT_ARCH_WITH_ARCH}"
135 extra_config="${extra_config} ${CT_ARCH_WITH_ABI}"
136 extra_config="${extra_config} ${CT_ARCH_WITH_CPU}"
137 extra_config="${extra_config} ${CT_ARCH_WITH_TUNE}"
138 extra_config="${extra_config} ${CT_ARCH_WITH_FPU}"
139 extra_config="${extra_config} ${CT_ARCH_WITH_FLOAT}"
140 [ "${CT_GMP_MPFR}" = "y" ] && extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
141 if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
142 extra_config="${extra_config} --enable-__cxa_atexit"
144 extra_config="${extra_config} --disable-__cxa_atexit"
147 CT_DoLog DEBUG "Extra config passed: '${extra_config}'"
149 # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
150 CC_FOR_BUILD="${CT_BUILD}-gcc" \
151 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
153 "${CT_SRC_DIR}/gcc-${version}/configure" \
154 --build=${CT_BUILD} \
156 --target=${CT_TARGET} \
157 --prefix="${core_prefix_dir}" \
158 --with-local-prefix="${CT_SYSROOT_DIR}" \
160 ${CC_CORE_SYSROOT_ARG} \
163 --enable-symvers=gnu \
164 --enable-languages="${lang_opt}" \
165 --enable-target-optspace \
166 ${CT_CC_CORE_EXTRA_CONFIG}
168 if [ "${build_libgcc}" = "yes" ]; then
169 # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
170 # gcc/config/t-libunwind so -lc is removed from the link for
171 # libgcc_s.so, as we do not have a target -lc yet.
172 # This is not as ugly as it appears to be ;-) All symbols get resolved
173 # during the glibc build, and we provide a proper libgcc_s.so for the
174 # cross toolchain during the final gcc build.
176 # As we cannot modify the source tree, nor override SHLIB_LC itself
177 # during configure or make, we have to edit the resultant
178 # gcc/libgcc.mk itself to remove -lc from the link.
179 # This causes us to have to jump through some hoops...
181 # To produce libgcc.mk to edit we firstly require libiberty.a,
182 # so we configure then build it.
183 # Next we have to configure gcc, create libgcc.mk then edit it...
184 # So much easier if we just edit the source tree, but hey...
185 if [ ! -f "${CT_SRC_DIR}/gcc-${version}/gcc/BASE-VER" ]; then
186 CT_DoExecLog ALL make configure-libiberty
187 CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libiberty libiberty.a
188 CT_DoExecLog ALL make configure-gcc configure-libcpp
189 CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp
191 CT_DoExecLog ALL make configure-gcc configure-libcpp configure-build-libiberty
192 CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp all-build-libiberty
194 # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
195 if [ -d "${CT_SRC_DIR}/gcc-${version}/libdecnumber" ]; then
196 CT_DoExecLog ALL make configure-libdecnumber
197 CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libdecnumber libdecnumber.a
200 # Starting with GCC 4.3, libgcc.mk is no longer built,
201 # and libgcc.mvars is used instead.
203 if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
204 libgcc_rule="libgcc.mvars"
205 build_rules="all-gcc all-target-libgcc"
206 install_rules="install-gcc install-target-libgcc"
208 libgcc_rule="libgcc.mk"
209 build_rules="all-gcc"
210 install_rules="install-gcc"
213 CT_DoExecLog ALL make ${PARALLELMFLAGS} -C gcc ${libgcc_rule}
214 sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
216 build_rules="all-gcc"
217 install_rules="install-gcc"
220 if [ "${CT_CANADIAN}" = "y" ]; then
221 CT_DoLog EXTRA "Building libiberty"
222 CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
225 CT_DoLog EXTRA "Building ${mode} core C compiler"
226 CT_DoExecLog ALL make ${PARALLELMFLAGS} ${build_rules}
228 CT_DoLog EXTRA "Installing ${mode} core C compiler"
229 CT_DoExecLog ALL make ${install_rules}
234 #------------------------------------------------------------------------------
237 local version="${CT_CC_VERSION}${CT_CC_GCC_4_4_snapshot_date}"
239 # If building for bare metal, nothing to be done here, the static core conpiler is enough!
240 [ "${CT_BARE_METAL}" = "y" ] && return 0
242 CT_DoStep INFO "Installing final compiler"
244 mkdir -p "${CT_BUILD_DIR}/build-cc"
245 cd "${CT_BUILD_DIR}/build-cc"
247 CT_DoLog EXTRA "Configuring final compiler"
249 # Enable selected languages
251 [ "${CT_CC_LANG_CXX}" = "y" ] && lang_opt="${lang_opt},c++"
252 [ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_opt="${lang_opt},fortran"
253 [ "${CT_CC_LANG_ADA}" = "y" ] && lang_opt="${lang_opt},ada"
254 [ "${CT_CC_LANG_JAVA}" = "y" ] && lang_opt="${lang_opt},java"
255 [ "${CT_CC_LANG_OBJC}" = "y" ] && lang_opt="${lang_opt},objc"
256 [ "${CT_CC_LANG_OBJCXX}" = "y" ] && lang_opt="${lang_opt},obj-c++"
257 CT_Test "Building ADA language is not yet supported. Will try..." "${CT_CC_LANG_ADA}" = "y"
258 CT_Test "Building Objective-C language is not yet supported. Will try..." "${CT_CC_LANG_OBJC}" = "y"
259 CT_Test "Building Objective-C++ language is not yet supported. Will try..." "${CT_CC_LANG_OBJCXX}" = "y"
260 CT_Test "Building ${CT_CC_LANG_OTHERS//,/ } language(s) is not yet supported. Will try..." -n "${CT_CC_LANG_OTHERS}"
261 lang_opt=$(echo "${lang_opt},${CT_CC_LANG_OTHERS}" |sed -r -e 's/,+/,/g; s/,*$//;')
263 extra_config="--enable-languages=${lang_opt}"
264 extra_config="${extra_config} --disable-multilib"
265 extra_config="${extra_config} ${CT_ARCH_WITH_ARCH}"
266 extra_config="${extra_config} ${CT_ARCH_WITH_ABI}"
267 extra_config="${extra_config} ${CT_ARCH_WITH_CPU}"
268 extra_config="${extra_config} ${CT_ARCH_WITH_TUNE}"
269 extra_config="${extra_config} ${CT_ARCH_WITH_FPU}"
270 extra_config="${extra_config} ${CT_ARCH_WITH_FLOAT}"
271 [ "${CT_SHARED_LIBS}" = "y" ] || extra_config="${extra_config} --disable-shared"
272 [ "${CT_GMP_MPFR}" = "y" ] && extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
273 [ -n "${CT_CC_PKGVERSION}" ] && extra_config="${extra_config} --with-pkgversion=${CT_CC_PKGVERSION}"
274 [ -n "${CT_CC_BUGURL}" ] && extra_config="${extra_config} --with-bugurl=${CT_CC_BUGURL}"
275 [ "${CT_CC_SJLJ_EXCEPTIONS_USE}" = "y" ] && extra_config="${extra_config} --enable-sjlj-exceptions"
276 [ "${CT_CC_SJLJ_EXCEPTIONS_DONT_USE}" = "y" ] && extra_config="${extra_config} --disable-sjlj-exceptions"
277 if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
278 extra_config="${extra_config} --enable-__cxa_atexit"
280 extra_config="${extra_config} --disable-__cxa_atexit"
283 CT_DoLog DEBUG "Extra config passed: '${extra_config}'"
285 # --enable-symvers=gnu really only needed for sh4 to work around a
286 # detection problem only matters for gcc-3.2.x and later, I think.
287 # --disable-nls to work around crash bug on ppc405, but also because
288 # embedded systems don't really need message catalogs...
289 CC_FOR_BUILD="${CT_BUILD}-gcc" \
290 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
291 CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
292 CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
293 LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \
295 "${CT_SRC_DIR}/gcc-${version}/configure" \
296 --build=${CT_BUILD} \
298 --target=${CT_TARGET} \
299 --prefix="${CT_PREFIX_DIR}" \
302 --with-local-prefix="${CT_SYSROOT_DIR}" \
304 --enable-threads=posix \
305 --enable-symvers=gnu \
308 --enable-target-optspace \
309 ${CT_CC_EXTRA_CONFIG}
311 if [ "${CT_CANADIAN}" = "y" ]; then
312 CT_DoLog EXTRA "Building libiberty"
313 CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
316 CT_DoLog EXTRA "Building final compiler"
317 CT_DoExecLog ALL make ${PARALLELMFLAGS} all
319 CT_DoLog EXTRA "Installing final compiler"
320 CT_DoExecLog ALL make install
322 # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-gcc to always be able
323 # to call the C compiler with the same, somewhat canonical name.
324 CT_DoExecLog ALL ln -sv "${CT_TARGET}"-gcc "${CT_PREFIX_DIR}/bin/${CT_TARGET}"-cc