Be alittle less verbose in the core CC pass 1 & 2.
/trunk/scripts/build/cc_gcc.sh | 5 0 5 0 -----
1 file changed, 5 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
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 case "${CT_THREADS}" in
35 nptl) do_cc_core_static;;
41 # In case we're NPTL, build the shared core gcc,
42 # in any other case, build the static core gcc.
43 case "${CT_THREADS}" in
44 nptl) do_cc_core_shared;;
45 *) do_cc_core_static;;
49 #------------------------------------------------------------------------------
50 # Build static core gcc
52 mkdir -p "${CT_BUILD_DIR}/build-cc-core-static"
53 cd "${CT_BUILD_DIR}/build-cc-core-static"
55 CT_DoStep INFO "Installing static core C compiler"
57 CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
58 mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include"
59 cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
61 CT_DoLog EXTRA "Configuring static core C compiler"
63 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}"
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_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 #------------------------------------------------------------------------------
102 # Build shared core gcc
103 do_cc_core_shared() {
104 mkdir -p "${CT_BUILD_DIR}/build-cc-core-shared"
105 cd "${CT_BUILD_DIR}/build-cc-core-shared"
107 CT_DoStep INFO "Installing shared core C compiler"
109 CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
110 mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include"
111 cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
113 CT_DoLog EXTRA "Configuring shared core C compiler"
115 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}"
116 [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
118 CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
120 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
121 "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
123 --target=${CT_TARGET} \
125 --prefix="${CT_CC_CORE_SHARED_PREFIX_DIR}" \
126 --with-local-prefix="${CT_SYSROOT_DIR}" \
128 ${CC_CORE_SYSROOT_ARG} \
131 --enable-symvers=gnu \
132 --enable-languages=c \
134 ${CT_CC_CORE_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
136 # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
137 # gcc/config/t-libunwind so -lc is removed from the link for
138 # libgcc_s.so, as we do not have a target -lc yet.
139 # This is not as ugly as it appears to be ;-) All symbols get resolved
140 # during the glibc build, and we provide a proper libgcc_s.so for the
141 # cross toolchain during the final gcc build.
143 # As we cannot modify the source tree, nor override SHLIB_LC itself
144 # during configure or make, we have to edit the resultant
145 # gcc/libgcc.mk itself to remove -lc from the link.
146 # This causes us to have to jump through some hoops...
148 # To produce libgcc.mk to edit we firstly require libiberty.a,
149 # so we configure then build it.
150 # Next we have to configure gcc, create libgcc.mk then edit it...
151 # So much easier if we just edit the source tree, but hey...
152 if [ ! -f "${CT_SRC_DIR}/${CT_CC_FILE}/gcc/BASE-VER" ]; then
153 make configure-libiberty
154 make -C libiberty libiberty.a
156 make configure-libcpp
160 make configure-libcpp
161 make configure-build-libiberty
163 make all-build-libiberty
164 fi 2>&1 |CT_DoLog ALL
165 # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
166 if [ -d "${CT_SRC_DIR}/${CT_CC_FILE}/libdecnumber" ]; then
167 make configure-libdecnumber
168 make -C libdecnumber libdecnumber.a
169 fi 2>&1 |CT_DoLog ALL
170 make -C gcc libgcc.mk 2>&1 |CT_DoLog ALL
171 sed -r -i -e 's@-lc@@g' gcc/libgcc.mk
173 if [ "${CT_CANADIAN}" = "y" ]; then
174 CT_DoLog EXTRA "Building libiberty"
175 make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
178 CT_DoLog EXTRA "Building shared core C compiler"
179 make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog ALL
181 CT_DoLog EXTRA "Installing shared core C compiler"
182 make install-gcc 2>&1 |CT_DoLog ALL
187 #------------------------------------------------------------------------------
190 CT_DoStep INFO "Installing final compiler"
192 mkdir -p "${CT_BUILD_DIR}/build-cc"
193 cd "${CT_BUILD_DIR}/build-cc"
195 CT_DoLog EXTRA "Configuring final compiler"
197 # Enable selected languages
199 [ "${CT_CC_LANG_CXX}" = "y" ] && lang_opt="${lang_opt},c++"
200 [ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_opt="${lang_opt},fortran"
201 [ "${CT_CC_LANG_ADA}" = "y" ] && lang_opt="${lang_opt},ada"
202 [ "${CT_CC_LANG_JAVA}" = "y" ] && lang_opt="${lang_opt},java"
203 [ "${CT_CC_LANG_OBJC}" = "y" ] && lang_opt="${lang_opt},objc"
204 [ "${CT_CC_LANG_OBJCXX}" = "y" ] && lang_opt="${lang_opt},obj-c++"
205 CT_Test "Building Fortran language is not yet supported. Will try..." "${CT_CC_LANG_FORTRAN}" = "y"
206 CT_Test "Building ADA language is not yet supported. Will try..." "${CT_CC_LANG_ADA}" = "y"
207 CT_Test "Building Java language is not yet supported. Will try..." "${CT_CC_LANG_JAVA}" = "y"
208 CT_Test "Building Objective-C language is not yet supported. Will try..." "${CT_CC_LANG_OBJC}" = "y"
209 CT_Test "Building Objective-C++ language is not yet supported. Will try..." "${CT_CC_LANG_OBJCXX}" = "y"
210 CT_Test "Building ${CT_CC_LANG_OTHERS} language(s) is not yet supported. Will try..." -n "${CT_CC_LANG_OTHERS}"
211 lang_opt=`echo "${lang_opt},${CT_CC_LANG_OTHERS}" |sed -r -e 's/,+/,/g; s/,*$//;'`
213 extra_config="--enable-languages=${lang_opt}"
214 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}"
215 [ "${CT_SHARED_LIBS}" = "y" ] || extra_config="${extra_config} --disable-shared"
216 [ "${CT_CC_CXA_ATEXIT}" == "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
217 if [ "${CT_TARGET_MULTILIB}" = "y" ]; then
218 extra_config="${extra_config} --enable-multilib"
220 extra_config="${extra_config} --disable-multilib"
223 CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
225 # --enable-symvers=gnu really only needed for sh4 to work around a
226 # detection problem only matters for gcc-3.2.x and later, I think.
227 # --disable-nls to work around crash bug on ppc405, but also because
228 # embedded systems don't really need message catalogs...
229 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
230 TARGET_CFLAGS="${CT_TARGET_CFLAGS}" \
231 "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
233 --target=${CT_TARGET} --host=${CT_HOST} \
234 --prefix="${CT_PREFIX_DIR}" \
237 --with-local-prefix="${CT_SYSROOT_DIR}" \
239 --enable-threads=posix \
240 --enable-symvers=gnu \
243 ${CT_CC_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
245 if [ "${CT_CANADIAN}" = "y" ]; then
246 CT_DoLog EXTRA "Building libiberty"
247 make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
250 # Idea from <cort.dougan at gmail.com>:
251 # Fix lib/lib64 confusion for GCC 3.3.3 on PowerPC64 and x86_64.
252 # GCC 3.4.0 and up don't suffer from this confusion, and don't need this
254 # FIXME: we should patch gcc's source rather than uglify crosstool.sh.
255 # FIXME: is this needed for gcc-3.3.[56]?
256 case "${CT_CC_FILE}" in
258 case "${CT_TARGET}" in
259 powerpc64-unknown-linux-gnu|x86_64-unknown-linux-gnu)
260 for d in `find "${CT_SYSROOT_DIR}" -name lib -type d -empty`; do
261 if [ -d `dirname "${d}"`/lib64 ] ; then
263 ln -s `dirname "${d}"`/lib64 "${d}"
270 CT_DoLog EXTRA "Building final compiler"
271 make ${PARALLELMFLAGS} all 2>&1 |CT_DoLog ALL
273 CT_DoLog EXTRA "Installing final compiler"
274 make install 2>&1 |CT_DoLog ALL
276 # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-gcc to always be able
277 # to call the C compiler with the same, somewhat canonical name.
278 ln "${CT_PREFIX_DIR}/bin/${CT_TARGET}"-{g,}cc
280 # gcc installs stuff in prefix/target/lib, when it would make better sense
281 # to install that into sysroot/usr/lib
282 CT_DoLog EXTRA "Moving improperly installed gcc libs to sysroot"
283 ( cd "${CT_PREFIX_DIR}/${CT_TARGET}/lib"; tar cf - . ) | ( cd "${CT_SYSROOT_DIR}/usr/lib"; tar xfv - )