Skip to content

Commit

Permalink
package/gdb: gdbserver does not need zlib
Browse files Browse the repository at this point in the history
Since 3341ceb (package/gdb: zlib is mandatory, not optional), zlib
has become a mandatory dependencies of the gdb package.

However, zlib is only needed for the debugger, gdb itself, while the
server, gdbserver, does not use it.

This means that, when building an SDK to be later reused as an external
toolchain, the zlib headers and libraries are present in the sysroot of
the toolchain, tainting the toolchain and making it unsuitable to be
reused.

As Julien noticed, for example, tcl will try and link with zlib if
available, and at build time it is. But at runtime, it is not, and thus
tclsh fails to run; see 7af8dee (package/tcl: add mandatory
dependency to zlib)

When we only need to build gdbserver, we still need to configure and
build the whole gdb distribution, which means we call the top-level
configure script; that script has no option to disable the detection
of zlib: it wants to either use a system one, or it will build the
bundled one.

So, when we only build gdbserver, we tell configure to not use a system
zlib. This triggers the build of the bundled one, but it is not linked
with gdbserver so in the end it is not used on the target.

Reported-by: Julien Olivain <[email protected]>
Reported-by: Thomas Petazzoni <[email protected]>
Signed-off-by: Yann E. MORIN <[email protected]>
Cc: Fabrice Fontaine <[email protected]>
Signed-off-by: Arnout Vandecappelle <[email protected]>
  • Loading branch information
yann-morin-1998 authored and arnout committed Sep 17, 2023
1 parent de0f8c6 commit 8ce33fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package/gdb/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ config BR2_PACKAGE_GDB
# The or1k musl port is incomplete, elf_gregset_t definition is missing:
# https://git.musl-libc.org/cgit/musl/tree/arch/or1k/bits/user.h?h=v1.2.3
depends on !BR2_or1k || !BR2_TOOLCHAIN_USES_MUSL
select BR2_PACKAGE_ZLIB
# When the external toolchain gdbserver is copied to the
# target, we don't allow building a separate gdbserver. The
# one from the external toolchain should be used.
Expand Down Expand Up @@ -61,6 +60,7 @@ config BR2_PACKAGE_GDB_DEBUGGER
depends on !BR2_sh
select BR2_PACKAGE_GMP if !BR2_arc
select BR2_PACKAGE_NCURSES
select BR2_PACKAGE_ZLIB

comment "full gdb on target needs a toolchain w/ wchar"
depends on !BR2_sh
Expand Down
14 changes: 10 additions & 4 deletions package/gdb/gdb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ GDB_PRE_CONFIGURE_HOOKS += GDB_CONFIGURE_SYMLINK
# also need ncurses.
# As for libiberty, gdb may use a system-installed one if present, so
# we must ensure ours is installed first.
GDB_DEPENDENCIES = zlib
HOST_GDB_DEPENDENCIES = host-expat host-libiberty host-ncurses host-zlib

# Disable building documentation
Expand Down Expand Up @@ -131,22 +130,29 @@ GDB_CONF_OPTS = \
--disable-sim \
$(GDB_DISABLE_BINUTILS_CONF_OPTS) \
--without-included-gettext \
--with-system-zlib \
--disable-werror \
--enable-static \
--without-mpfr \
--disable-source-highlight

ifeq ($(BR2_PACKAGE_GDB_DEBUGGER),y)
GDB_DEPENDENCIES += zlib
GDB_CONF_OPTS += \
--enable-gdb \
--with-curses
--with-curses \
--with-system-zlib
GDB_DEPENDENCIES += ncurses \
$(if $(BR2_PACKAGE_LIBICONV),libiconv)
else
# When only building gdbserver, we don't need zlib. But we have no way to
# tell the top-level configure that we don't need zlib: it either wants to
# build the bundled one, or use the system one.
# Since we're going to only install the gdbserver to the target, we don't
# care that the bundled zlib is built, as it is not used.
GDB_CONF_OPTS += \
--disable-gdb \
--without-curses
--without-curses \
--without-system-zlib
endif

# Starting from GDB 11.x, gmp is needed as a dependency to build full
Expand Down

0 comments on commit 8ce33fe

Please sign in to comment.