2007-05-17 16:22:51 +00:00
|
|
|
# Build script for the gdb debug facility
|
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
do_debug_gdb_get()
|
|
|
|
{
|
2017-05-30 05:32:38 +00:00
|
|
|
CT_Fetch GDB
|
2007-05-17 16:22:51 +00:00
|
|
|
}
|
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
do_debug_gdb_extract()
|
|
|
|
{
|
2017-05-30 05:32:38 +00:00
|
|
|
CT_ExtractPatch GDB
|
2007-05-17 16:22:51 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
# Workaround for bad versions, where the configure
|
|
|
|
# script for gdbserver is not executable...
|
|
|
|
# Bah, GNU folks strike again... :-(
|
|
|
|
chmod a+x "${CT_SRC_DIR}/gdb/gdb/gdbserver/configure"
|
|
|
|
}
|
2011-05-31 19:03:03 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
do_debug_gdb_build()
|
|
|
|
{
|
2007-05-17 16:22:51 +00:00
|
|
|
if [ "${CT_GDB_CROSS}" = "y" ]; then
|
2017-04-02 02:19:35 +00:00
|
|
|
local gcc_version p _p
|
2019-03-10 02:01:30 +00:00
|
|
|
local -a cross_extra_config
|
2009-08-19 17:44:43 +00:00
|
|
|
|
2007-05-17 22:10:48 +00:00
|
|
|
CT_DoStep INFO "Installing cross-gdb"
|
2019-03-10 02:01:30 +00:00
|
|
|
|
|
|
|
cross_extra_config=( "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}" )
|
2007-05-17 16:22:51 +00:00
|
|
|
|
|
|
|
mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
|
|
|
|
cd "${CT_BUILD_DIR}/build-gdb-cross"
|
|
|
|
|
2011-10-08 20:57:21 +00:00
|
|
|
if [ "${CT_GDB_CROSS_PYTHON}" = "y" ]; then
|
2017-04-02 02:19:35 +00:00
|
|
|
if [ -z "${CT_GDB_CROSS_PYTHON_BINARY}" ]; then
|
2019-03-02 23:45:37 +00:00
|
|
|
if [ "${CT_CANADIAN}" = "y" -o "${CT_CROSS_NATIVE}" = "y" ]; then
|
|
|
|
CT_Abort "For canadian build, Python wrapper runnable on the build machine must be provided. Set CT_GDB_CROSS_PYTHON_BINARY."
|
|
|
|
elif [ "${CT_CONFIGURE_has_python}" = "y" ]; then
|
|
|
|
cross_extra_config+=("--with-python=${python}")
|
|
|
|
else
|
|
|
|
CT_Abort "Python support requested in GDB, but Python not found. Set CT_GDB_CROSS_PYTHON_BINARY."
|
2017-04-02 02:19:35 +00:00
|
|
|
fi
|
|
|
|
else
|
2017-12-14 05:27:03 +00:00
|
|
|
cross_extra_config+=("--with-python=${CT_GDB_CROSS_PYTHON_BINARY}")
|
2017-04-02 02:19:35 +00:00
|
|
|
fi
|
2011-10-08 20:57:21 +00:00
|
|
|
else
|
2017-12-14 05:27:03 +00:00
|
|
|
cross_extra_config+=("--with-python=no")
|
2011-10-08 20:57:21 +00:00
|
|
|
fi
|
2017-12-14 05:27:03 +00:00
|
|
|
|
2011-11-18 08:22:52 +00:00
|
|
|
if [ "${CT_GDB_CROSS_SIM}" = "y" ]; then
|
2017-12-14 05:27:03 +00:00
|
|
|
cross_extra_config+=("--enable-sim")
|
2011-11-18 08:22:52 +00:00
|
|
|
else
|
2017-12-14 05:27:03 +00:00
|
|
|
cross_extra_config+=("--disable-sim")
|
2011-11-18 08:22:52 +00:00
|
|
|
fi
|
2017-12-14 05:27:03 +00:00
|
|
|
|
2018-09-24 12:04:02 +00:00
|
|
|
if ${CT_HOST}-gcc --version 2>&1 | grep clang; then
|
|
|
|
# clang detects the line from gettext's _ macro as format string
|
|
|
|
# not being a string literal and produces a lot of warnings - which
|
|
|
|
# ct-ng's logger faithfully relays to user if this happens in the
|
|
|
|
# error() function. Suppress them.
|
|
|
|
cross_extra_config+=("--enable-build-warnings=,-Wno-format-nonliteral,-Wno-format-security")
|
|
|
|
fi
|
2008-04-27 10:25:02 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
do_gdb_backend \
|
|
|
|
buildtype=cross \
|
|
|
|
host="${CT_HOST}" \
|
|
|
|
cflags="${CT_CFLAGS_FOR_HOST}" \
|
|
|
|
ldflags="${CT_LDFLAGS_FOR_HOST}" \
|
|
|
|
prefix="${CT_PREFIX_DIR}" \
|
|
|
|
static="${CT_GDB_CROSS_STATIC}" \
|
2011-05-25 18:23:48 +00:00
|
|
|
--with-sysroot="${CT_SYSROOT_DIR}" \
|
2019-03-10 02:01:30 +00:00
|
|
|
"${cross_extra_config[@]}"
|
2007-05-17 16:22:51 +00:00
|
|
|
|
2011-11-15 21:06:21 +00:00
|
|
|
if [ "${CT_BUILD_MANUALS}" = "y" ]; then
|
|
|
|
CT_DoLog EXTRA "Building and installing the cross-GDB manuals"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make ${JOBSFLAGS} pdf html
|
|
|
|
CT_DoExecLog ALL make install-{pdf,html}-gdb
|
2011-11-15 21:06:21 +00:00
|
|
|
fi
|
|
|
|
|
2011-07-29 22:05:53 +00:00
|
|
|
if [ "${CT_GDB_INSTALL_GDBINIT}" = "y" ]; then
|
2013-03-03 16:17:55 +00:00
|
|
|
CT_DoLog EXTRA "Installing '.gdbinit' template"
|
2011-07-29 22:05:53 +00:00
|
|
|
# See in scripts/build/internals.sh for why we do this
|
2017-05-30 05:32:38 +00:00
|
|
|
# TBD GCC 3.x and older not supported
|
|
|
|
if [ -f "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ]; then
|
2017-12-14 05:27:03 +00:00
|
|
|
gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER")
|
2011-07-29 22:05:53 +00:00
|
|
|
else
|
2017-02-27 03:06:35 +00:00
|
|
|
gcc_version=$(sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
|
2017-05-30 05:32:38 +00:00
|
|
|
"${CT_SRC_DIR}/gcc/gcc/version.c" \
|
2011-07-29 22:05:53 +00:00
|
|
|
)
|
|
|
|
fi
|
2017-12-14 05:27:03 +00:00
|
|
|
sed -r \
|
2011-07-29 22:05:53 +00:00
|
|
|
-e "s:@@PREFIX@@:${CT_PREFIX_DIR}:;" \
|
|
|
|
-e "s:@@VERSION@@:${gcc_version}:;" \
|
|
|
|
"${CT_LIB_DIR}/scripts/build/debug/gdbinit.in" \
|
|
|
|
>"${CT_PREFIX_DIR}/share/gdb/gdbinit"
|
|
|
|
fi # Install gdbinit sample
|
2011-07-24 18:30:52 +00:00
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
CT_EndStep
|
|
|
|
fi
|
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
if [ "${CT_GDB_NATIVE}" = "y" -o "${CT_GDB_GDBSERVER}" = "y" ]; then
|
2009-08-19 17:44:43 +00:00
|
|
|
local -a native_extra_config
|
2019-03-10 02:01:30 +00:00
|
|
|
local subdir
|
2009-08-19 17:44:43 +00:00
|
|
|
|
2008-06-18 12:33:32 +00:00
|
|
|
CT_DoStep INFO "Installing native gdb"
|
2017-12-14 05:27:03 +00:00
|
|
|
|
|
|
|
mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
|
|
|
|
cd "${CT_BUILD_DIR}/build-gdb-native"
|
2008-06-18 12:33:32 +00:00
|
|
|
|
2010-07-11 20:23:34 +00:00
|
|
|
# GDB on Mingw depends on PDcurses, not ncurses
|
2013-03-03 14:25:52 +00:00
|
|
|
if [ "${CT_MINGW32}" != "y" ]; then
|
2010-08-23 12:32:16 +00:00
|
|
|
native_extra_config+=("--with-curses")
|
2015-11-08 07:31:46 +00:00
|
|
|
fi
|
2009-03-30 21:17:21 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
# Build a native gdbserver if needed. If building only
|
|
|
|
# gdbserver, configure in the subdirectory.
|
2017-12-11 22:34:50 +00:00
|
|
|
# Newer versions enable it automatically for a native target by default.
|
2019-03-10 02:01:30 +00:00
|
|
|
if [ "${CT_GDB_GDBSERVER}" != "y" ]; then
|
|
|
|
native_extra_config+=("--disable-gdbserver")
|
|
|
|
else
|
|
|
|
native_extra_config+=("--enable-gdbserver")
|
|
|
|
if [ "${CT_GDB_NATIVE_BUILD_IPA_LIB}" = "y" ]; then
|
|
|
|
gdbserver_extra_config+=("--enable-inprocess-agent")
|
|
|
|
else
|
|
|
|
gdbserver_extra_config+=("--disable-inprocess-agent")
|
|
|
|
fi
|
|
|
|
if [ "${CT_GDB_NATIVE}" != "y" ]; then
|
|
|
|
subdir=gdbserver/
|
|
|
|
fi
|
2008-06-19 15:33:33 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
export ac_cv_func_strncmp_works=yes
|
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
# TBD do we need all these? Eg why do we disable TUI if we build curses for target?
|
|
|
|
native_extra_config+=(
|
|
|
|
--without-uiout
|
|
|
|
--disable-tui
|
|
|
|
--disable-gdbtk
|
|
|
|
--without-x
|
|
|
|
--disable-sim
|
|
|
|
--without-included-gettext
|
|
|
|
--without-develop
|
|
|
|
--sysconfdir=/etc
|
|
|
|
--localstatedir=/var
|
|
|
|
)
|
|
|
|
|
|
|
|
do_gdb_backend \
|
|
|
|
buildtype=native \
|
|
|
|
subdir=${subdir} \
|
|
|
|
host="${CT_TARGET}" \
|
|
|
|
cflags="${CT_ALL_TARGET_CFLAGS}" \
|
|
|
|
ldflags="${CT_ALL_TARGET_LDFLAGS}" \
|
|
|
|
static="${CT_GDB_NATIVE_STATIC}" \
|
|
|
|
static_libstdc="${CT_GDB_NATIVE_STATIC_LIBSTDC}" \
|
|
|
|
prefix=/usr \
|
|
|
|
destdir="${CT_DEBUGROOT_DIR}" \
|
2009-08-19 17:44:43 +00:00
|
|
|
"${native_extra_config[@]}"
|
2007-05-17 16:22:51 +00:00
|
|
|
|
2008-06-19 15:33:33 +00:00
|
|
|
unset ac_cv_func_strncmp_works
|
|
|
|
|
2009-03-30 21:17:21 +00:00
|
|
|
CT_EndStep # native gdb build
|
2008-06-19 15:33:33 +00:00
|
|
|
fi
|
2019-03-10 02:01:30 +00:00
|
|
|
}
|
2008-06-19 15:33:33 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
do_gdb_backend()
|
|
|
|
{
|
|
|
|
local host prefix destdir cflags ldflags static buildtype subdir
|
|
|
|
local -a extra_config
|
2008-06-19 15:33:33 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
for arg in "$@"; do
|
|
|
|
case "$arg" in
|
|
|
|
--*)
|
|
|
|
extra_config+=("${arg}")
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
eval "${arg// /\\ }"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2008-06-20 15:16:43 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
if [ "${CT_GDB_HAS_PKGVERSION_BUGURL}" = "y" ]; then
|
|
|
|
[ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
|
|
|
|
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
|
|
|
|
fi
|
2017-02-10 06:14:36 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
# Disable binutils options when building from the binutils-gdb repo.
|
|
|
|
extra_config+=("--disable-binutils")
|
|
|
|
extra_config+=("--disable-ld")
|
|
|
|
extra_config+=("--disable-gas")
|
2012-05-17 15:56:27 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
if [ "${CT_GDB_HAS_DISABLE_CXX_BUILD}" = "y" ]; then
|
|
|
|
extra_config+=("--disable-build-with-cxx")
|
|
|
|
fi
|
2015-11-25 04:40:44 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
case "${CT_THREADS}" in
|
|
|
|
none) extra_config+=("--disable-threads");;
|
|
|
|
*) extra_config+=("--enable-threads");;
|
|
|
|
esac
|
2017-12-14 05:27:03 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
if [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ]; then
|
|
|
|
extra_config+=("--disable-nls")
|
|
|
|
fi
|
2017-12-14 05:27:03 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
# Target libexpat resides in sysroot and does not have
|
|
|
|
# any dependencies, so just passing '-lexpat' to gcc is enough.
|
|
|
|
#
|
|
|
|
# By default gdb configure looks for expat in '$prefix/lib'
|
|
|
|
# directory. In our case '$prefix/lib' resolves to '/usr/lib'
|
|
|
|
# where libexpat for build platform lives, which is
|
|
|
|
# unacceptable for cross-compiling.
|
|
|
|
#
|
|
|
|
# To prevent this '--without-libexpat-prefix' flag must be passed.
|
|
|
|
# Thus configure falls back to '-lexpat', which is exactly what we want.
|
|
|
|
#
|
|
|
|
# NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!!
|
|
|
|
# It conflicts with a static build: GDB's configure script will find the shared
|
|
|
|
# version of expat and will attempt to link that, despite the -static flag.
|
|
|
|
# The link will fail, and configure will abort with "expat missing or unusable"
|
|
|
|
# message.
|
|
|
|
extra_config+=("--with-expat")
|
|
|
|
extra_config+=("--without-libexpat-prefix")
|
|
|
|
|
|
|
|
if [ "${static}" = "y" ]; then
|
|
|
|
cflags+=" -static"
|
|
|
|
ldflags+=" -static"
|
|
|
|
fi
|
|
|
|
if [ "${static_libstdc}" = "y" ]; then
|
|
|
|
ldflags+=" -static-libstdc++"
|
|
|
|
fi
|
2017-12-14 05:27:03 +00:00
|
|
|
|
2008-06-19 15:33:33 +00:00
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
# Fix up whitespace. Some older GDB releases (e.g. 6.8a) get confused if there
|
|
|
|
# are multiple consecutive spaces: sub-configure scripts replace them with a
|
|
|
|
# single space and then complain that $CC value changed from that in
|
|
|
|
# the master directory.
|
|
|
|
cflags=`echo ${cflags}`
|
|
|
|
ldflags=`echo ${ldflags}`
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Configuring ${buildtype} gdb"
|
|
|
|
CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
|
|
|
|
|
|
|
|
# TBD: is passing CPP/CC/CXX/LD needed? GCC should be determining this automatically from the triplets
|
|
|
|
CT_DoExecLog CFG \
|
|
|
|
CPP="${host}-cpp" \
|
|
|
|
CC="${host}-gcc" \
|
|
|
|
CXX="${host}-g++" \
|
|
|
|
LD="${host}-ld" \
|
|
|
|
CFLAGS="${cflags}" \
|
|
|
|
CXXFLAGS="${cflags}" \
|
|
|
|
LDFLAGS="${ldflags}" \
|
|
|
|
${CONFIG_SHELL} \
|
|
|
|
"${CT_SRC_DIR}/gdb/${subdir}configure" \
|
|
|
|
--build=${CT_BUILD} \
|
|
|
|
--host=${host} \
|
|
|
|
--target=${CT_TARGET} \
|
|
|
|
--prefix="${prefix}" \
|
|
|
|
--with-build-sysroot="${CT_SYSROOT_DIR}" \
|
|
|
|
--includedir="${CT_HEADERS_DIR}" \
|
|
|
|
--disable-werror \
|
|
|
|
"${extra_config[@]}" \
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Building ${buildtype} gdb"
|
|
|
|
CT_DoExecLog ALL make ${JOBSFLAGS}
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing ${buildtype} gdb"
|
|
|
|
CT_DoExecLog ALL make install ${destdir:+DESTDIR="${destdir}"}
|
2007-05-17 16:22:51 +00:00
|
|
|
}
|