Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/gdb: gdbserver does not need zlib
@ 2023-09-17 15:23 Yann E. MORIN
  2023-09-17 19:32 ` Arnout Vandecappelle via buildroot
  2023-09-25  5:33 ` Peter Korsgaard
  0 siblings, 2 replies; 4+ messages in thread
From: Yann E. MORIN @ 2023-09-17 15:23 UTC (permalink / raw)
  To: buildroot
  Cc: Julien Olivain, Yann E. MORIN, Thomas Petazzoni, Fabrice Fontaine

Since 3341ceb1e585 (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 7af8dee3a8a0 (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 onlyt build gdbserver, we tell configure to not use a system
zlib, which triggers a build of the bundled one, which we do not use...

Reported-by: Julien Olivain <ju.o@free.fr>
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 package/gdb/Config.in |  2 +-
 package/gdb/gdb.mk    | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/package/gdb/Config.in b/package/gdb/Config.in
index 20fd262c93..e4ab39a2bd 100644
--- a/package/gdb/Config.in
+++ b/package/gdb/Config.in
@@ -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.
@@ -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
diff --git a/package/gdb/gdb.mk b/package/gdb/gdb.mk
index 0d41548ed0..070598b385 100644
--- a/package/gdb/gdb.mk
+++ b/package/gdb/gdb.mk
@@ -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
@@ -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
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH] package/gdb: gdbserver does not need zlib
  2023-09-17 15:23 [Buildroot] [PATCH] package/gdb: gdbserver does not need zlib Yann E. MORIN
@ 2023-09-17 19:32 ` Arnout Vandecappelle via buildroot
  2023-09-17 19:41   ` Yann E. MORIN
  2023-09-25  5:33 ` Peter Korsgaard
  1 sibling, 1 reply; 4+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2023-09-17 19:32 UTC (permalink / raw)
  To: Yann E. MORIN, buildroot
  Cc: Julien Olivain, Fabrice Fontaine, Thomas Petazzoni



On 17/09/2023 17:23, Yann E. MORIN wrote:
> Since 3341ceb1e585 (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 7af8dee3a8a0 (package/tcl: add mandatory
> dependency to zlib)

  So this commit should be reverted now?


> 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 onlyt build gdbserver, we tell configure to not use a system
> zlib, which triggers a build of the bundled one, which we do not use...

  I didn't think this paragraph was very clear, so I reformulated it a little, 
and applied to master, thanks.

  Regards,
  Arnout

> 
> Reported-by: Julien Olivain <ju.o@free.fr>
> Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
>   package/gdb/Config.in |  2 +-
>   package/gdb/gdb.mk    | 14 ++++++++++----
>   2 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/package/gdb/Config.in b/package/gdb/Config.in
> index 20fd262c93..e4ab39a2bd 100644
> --- a/package/gdb/Config.in
> +++ b/package/gdb/Config.in
> @@ -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.
> @@ -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
> diff --git a/package/gdb/gdb.mk b/package/gdb/gdb.mk
> index 0d41548ed0..070598b385 100644
> --- a/package/gdb/gdb.mk
> +++ b/package/gdb/gdb.mk
> @@ -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
> @@ -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
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH] package/gdb: gdbserver does not need zlib
  2023-09-17 19:32 ` Arnout Vandecappelle via buildroot
@ 2023-09-17 19:41   ` Yann E. MORIN
  0 siblings, 0 replies; 4+ messages in thread
From: Yann E. MORIN @ 2023-09-17 19:41 UTC (permalink / raw)
  To: Arnout Vandecappelle
  Cc: Julien Olivain, Fabrice Fontaine, Thomas Petazzoni, buildroot

Arnout, All,

On 2023-09-17 21:32 +0200, Arnout Vandecappelle via buildroot spake thusly:
> On 17/09/2023 17:23, Yann E. MORIN wrote:
[--SNIP--]
> >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 7af8dee3a8a0 (package/tcl: add mandatory
> >dependency to zlib)
>  So this commit should be reverted now?

No, because tcl unconditionally uses zlib: either a bundled version, or
the system one. 7af8dee3a8a0 ensured the system one is available and
used.

> >So, when we onlyt build gdbserver, we tell configure to not use a system
> >zlib, which triggers a build of the bundled one, which we do not use...
>  I didn't think this paragraph was very clear, so I reformulated it a
> little, and applied to master, thanks.

Better, indeed, thanks!

Regards,
Yann E. MORIN.

>  Regards,
>  Arnout
> 
> >
> >Reported-by: Julien Olivain <ju.o@free.fr>
> >Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> >Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> >Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> >---
> >  package/gdb/Config.in |  2 +-
> >  package/gdb/gdb.mk    | 14 ++++++++++----
> >  2 files changed, 11 insertions(+), 5 deletions(-)
> >
> >diff --git a/package/gdb/Config.in b/package/gdb/Config.in
> >index 20fd262c93..e4ab39a2bd 100644
> >--- a/package/gdb/Config.in
> >+++ b/package/gdb/Config.in
> >@@ -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.
> >@@ -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
> >diff --git a/package/gdb/gdb.mk b/package/gdb/gdb.mk
> >index 0d41548ed0..070598b385 100644
> >--- a/package/gdb/gdb.mk
> >+++ b/package/gdb/gdb.mk
> >@@ -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
> >@@ -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
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH] package/gdb: gdbserver does not need zlib
  2023-09-17 15:23 [Buildroot] [PATCH] package/gdb: gdbserver does not need zlib Yann E. MORIN
  2023-09-17 19:32 ` Arnout Vandecappelle via buildroot
@ 2023-09-25  5:33 ` Peter Korsgaard
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Korsgaard @ 2023-09-25  5:33 UTC (permalink / raw)
  To: Yann E. MORIN
  Cc: Julien Olivain, Fabrice Fontaine, Thomas Petazzoni, buildroot

>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > Since 3341ceb1e585 (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 7af8dee3a8a0 (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 onlyt build gdbserver, we tell configure to not use a system
 > zlib, which triggers a build of the bundled one, which we do not use...

 > Reported-by: Julien Olivain <ju.o@free.fr>
 > Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
 > Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
 > Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Committed to 2023.02.x, 2023.05.x and 2023.08.x, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-25  5:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-17 15:23 [Buildroot] [PATCH] package/gdb: gdbserver does not need zlib Yann E. MORIN
2023-09-17 19:32 ` Arnout Vandecappelle via buildroot
2023-09-17 19:41   ` Yann E. MORIN
2023-09-25  5:33 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox