Move GDB build into a common backend function

... needed to create a common runtime test for an incompatible change
in glibc API.

Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
Alexey Neyman 2019-03-09 18:01:30 -08:00
parent 32af07341d
commit 1e25ebc7e0
10 changed files with 2861 additions and 362 deletions

View File

@ -4,7 +4,6 @@
source "config/debug/gdb.in.cross"
source "config/debug/gdb.in.native"
source "config/debug/gdb.in.gdbserver"
config GDB_HAS_PKGVERSION_BUGURL
bool
@ -32,3 +31,9 @@ config GDB_DEP_CXX11
def_bool y
depends on !CONFIGURE_has_cxx11
select GDB_REQUIRE_older_than_8_0
config GDB_HAS_IPA_LIB
bool
depends on GDB_7_2_or_later
default y

View File

@ -1,71 +0,0 @@
# Menu for the native gdbserver
config GDB_GDBSERVER
bool
prompt "gdbserver"
default y
depends on ! BARE_METAL
select LIBC_UCLIBC_WCHAR if LIBC_UCLIBC && GDB_8_0_or_later
help
Build and install a gdbserver for the target, to run on the target.
if GDB_GDBSERVER
config GDB_GDBSERVER_HAS_IPA_LIB
bool
depends on GDB_7_2_or_later
default y
config GDB_GDBSERVER_STATIC
bool
prompt "Build a static gdbserver"
depends on EXPERIMENTAL
help
In case you have trouble with dynamic loading of shared libraries,
you will find that a static gdbserver comes in handy.
However, it has been noticed at least on x86 that enabling this
option produces an invalid gdbserver binary. It is linked with
"-static -Wl,--dynamic-list=..." which
# (a) requests invalid program interpreter
# (b) crashes glibc/uClibc-ng and does not work with musl
# See https://sourceware.org/ml/libc-alpha/2017-03/msg00267.html
It is possible it would work with other architectures, hence it is
not completely removed. Use with care and report to the mailing list
if the resulting gdbserver works.
For further details, see:
https://sourceware.org/bugzilla/show_bug.cgi?id=19617
https://sourceware.org/bugzilla/show_bug.cgi?id=21086
config GDB_GDBSERVER_STATIC_LIBSTDCXX
bool
prompt "Link against static libstdc+++"
depends on !GDB_GDBSERVER_STATIC
default n
help
Say 'y' if you do not want gdbserver to require libstdc++.so on the
target.
config GDB_GDBSERVER_BUILD_IPA_LIB
bool
prompt "Build the IPA library"
depends on GDB_GDBSERVER_HAS_IPA_LIB && !GDB_GDBSERVER_STATIC
help
gdbserver >= 7.2 comes with an optional library to use tracepoints,
the In Process Agent (IPA) library, libinproctrace.so.
Say 'y' if you indend to use tracepoints when debugging your
programs with gdbserver.
Note: Currently, building this library is not possible when the
gdbserver is built statically. This is a limitation in
crosstool-NG, so do not bug upstream about it...
endif # GDB_GDBSERVER
if BARE_METAL
comment "In bare-metal, you'll need to "
comment "provide your own gdbserver stub."
endif # BARE_METAL

View File

@ -1,4 +1,4 @@
# Menu for the native GDB
# Menu for the native GDB binaries (GDB itself and gdbserver)
config GDB_NATIVE
bool
@ -12,11 +12,35 @@ config GDB_NATIVE
help
Build and install a native gdb for the target, to run on the target.
if GDB_NATIVE
config GDB_GDBSERVER
bool
prompt "gdbserver"
default y
depends on ! BARE_METAL
select LIBC_UCLIBC_WCHAR if LIBC_UCLIBC && GDB_8_0_or_later
help
Build and install a gdbserver for the target, to run on the target.
if GDB_NATIVE || GDB_GDBSERVER
config GDB_NATIVE_BUILD_IPA_LIB
bool
prompt "Build the IPA library"
depends on GDB_HAS_IPA_LIB && !GDB_NATIVE_STATIC
help
gdbserver >= 7.2 comes with an optional library to use tracepoints,
the In Process Agent (IPA) library, libinproctrace.so.
Say 'y' if you intend to use tracepoints when debugging your
programs with gdbserver.
Note: Currently, building this library is not possible when the
gdbserver is built statically. This is a limitation in
crosstool-NG, so do not bug upstream about it...
config GDB_NATIVE_STATIC
bool
prompt "Build a static native gdb"
prompt "Build a static gdb binaries"
depends on EXPERIMENTAL
help
In case you have trouble with dynamic loading of shared libraries,
@ -31,10 +55,24 @@ config GDB_NATIVE_STATIC
It is possible it would work with other architectures, hence it is
not completely removed. Use with care and report to the mailing list
if the resulting gdbserver works.
if the resulting binaries work.
For further details, see:
https://sourceware.org/bugzilla/show_bug.cgi?id=19617
https://sourceware.org/bugzilla/show_bug.cgi?id=21086
config GDB_NATIVE_STATIC_LIBSTDCXX
bool
prompt "Link against static libstdc+++"
depends on !GDB_NATIVE_STATIC
default n
help
Say 'y' if you do not want gdbserver to require libstdc++.so on the
target.
endif # GDB_NATIVE
if BARE_METAL
comment "In bare-metal, you'll need to "
comment "provide your own gdbserver stub."
endif # BARE_METAL

View File

@ -41,7 +41,7 @@ export CT_VCHECK=
# need to pass it to the upgrade script - which may receive an input that
# was not preprocessed by kconfig, and hence have no string for "up-to-date"
# version.
export CT_CONFIG_VERSION_CURRENT=2
export CT_CONFIG_VERSION_CURRENT=3
# Download agents used by scripts.mk
CT_WGET := @wget@

View File

@ -0,0 +1,43 @@
commit 5a6c3296a7a90694ad4042f6256f3da6d4fa4ee8
Author: James Clarke <jrtc27@jrtc27.com>
Date: Fri Jan 19 17:22:49 2018 +0000
gdb: Fix ia64 defining TRAP_HWBKPT before including gdb_wait.h
On ia64, gdb_wait.h eventually includes siginfo-consts-arch.h, which
contains an enum with TRAP_HWBKPT, along with a #define. Thus we cannot
define TRAP_HWBKPT to 4 beforehand, and so gdb_wait.h must be included
earlier; include it from linux-ptrace.h so it can never come afterwards.
gdb/ChangeLog:
* nat/linux-ptrace.c: Remove unnecessary reinclusion of
gdb_ptrace.h, and move including gdb_wait.h ...
* nat/linux-ptrace.h: ... to here.
---
gdb/nat/linux-ptrace.c | 2 --
gdb/nat/linux-ptrace.h | 1 +
2 files changed, 1 insertion(+), 2 deletions(-)
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -21,8 +21,6 @@
#include "linux-procfs.h"
#include "linux-waitpid.h"
#include "buffer.h"
-#include "gdb_wait.h"
-#include "gdb_ptrace.h"
/* Stores the ptrace options supported by the running kernel.
A value of -1 means we did not check for features yet. A value
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -21,6 +21,7 @@
struct buffer;
#include "nat/gdb_ptrace.h"
+#include "gdb_wait.h"
#ifdef __UCLIBC__
#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))

View File

@ -125,7 +125,7 @@ do_ncurses_backend() {
for arg in "$@"; do
case "$arg" in
--*)
ncurses_opts+=("$arg")
ncurses_opts+=("${arg}")
;;
*)
eval "${arg// /\\ }"

View File

@ -1,67 +1,33 @@
# Build script for the gdb debug facility
do_debug_gdb_get() {
do_debug_gdb_get()
{
CT_Fetch GDB
}
do_debug_gdb_extract() {
do_debug_gdb_extract()
{
CT_ExtractPatch GDB
# 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"
}
do_debug_gdb_build() {
local -a extra_config
# These variables should be global and shared between all packages.
local CT_TARGET_CPP="${CT_TARGET}-cpp"
local CT_TARGET_CC="${CT_TARGET}-gcc"
local CT_TARGET_CXX="${CT_TARGET}-g++"
local CT_TARGET_LD="${CT_TARGET}-ld"
local CT_HOST_CPP="${CT_HOST}-cpp"
local CT_HOST_CC="${CT_HOST}-gcc"
local CT_HOST_CXX="${CT_HOST}-g++"
local CT_HOST_LD="${CT_HOST}-ld"
gdb_src_dir="${CT_SRC_DIR}/gdb"
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
do_debug_gdb_build()
{
if [ "${CT_GDB_CROSS}" = "y" ]; then
local -a cross_extra_config
local gcc_version p _p
local cross_CFLAGS cross_LDFLAGS
local -a cross_extra_config
CT_DoStep INFO "Installing cross-gdb"
CT_DoLog EXTRA "Configuring cross-gdb"
cross_extra_config=( "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}" )
mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
cd "${CT_BUILD_DIR}/build-gdb-cross"
cross_extra_config=("${extra_config[@]}")
if [ "${CT_GDB_HAS_DISABLE_CXX_BUILD}" = "y" ]; then
cross_extra_config+=("--disable-build-with-cxx")
fi
# For gdb-cross this combination of flags forces
# gdb configure to fall back to default '-lexpat' flag
# which is acceptable.
#
# 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.
cross_extra_config+=("--with-expat")
cross_extra_config+=("--without-libexpat-prefix")
case "${CT_THREADS}" in
none) cross_extra_config+=("--disable-threads");;
*) cross_extra_config+=("--enable-threads");;
esac
if [ "${CT_GDB_CROSS_PYTHON}" = "y" ]; then
if [ -z "${CT_GDB_CROSS_PYTHON_BINARY}" ]; then
if [ "${CT_CANADIAN}" = "y" -o "${CT_CROSS_NATIVE}" = "y" ]; then
@ -84,18 +50,6 @@ do_debug_gdb_build() {
cross_extra_config+=("--disable-sim")
fi
if [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ]; then
cross_extra_config+=("--disable-nls")
fi
cross_CFLAGS="${CT_CFLAGS_FOR_HOST}"
cross_LDFLAGS="${CT_LDFLAGS_FOR_HOST}"
if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
cross_CFLAGS+=" -static"
cross_LDFLAGS+=" -static"
fi
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
@ -104,45 +58,15 @@ do_debug_gdb_build() {
cross_extra_config+=("--enable-build-warnings=,-Wno-format-nonliteral,-Wno-format-security")
fi
# 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.
cross_CFLAGS=`echo ${cross_CFLAGS}`
cross_LDFLAGS=`echo ${cross_LDFLAGS}`
# Disable binutils options when building from the binutils-gdb repo.
cross_extra_config+=("--disable-binutils")
cross_extra_config+=("--disable-ld")
cross_extra_config+=("--disable-gas")
CT_DoLog DEBUG "Extra config passed: '${cross_extra_config[*]}'"
CT_DoExecLog CFG \
CPP="${CT_HOST_CPP}" \
CC="${CT_HOST_CC}" \
CXX="${CT_HOST_CXX}" \
LD="${CT_HOST_LD}" \
CFLAGS="${cross_CFLAGS}" \
CXXFLAGS="${cross_CFLAGS}" \
LDFLAGS="${cross_LDFLAGS}" \
${CONFIG_SHELL} \
"${gdb_src_dir}/configure" \
--build=${CT_BUILD} \
--host=${CT_HOST} \
--target=${CT_TARGET} \
--prefix="${CT_PREFIX_DIR}" \
--with-build-sysroot="${CT_SYSROOT_DIR}" \
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}" \
--with-sysroot="${CT_SYSROOT_DIR}" \
--disable-werror \
"${cross_extra_config[@]}" \
"${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}"
CT_DoLog EXTRA "Building cross-gdb"
CT_DoExecLog ALL make ${JOBSFLAGS}
CT_DoLog EXTRA "Installing cross-gdb"
CT_DoExecLog ALL make install
"${cross_extra_config[@]}"
if [ "${CT_BUILD_MANUALS}" = "y" ]; then
CT_DoLog EXTRA "Building and installing the cross-GDB manuals"
@ -171,206 +95,170 @@ do_debug_gdb_build() {
CT_EndStep
fi
# TBD combine GDB native and gdbserver backends, build either or both in a single pass.
if [ "${CT_GDB_NATIVE}" = "y" ]; then
if [ "${CT_GDB_NATIVE}" = "y" -o "${CT_GDB_GDBSERVER}" = "y" ]; then
local -a native_extra_config
local native_CFLAGS native_LDFLAGS
local subdir
CT_DoStep INFO "Installing native gdb"
CT_DoLog EXTRA "Configuring native gdb"
mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
cd "${CT_BUILD_DIR}/build-gdb-native"
native_extra_config=("${extra_config[@]}")
# We may not have C++ language configured for target
if [ "${CT_GDB_HAS_DISABLE_CXX_BUILD}" = "y" ]; then
native_extra_config+=("--disable-build-with-cxx")
fi
# GDB on Mingw depends on PDcurses, not ncurses
if [ "${CT_MINGW32}" != "y" ]; then
native_extra_config+=("--with-curses")
fi
# Build a native gdbserver later if required.
# Build a native gdbserver if needed. If building only
# gdbserver, configure in the subdirectory.
# Newer versions enable it automatically for a native target by default.
native_extra_config+=("--enable-gdbserver=no")
# 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.
native_extra_config+=("--with-expat")
native_extra_config+=("--without-libexpat-prefix")
case "${CT_THREADS}" in
none) native_extra_config+=("--disable-threads");;
*) native_extra_config+=("--enable-threads");;
esac
if [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ]; then
native_extra_config+=("--disable-nls")
fi
native_CFLAGS="${CT_ALL_TARGET_CFLAGS}"
native_LDFLAGS="${CT_ALL_TARGET_LDFLAGS}"
if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
native_CFLAGS+=" -static"
native_LDFLAGS+=" -static"
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
fi
export ac_cv_func_strncmp_works=yes
# Disable binutils options when building from the binutils-gdb repo.
native_extra_config+=("--disable-binutils")
native_extra_config+=("--disable-ld")
native_extra_config+=("--disable-gas")
# 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
)
native_CFLAGS=`echo ${native_CFLAGS}`
native_LDFLAGS=`echo ${native_LDFLAGS}`
CT_DoLog DEBUG "Extra config passed: '${native_extra_config[*]}'"
CT_DoExecLog CFG \
CPP="${CT_TARGET_CPP}" \
CC="${CT_TARGET_CC}" \
CXX="${CT_TARGET_CXX}" \
LD="${CT_TARGET_LD}" \
CFLAGS="${native_CFLAGS}" \
CXXFLAGS="${native_CFLAGS}" \
LDFLAGS="${native_LDFLAGS}" \
${CONFIG_SHELL} \
"${gdb_src_dir}/configure" \
--build=${CT_BUILD} \
--host=${CT_TARGET} \
--target=${CT_TARGET} \
--prefix=/usr \
--with-build-sysroot="${CT_SYSROOT_DIR}" \
--without-uiout \
--disable-tui \
--disable-gdbtk \
--without-x \
--disable-sim \
--disable-werror \
--without-included-gettext \
--without-develop \
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[@]}"
CT_DoLog EXTRA "Building native gdb"
CT_DoExecLog ALL make ${JOBSFLAGS}
CT_DoLog EXTRA "Installing native gdb"
CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
# Building a native gdb also builds a gdbserver
find "${CT_DEBUGROOT_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
unset ac_cv_func_strncmp_works
CT_EndStep # native gdb build
fi
if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
local -a gdbserver_extra_config
local gdbserver_CFLAGS gdbserver_LDFLAGS
CT_DoStep INFO "Installing gdbserver"
CT_DoLog EXTRA "Configuring gdbserver"
mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
# Workaround for bad versions, where the configure
# script for gdbserver is not executable...
# Bah, GNU folks strike again... :-(
chmod a+x "${gdb_src_dir}/gdb/gdbserver/configure"
gdbserver_extra_config=("${extra_config[@]}")
# We may not have C++ language configured for target
if [ "${CT_GDB_HAS_DISABLE_CXX_BUILD}" = "y" ]; then
gdbserver_extra_config+=("--disable-build-with-cxx")
fi
if [ "${CT_GDB_GDBSERVER_HAS_IPA_LIB}" = "y" ]; then
if [ "${CT_GDB_GDBSERVER_BUILD_IPA_LIB}" = "y" ]; then
gdbserver_extra_config+=("--enable-inprocess-agent")
else
gdbserver_extra_config+=("--disable-inprocess-agent")
fi
fi
# Disable binutils options when building from the binutils-gdb repo.
gdbserver_extra_config+=("--disable-binutils")
gdbserver_extra_config+=("--disable-ld")
gdbserver_extra_config+=("--disable-gas")
gdbserver_CFLAGS="${CT_ALL_TARGET_CFLAGS}"
gdbserver_LDFLAGS="${CT_ALL_TARGET_LDFLAGS}"
if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
gdbserver_CFLAGS+=" -static"
gdbserver_LDFLAGS+=" -static"
fi
if [ "${CT_GDB_GDBSERVER_STATIC_LIBSTDCXX}" = "y" ]; then
gdbserver_LDFLAGS+=" -static-libstdc++"
fi
gdbserver_CFLAGS=`echo ${gdbserver_CFLAGS}`
gdbserver_LDFLAGS=`echo ${gdbserver_LDFLAGS}`
CT_DoLog DEBUG "Extra config passed: '${gdbserver_extra_config[*]}'"
CT_DoExecLog CFG \
CPP="${CT_TARGET_CPP}" \
CC="${CT_TARGET_CC}" \
CXX="${CT_TARGET_CXX}" \
LD="${CT_TARGET_LD}" \
CFLAGS="${gdbserver_CFLAGS}" \
CXXFLAGS="${gdbserver_CFLAGS}" \
LDFLAGS="${gdbserver_LDFLAGS}" \
${CONFIG_SHELL} \
"${gdb_src_dir}/gdb/gdbserver/configure" \
--build=${CT_BUILD} \
--host=${CT_TARGET} \
--target=${CT_TARGET} \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--includedir="${CT_HEADERS_DIR}" \
--with-build-sysroot="${CT_SYSROOT_DIR}" \
--program-prefix= \
--without-uiout \
--disable-tui \
--disable-gdbtk \
--without-x \
--without-included-gettext \
--without-develop \
--disable-werror \
"${gdbserver_extra_config[@]}"
CT_DoLog EXTRA "Building gdbserver"
CT_DoExecLog ALL make ${JOBSFLAGS} CC=${CT_TARGET}-${CT_CC}
CT_DoLog EXTRA "Installing gdbserver"
CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
CT_EndStep
fi
}
do_gdb_backend()
{
local host prefix destdir cflags ldflags static buildtype subdir
local -a extra_config
for arg in "$@"; do
case "$arg" in
--*)
extra_config+=("${arg}")
;;
*)
eval "${arg// /\\ }"
;;
esac
done
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
# Disable binutils options when building from the binutils-gdb repo.
extra_config+=("--disable-binutils")
extra_config+=("--disable-ld")
extra_config+=("--disable-gas")
if [ "${CT_GDB_HAS_DISABLE_CXX_BUILD}" = "y" ]; then
extra_config+=("--disable-build-with-cxx")
fi
case "${CT_THREADS}" in
none) extra_config+=("--disable-threads");;
*) extra_config+=("--enable-threads");;
esac
if [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ]; then
extra_config+=("--disable-nls")
fi
# 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
# 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}"}
}

25
scripts/upgrade/v2 Normal file
View File

@ -0,0 +1,25 @@
# vim: set filetype=sh :
# Upgrade v2 -> v3: unified build of native gdb and gdbserver,
# combining their options
upgrade()
{
case "${opt}" in
CT_GDB_GDBSERVER_BUILD_IPA_LIB)
replace CT_GDB_NATIVE_BUILD_IPA_LIB
;;
CT_GDB_GDBSERVER_STATIC)
if [ "${CT_GDB_GDBSERVER_STATIC}" != "${CT_GDB_GDBSERVER_STATIC}" ]; then
warning "Both native gdb and gdbserver must now be built in the same way"
fi
unset opt
;;
CT_GDB_GDBSERVER_STATIC_LIBSTDCXX)
replace GDB_NATIVE_STATIC_LIBSTDCXX
;;
CT_GDB_GDBSERVER_HAS_IPA_LIB)
# not user-selectable
unset opt
;;
esac
}

File diff suppressed because it is too large Load Diff

View File

@ -117,19 +117,28 @@ curver=`sed -n 's,export CT_CONFIG_VERSION_CURRENT=,,p' ${CTNG}`
if [ -z "${curver}" ]; then
echo "Cannot determine config version" >&${LOG}
fail
elif [ ! -r "kconfig-list/${curver}" ]; then
echo "No saved kconfig data for version ${curver}" >&${LOG}
fail
else
grep -hr '^\(menu\)\?config ' "${dirs[@]}" ../../config | \
grep -v '^Binary ' | \
sed 's,^.* ,CT_,' | LANG=C sort | uniq > logs/current-kconfig-list
diff -U 10000 "kconfig-list/${curver}" logs/current-kconfig-list | \
grep '^-CT_' > logs/current-kconfig-retired || true
nretired=`wc -l logs/current-kconfig-retired | sed 's/ .*//'`
echo "${nretired} kconfig options have been removed without bumping the config version" >&${LOG}
if [ "${nretired}" != "0" ]; then
if [ ! -r "kconfig-list/${curver}" ]; then
echo "No saved kconfig data for version ${curver}" >&${LOG}
if [ -r "kconfig-list/$[ curver - 1 ]" ]; then
echo "Comparing with previous version $[ curver - 1 ]"
echo "Verify that the following options are handled:"
diff -U 10000 "kconfig-list/$[ curver - 1 ]" logs/current-kconfig-list | \
grep '^-CT_' || true
echo "Then rename logs/current-kconfig-list to kconfig-list/${curver}"
fi >&${LOG}
fail
else
diff -U 10000 "kconfig-list/${curver}" logs/current-kconfig-list | \
grep '^-CT_' > logs/current-kconfig-retired || true
nretired=`wc -l logs/current-kconfig-retired | sed 's/ .*//'`
if [ "${nretired}" != "0" ]; then
echo "${nretired} kconfig options have been removed without bumping the config version" >&${LOG}
fail
fi
fi
fi
finish