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
|
2019-03-10 02:01:30 +00:00
|
|
|
}
|
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-13 06:08:58 +00:00
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-cross"
|
2019-03-10 02:01:30 +00:00
|
|
|
|
|
|
|
cross_extra_config=( "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}" )
|
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
|
|
|
|
2020-05-27 10:10:31 +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")
|
|
|
|
|
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"
|
2019-04-04 23:47:50 +00:00
|
|
|
CT_DoExecLog ALL make ${CT_JOBSFLAGS} pdf html
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make install-{pdf,html}-gdb
|
2011-11-15 21:06:21 +00:00
|
|
|
fi
|
|
|
|
|
2021-09-21 09:09:16 +00:00
|
|
|
CT_DoLog EXTRA "Installing '.gdbinit' template"
|
|
|
|
# See in scripts/build/internals.sh for why we do this
|
|
|
|
# TBD GCC 3.x and older not supported
|
|
|
|
if [ -f "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ]; then
|
|
|
|
gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER")
|
|
|
|
else
|
|
|
|
gcc_version=$(sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
|
|
|
|
"${CT_SRC_DIR}/gcc/gcc/version.c" \
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
sed -r \
|
|
|
|
-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"
|
2011-07-24 18:30:52 +00:00
|
|
|
|
2019-03-13 06:08:58 +00:00
|
|
|
CT_Popd
|
2007-05-17 16:22:51 +00:00
|
|
|
CT_EndStep
|
|
|
|
fi
|
|
|
|
|
2020-05-27 10:10:31 +00:00
|
|
|
if [ "${CT_GDB_NATIVE}" = "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"
|
2019-03-13 06:08:58 +00:00
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-native"
|
2017-12-14 05:27:03 +00:00
|
|
|
|
2019-03-13 06:08:58 +00:00
|
|
|
native_extra_config+=("--program-prefix=")
|
2008-06-18 12:33:32 +00:00
|
|
|
|
2021-09-16 15:24:14 +00:00
|
|
|
# gdbserver gets enabled by default with gdb
|
|
|
|
# since gdbserver was promoted to top-level
|
|
|
|
if [ "${CT_GDB_GDBSERVER_TOPLEVEL}" = "y" ]; then
|
|
|
|
native_extra_config+=("--disable-gdbserver")
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
2020-05-27 10:10:31 +00:00
|
|
|
if [ "${CT_GDB_NATIVE_BUILD_IPA_LIB}" = "y" ]; then
|
|
|
|
native_extra_config+=("--enable-inprocess-agent")
|
2019-03-10 02:01:30 +00:00
|
|
|
else
|
2020-05-27 10:10:31 +00:00
|
|
|
native_extra_config+=("--disable-inprocess-agent")
|
2008-06-19 15:33:33 +00:00
|
|
|
fi
|
2020-05-27 10:10:31 +00:00
|
|
|
|
2023-02-21 07:31:19 +00:00
|
|
|
if [ "${CT_COMP_LIBS_ZSTD}}" = "y" ]; then
|
|
|
|
native_extra_config+=("--with-zstd=${complibs}")
|
|
|
|
else
|
|
|
|
native_extra_config+=("--without-zstd")
|
|
|
|
fi
|
|
|
|
|
2020-05-27 10:10:31 +00:00
|
|
|
export ac_cv_func_strncmp_works=yes
|
|
|
|
|
2021-09-16 19:38:33 +00:00
|
|
|
# TBD do we need all these?
|
2020-05-27 10:10:31 +00:00
|
|
|
native_extra_config+=(
|
|
|
|
--without-uiout
|
|
|
|
--disable-gdbtk
|
|
|
|
--without-x
|
|
|
|
--disable-sim
|
|
|
|
--without-included-gettext
|
|
|
|
--without-develop
|
|
|
|
--sysconfdir=/etc
|
|
|
|
--localstatedir=/var
|
|
|
|
)
|
|
|
|
|
|
|
|
# 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.
|
2023-05-09 08:30:15 +00:00
|
|
|
native_extra_config+=("--with-expat")
|
|
|
|
native_extra_config+=("--without-libexpat-prefix")
|
2020-05-27 10:10:31 +00:00
|
|
|
|
|
|
|
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}" \
|
|
|
|
"${native_extra_config[@]}"
|
|
|
|
|
|
|
|
unset ac_cv_func_strncmp_works
|
|
|
|
|
|
|
|
CT_Popd
|
|
|
|
CT_EndStep # native gdb build
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
|
|
|
|
local -a native_extra_config
|
|
|
|
local subdir
|
|
|
|
|
|
|
|
if [ "${CT_GDB_GDBSERVER_TOPLEVEL}" != "y" ]; then
|
|
|
|
subdir=gdb/gdbserver/
|
2021-09-16 15:24:14 +00:00
|
|
|
else
|
|
|
|
native_extra_config+=("--disable-gdb")
|
2020-05-27 10:10:31 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
CT_DoStep INFO "Installing gdb server"
|
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-server"
|
|
|
|
|
|
|
|
native_extra_config+=("--program-prefix=")
|
|
|
|
native_extra_config+=("--enable-gdbserver")
|
|
|
|
|
2019-03-21 01:16:11 +00:00
|
|
|
if [ "${CT_GDB_NATIVE_BUILD_IPA_LIB}" = "y" ]; then
|
|
|
|
native_extra_config+=("--enable-inprocess-agent")
|
|
|
|
else
|
|
|
|
native_extra_config+=("--disable-inprocess-agent")
|
|
|
|
fi
|
2008-06-19 15:33:33 +00:00
|
|
|
|
|
|
|
export ac_cv_func_strncmp_works=yes
|
|
|
|
|
2021-09-16 19:38:33 +00:00
|
|
|
# TBD do we need all these?
|
2019-03-10 02:01:30 +00:00
|
|
|
native_extra_config+=(
|
|
|
|
--without-uiout
|
|
|
|
--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}" \
|
2020-05-26 07:25:20 +00:00
|
|
|
static_libstdcxx="${CT_GDB_NATIVE_STATIC_LIBSTDCXX}" \
|
2019-03-10 02:01:30 +00:00
|
|
|
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
|
|
|
|
|
2019-03-13 06:08:58 +00:00
|
|
|
CT_Popd
|
2020-05-27 10:10:31 +00:00
|
|
|
CT_EndStep # gdb server 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()
|
|
|
|
{
|
2023-05-24 10:54:34 +00:00
|
|
|
local host prefix destdir cflags ldflags static buildtype subdir includedir
|
2019-03-10 02:01:30 +00:00
|
|
|
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
|
|
|
|
2021-09-21 09:09:16 +00:00
|
|
|
[ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
|
|
|
|
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
|
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
|
|
|
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
|
|
|
if [ "${static}" = "y" ]; then
|
|
|
|
cflags+=" -static"
|
|
|
|
ldflags+=" -static"
|
2021-07-12 18:52:35 +00:00
|
|
|
# There is no static libsource-highlight
|
|
|
|
extra_config+=("--disable-source-highlight")
|
2019-03-10 02:01:30 +00:00
|
|
|
fi
|
2020-05-26 07:25:20 +00:00
|
|
|
if [ "${static_libstdcxx}" = "y" ]; then
|
2020-05-26 07:34:31 +00:00
|
|
|
ldflags+=" -static-libgcc"
|
2019-03-10 02:01:30 +00:00
|
|
|
ldflags+=" -static-libstdc++"
|
2021-07-12 18:52:35 +00:00
|
|
|
# libsource-highlight is a dynamic library that uses exception
|
|
|
|
# exceptions are handled by libstdc++
|
|
|
|
# this combination is very buggy, so configure don't use it and abort
|
|
|
|
extra_config+=("--disable-source-highlight")
|
2019-03-10 02:01:30 +00:00
|
|
|
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[*]}'"
|
|
|
|
|
2019-03-13 06:08:58 +00:00
|
|
|
# Run configure/make in the matching subdirectory so that any fixups
|
|
|
|
# prepared in a given subdirectory apply.
|
|
|
|
if [ -n "${subdir}" ]; then
|
|
|
|
CT_mkdir_pushd "${subdir}"
|
|
|
|
fi
|
|
|
|
|
2023-05-24 10:54:34 +00:00
|
|
|
# Use a relative path for include directory if gdb or gdbserver
|
|
|
|
# is being built and installed for a target. Otherwise headers
|
|
|
|
# are installed in ${destdir}${CT_HEADERS_DIR} - a concatenation
|
|
|
|
# of ${destdir} and an absolute path to sysroot's include directory.
|
|
|
|
# As a result debug-root may contain wrong paths for includes.
|
|
|
|
if [ -n "${destdir}" ]; then
|
|
|
|
includedir="/usr/include"
|
|
|
|
else
|
|
|
|
includedir=${CT_HEADERS_DIR}
|
|
|
|
fi
|
|
|
|
|
2019-03-10 02:01:30 +00:00
|
|
|
# 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}" \
|
2023-05-24 10:54:34 +00:00
|
|
|
--includedir="${includedir}" \
|
2019-03-10 02:01:30 +00:00
|
|
|
--disable-werror \
|
|
|
|
"${extra_config[@]}" \
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Building ${buildtype} gdb"
|
2019-04-04 23:47:50 +00:00
|
|
|
CT_DoExecLog ALL make ${CT_JOBSFLAGS}
|
2019-03-10 02:01:30 +00:00
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing ${buildtype} gdb"
|
|
|
|
CT_DoExecLog ALL make install ${destdir:+DESTDIR="${destdir}"}
|
2019-03-13 06:08:58 +00:00
|
|
|
|
|
|
|
if [ -n "${subdir}" ]; then
|
|
|
|
CT_Popd
|
|
|
|
fi
|
2007-05-17 16:22:51 +00:00
|
|
|
}
|