Robert P. J. DAY says:
apparently, the patchset for gcc 4.2.1 applies properly to the
source for gcc 4.2.2 and gcc 4.2.3. so, if you want, you can simply
add support for those last two just by augmenting menuconfig and
adding a couple symlinks for those two directories. seems like a
cheap way to add a couple new versions.
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
6 [ "${CT_CC}" = "gcc" ] || return 0
7 echo "gcc-${CT_CC_VERSION}"
12 # Ah! gcc folks are kind of 'different': they store the tarballs in
13 # subdirectories of the same name! That's because gcc is such /crap/ that
14 # it is such /big/ that it needs being splitted for distribution! Sad. :-(
15 # Arrgghh! Some of those versions does not follow this convention:
16 # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
17 # subdirectory! You bastard!
18 CT_GetFile "${CT_CC_FILE}" \
19 ftp://ftp.gnu.org/gnu/gcc/${CT_CC_FILE} \
20 ftp://ftp.gnu.org/gnu/gcc/releases/${CT_CC_FILE} \
21 ftp://ftp.gnu.org/gnu/gcc
26 CT_ExtractAndPatch "${CT_CC_FILE}"
29 #------------------------------------------------------------------------------
32 # In case we're NPTL, build the static core gcc;
33 # in any other case, do nothing.
34 CT_DoStep INFO "Core C compiler, pass 1"
35 case "${CT_THREADS}" in
36 nptl) do_cc_core_static;;
37 *) CT_DoLog INFO "Nothing to do";;
44 # In case we're NPTL, build the shared core gcc,
45 # in any other case, build the static core gcc.
46 CT_DoStep INFO "Core C compiler, pass 2"
47 case "${CT_THREADS}" in
48 nptl) do_cc_core_shared;;
49 *) do_cc_core_static;;
54 #------------------------------------------------------------------------------
55 # Build static core gcc
57 mkdir -p "${CT_BUILD_DIR}/build-cc-core-static"
58 cd "${CT_BUILD_DIR}/build-cc-core-static"
60 CT_DoStep INFO "Installing static core C compiler"
62 CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
63 mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include"
64 cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
66 CT_DoLog EXTRA "Configuring static core C compiler"
68 extra_config="${CT_ARCH_WITH_ARCH} ${CT_ARCH_WITH_ABI} ${CT_ARCH_WITH_CPU} ${CT_ARCH_WITH_TUNE} ${CT_ARCH_WITH_FPU} ${CT_ARCH_WITH_FLOAT}"
69 [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
71 CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
73 # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
74 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
75 "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
78 --target=${CT_TARGET} \
79 --prefix="${CT_CC_CORE_STATIC_PREFIX_DIR}" \
80 --with-local-prefix="${CT_SYSROOT_DIR}" \
83 ${CC_CORE_SYSROOT_ARG} \
87 --enable-symvers=gnu \
88 --enable-languages=c \
90 ${CT_CC_CORE_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
92 if [ "${CT_CANADIAN}" = "y" ]; then
93 CT_DoLog EXTRA "Building libiberty"
94 make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
97 CT_DoLog EXTRA "Building static core C compiler"
98 make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog ALL
100 CT_DoLog EXTRA "Installing static core C compiler"
101 make install-gcc 2>&1 |CT_DoLog ALL
106 #------------------------------------------------------------------------------
107 # Build shared core gcc
108 do_cc_core_shared() {
109 mkdir -p "${CT_BUILD_DIR}/build-cc-core-shared"
110 cd "${CT_BUILD_DIR}/build-cc-core-shared"
112 CT_DoStep INFO "Installing shared core C compiler"
114 CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
115 mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include"
116 cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
118 CT_DoLog EXTRA "Configuring shared core C compiler"
120 extra_config="${CT_ARCH_WITH_ARCH} ${CT_ARCH_WITH_ABI} ${CT_ARCH_WITH_CPU} ${CT_ARCH_WITH_TUNE} ${CT_ARCH_WITH_FPU} ${CT_ARCH_WITH_FLOAT}"
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_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_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_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
192 #------------------------------------------------------------------------------
195 CT_DoStep INFO "Installing final compiler"
197 mkdir -p "${CT_BUILD_DIR}/build-cc"
198 cd "${CT_BUILD_DIR}/build-cc"
200 CT_DoLog EXTRA "Configuring final compiler"
202 # Enable selected languages
204 [ "${CT_CC_LANG_CXX}" = "y" ] && lang_opt="${lang_opt},c++"
205 [ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_opt="${lang_opt},fortran"
206 [ "${CT_CC_LANG_ADA}" = "y" ] && lang_opt="${lang_opt},ada"
207 [ "${CT_CC_LANG_JAVA}" = "y" ] && lang_opt="${lang_opt},java"
208 [ "${CT_CC_LANG_OBJC}" = "y" ] && lang_opt="${lang_opt},objc"
209 [ "${CT_CC_LANG_OBJCXX}" = "y" ] && lang_opt="${lang_opt},obj-c++"
210 CT_Test "Building Fortran language is not yet supported. Will try..." "${CT_CC_LANG_FORTRAN}" = "y"
211 CT_Test "Building ADA language is not yet supported. Will try..." "${CT_CC_LANG_ADA}" = "y"
212 CT_Test "Building Java language is not yet supported. Will try..." "${CT_CC_LANG_JAVA}" = "y"
213 CT_Test "Building Objective-C language is not yet supported. Will try..." "${CT_CC_LANG_OBJC}" = "y"
214 CT_Test "Building Objective-C++ language is not yet supported. Will try..." "${CT_CC_LANG_OBJCXX}" = "y"
215 CT_Test "Building ${CT_CC_LANG_OTHERS} language(s) is not yet supported. Will try..." -n "${CT_CC_LANG_OTHERS}"
216 lang_opt=`echo "${lang_opt},${CT_CC_LANG_OTHERS}" |sed -r -e 's/,+/,/g; s/,*$//;'`
218 extra_config="--enable-languages=${lang_opt}"
219 extra_config="${extra_config} ${CT_ARCH_WITH_ARCH} ${CT_ARCH_WITH_ABI} ${CT_ARCH_WITH_CPU} ${CT_ARCH_WITH_TUNE} ${CT_ARCH_WITH_FPU} ${CT_ARCH_WITH_FLOAT}"
220 [ "${CT_SHARED_LIBS}" = "y" ] || extra_config="${extra_config} --disable-shared"
221 [ "${CT_CC_CXA_ATEXIT}" == "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
222 if [ "${CT_TARGET_MULTILIB}" = "y" ]; then
223 extra_config="${extra_config} --enable-multilib"
225 extra_config="${extra_config} --disable-multilib"
228 CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
230 # --enable-symvers=gnu really only needed for sh4 to work around a
231 # detection problem only matters for gcc-3.2.x and later, I think.
232 # --disable-nls to work around crash bug on ppc405, but also because
233 # embedded systems don't really need message catalogs...
234 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
235 TARGET_CFLAGS="${CT_TARGET_CFLAGS}" \
236 "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
238 --target=${CT_TARGET} --host=${CT_HOST} \
239 --prefix="${CT_PREFIX_DIR}" \
242 --with-local-prefix="${CT_SYSROOT_DIR}" \
244 --enable-threads=posix \
245 --enable-symvers=gnu \
248 ${CT_CC_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
250 if [ "${CT_CANADIAN}" = "y" ]; then
251 CT_DoLog EXTRA "Building libiberty"
252 make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
255 # Idea from <cort.dougan at gmail.com>:
256 # Fix lib/lib64 confusion for GCC 3.3.3 on PowerPC64 and x86_64.
257 # GCC 3.4.0 and up don't suffer from this confusion, and don't need this
259 # FIXME: we should patch gcc's source rather than uglify crosstool.sh.
260 # FIXME: is this needed for gcc-3.3.[56]?
261 case "${CT_CC_FILE}" in
263 case "${CT_TARGET}" in
264 powerpc64-unknown-linux-gnu|x86_64-unknown-linux-gnu)
265 for d in `find "${CT_SYSROOT_DIR}" -name lib -type d -empty`; do
266 if [ -d `dirname "${d}"`/lib64 ] ; then
268 ln -s `dirname "${d}"`/lib64 "${d}"
275 CT_DoLog EXTRA "Building final compiler"
276 make ${PARALLELMFLAGS} all 2>&1 |CT_DoLog ALL
278 CT_DoLog EXTRA "Installing final compiler"
279 make install 2>&1 |CT_DoLog ALL
281 # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-gcc to always be able
282 # to call the C compiler with the same, somewhat canonical name.
283 ln "${CT_PREFIX_DIR}/bin/${CT_TARGET}"-{g,}cc
285 # gcc installs stuff in prefix/target/lib, when it would make better sense
286 # to install that into sysroot/usr/lib
287 CT_DoLog EXTRA "Moving improperly installed gcc libs to sysroot"
288 ( cd "${CT_PREFIX_DIR}/${CT_TARGET}/lib"; tar cf - . ) | ( cd "${CT_SYSROOT_DIR}/usr/lib"; tar xfv - )