Offer an option to build the gdbserver statically. This helps in case of debugging shared library loading.
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
6 [ "${CT_CC_CORE}" = "gcc" ] || return 0
7 echo "gcc-${CT_CC_CORE_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_CORE_FILE}" \
19 ftp://ftp.gnu.org/gnu/gcc/${CT_CC_CORE_FILE} \
20 ftp://ftp.gnu.org/gnu/gcc/releases/${CT_CC_CORE_FILE} \
21 ftp://ftp.gnu.org/gnu/gcc
25 do_cc_core_extract() {
26 CT_ExtractAndPatch "${CT_CC_CORE_FILE}"
31 # In case we're NPTL, build the static core gcc;
32 # in any other case, do nothing.
33 case "${CT_THREADS}" in
34 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 # Build static core gcc
51 mkdir -p "${CT_BUILD_DIR}/build-cc-core-static"
52 cd "${CT_BUILD_DIR}/build-cc-core-static"
54 CT_DoStep INFO "Installing static core C compiler"
56 CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
57 mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include"
58 cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
60 CT_DoLog EXTRA "Configuring static core C compiler"
63 [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
64 [ -n "${CT_ARCH_ABI}" ] && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
65 [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
66 [ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
67 [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
68 [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
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_CORE_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 # Build shared core gcc
107 do_cc_core_shared() {
108 mkdir -p "${CT_BUILD_DIR}/build-cc-core-shared"
109 cd "${CT_BUILD_DIR}/build-cc-core-shared"
111 CT_DoStep INFO "Installing shared core C compiler"
113 CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
114 mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include"
115 cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
117 CT_DoLog EXTRA "Configuring shared core C compiler"
120 [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
121 [ -n "${CT_ARCH_ABI}" ] && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
122 [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
123 [ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
124 [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
125 [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
126 [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
128 CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
130 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
131 "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/configure" \
133 --target=${CT_TARGET} \
135 --prefix="${CT_CC_CORE_SHARED_PREFIX_DIR}" \
136 --with-local-prefix="${CT_SYSROOT_DIR}" \
138 ${CC_CORE_SYSROOT_ARG} \
141 --enable-symvers=gnu \
142 --enable-languages=c \
144 ${CT_CC_CORE_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
146 # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
147 # gcc/config/t-libunwind so -lc is removed from the link for
148 # libgcc_s.so, as we do not have a target -lc yet.
149 # This is not as ugly as it appears to be ;-) All symbols get resolved
150 # during the glibc build, and we provide a proper libgcc_s.so for the
151 # cross toolchain during the final gcc build.
153 # As we cannot modify the source tree, nor override SHLIB_LC itself
154 # during configure or make, we have to edit the resultant
155 # gcc/libgcc.mk itself to remove -lc from the link.
156 # This causes us to have to jump through some hoops...
158 # To produce libgcc.mk to edit we firstly require libiberty.a,
159 # so we configure then build it.
160 # Next we have to configure gcc, create libgcc.mk then edit it...
161 # So much easier if we just edit the source tree, but hey...
162 if [ ! -f "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/gcc/BASE-VER" ]; then
163 make configure-libiberty
164 make -C libiberty libiberty.a
166 make configure-libcpp
170 make configure-libcpp
171 make configure-build-libiberty
173 make all-build-libiberty
174 fi 2>&1 |CT_DoLog ALL
175 # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
176 if [ -d "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/libdecnumber" ]; then
177 make configure-libdecnumber
178 make -C libdecnumber libdecnumber.a
179 fi 2>&1 |CT_DoLog ALL
180 make -C gcc libgcc.mk 2>&1 |CT_DoLog ALL
181 sed -r -i -e 's@-lc@@g' gcc/libgcc.mk
183 if [ "${CT_CANADIAN}" = "y" ]; then
184 CT_DoLog EXTRA "Building libiberty"
185 make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
188 CT_DoLog EXTRA "Building shared core C compiler"
189 make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog ALL
191 CT_DoLog EXTRA "Installing shared core C compiler"
192 make install-gcc 2>&1 |CT_DoLog ALL