Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/gdb: build and link libbfd and libopcodes as static libraries
@ 2023-12-25 22:54 Thomas Petazzoni via buildroot
  2023-12-27 21:13 ` Yann E. MORIN
  2024-01-10 15:25 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-12-25 22:54 UTC (permalink / raw)
  To: buildroot; +Cc: Thomas Petazzoni

Since GDB 13.x and upstream commit
b686ecb5b10be9a33ab8f1bfdcff22eef920d1a5 ("gdb: link executables with
libtool"), gdb will be linked against the shared variants of libbfd
and libopcodes if they exist. However, this causes host gdb and target
gdb to not work, because our gdb package does not install libbfd and
libopcodes (to not clash with the ones potentially installed by
binutils).

In order to get around this, this commit proposes to get back to the
situation we had before GDB 13.x: libbfd and libopcodes are only
compiled as static libraries, so that they are linked directly inside
the gdb binary, avoiding the problem entirely.

This resolves:

 # gdb --version
 gdb: error while loading shared libraries: libopcodes-2.39.50.so: cannot open shared object file: No such file or directory

for target gdb, and:

 $ ./host/bin/arm-linux-gdb --version
 ./host/bin/arm-linux-gdb: error while loading shared libraries: libopcodes-2.39.50.so: cannot open shared object file: No such file or directory

for host gdb.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 package/gdb/gdb.mk | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/package/gdb/gdb.mk b/package/gdb/gdb.mk
index 070598b385..ea710f0c1f 100644
--- a/package/gdb/gdb.mk
+++ b/package/gdb/gdb.mk
@@ -121,8 +121,10 @@ GDB_MAKE_ENV += \
 GDB_CONF_ENV += gdb_cv_prfpregset_t_broken=no
 GDB_MAKE_ENV += gdb_cv_prfpregset_t_broken=no
 
-# The shared only build is not supported by gdb, so enable static build for
-# build-in libraries with --enable-static.
+# We want the built-in libraries of gdb (libbfd, libopcodes) to be
+# built and linked statically, as we do not install them on the
+# target, to not clash with the ones potentially installed by
+# binutils. This is why we pass --enable-static --disable-shared.
 GDB_CONF_OPTS = \
 	--without-uiout \
 	--disable-gdbtk \
@@ -132,6 +134,7 @@ GDB_CONF_OPTS = \
 	--without-included-gettext \
 	--disable-werror \
 	--enable-static \
+	--disable-shared \
 	--without-mpfr \
 	--disable-source-highlight
 
@@ -248,10 +251,14 @@ endif
 # A few notes:
 #  * --target, because we're doing a cross build rather than a real
 #    host build.
-#  * --enable-static because gdb really wants to use libbfd.a
+#  * --enable-static --disable-shared because we want host gdb to
+#    build and link against a static version of libbfd and
+#    libopcodes, because we don't install the shared variants of
+#    those libraries in $(HOST_DIR), as it might clash with binutils
 HOST_GDB_CONF_OPTS = \
 	--target=$(GNU_TARGET_NAME) \
 	--enable-static \
+	--disable-shared \
 	--without-uiout \
 	--disable-gdbtk \
 	--without-x \
-- 
2.43.0

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

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

* Re: [Buildroot] [PATCH] package/gdb: build and link libbfd and libopcodes as static libraries
  2023-12-25 22:54 [Buildroot] [PATCH] package/gdb: build and link libbfd and libopcodes as static libraries Thomas Petazzoni via buildroot
@ 2023-12-27 21:13 ` Yann E. MORIN
  2024-01-10 15:25 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Yann E. MORIN @ 2023-12-27 21:13 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: buildroot

Thomas, All,

On 2023-12-25 23:54 +0100, Thomas Petazzoni via buildroot spake thusly:
> Since GDB 13.x and upstream commit
> b686ecb5b10be9a33ab8f1bfdcff22eef920d1a5 ("gdb: link executables with
> libtool"), gdb will be linked against the shared variants of libbfd
> and libopcodes if they exist. However, this causes host gdb and target
> gdb to not work, because our gdb package does not install libbfd and
> libopcodes (to not clash with the ones potentially installed by
> binutils).
> 
> In order to get around this, this commit proposes to get back to the
> situation we had before GDB 13.x: libbfd and libopcodes are only
> compiled as static libraries, so that they are linked directly inside
> the gdb binary, avoiding the problem entirely.
> 
> This resolves:
> 
>  # gdb --version
>  gdb: error while loading shared libraries: libopcodes-2.39.50.so: cannot open shared object file: No such file or directory
> 
> for target gdb, and:
> 
>  $ ./host/bin/arm-linux-gdb --version
>  ./host/bin/arm-linux-gdb: error while loading shared libraries: libopcodes-2.39.50.so: cannot open shared object file: No such file or directory
> 
> for host gdb.
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  package/gdb/gdb.mk | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/package/gdb/gdb.mk b/package/gdb/gdb.mk
> index 070598b385..ea710f0c1f 100644
> --- a/package/gdb/gdb.mk
> +++ b/package/gdb/gdb.mk
> @@ -121,8 +121,10 @@ GDB_MAKE_ENV += \
>  GDB_CONF_ENV += gdb_cv_prfpregset_t_broken=no
>  GDB_MAKE_ENV += gdb_cv_prfpregset_t_broken=no
>  
> -# The shared only build is not supported by gdb, so enable static build for
> -# build-in libraries with --enable-static.
> +# We want the built-in libraries of gdb (libbfd, libopcodes) to be
> +# built and linked statically, as we do not install them on the
> +# target, to not clash with the ones potentially installed by
> +# binutils. This is why we pass --enable-static --disable-shared.
>  GDB_CONF_OPTS = \
>  	--without-uiout \
>  	--disable-gdbtk \
> @@ -132,6 +134,7 @@ GDB_CONF_OPTS = \
>  	--without-included-gettext \
>  	--disable-werror \
>  	--enable-static \
> +	--disable-shared \
>  	--without-mpfr \
>  	--disable-source-highlight
>  
> @@ -248,10 +251,14 @@ endif
>  # A few notes:
>  #  * --target, because we're doing a cross build rather than a real
>  #    host build.
> -#  * --enable-static because gdb really wants to use libbfd.a
> +#  * --enable-static --disable-shared because we want host gdb to
> +#    build and link against a static version of libbfd and
> +#    libopcodes, because we don't install the shared variants of
> +#    those libraries in $(HOST_DIR), as it might clash with binutils
>  HOST_GDB_CONF_OPTS = \
>  	--target=$(GNU_TARGET_NAME) \
>  	--enable-static \
> +	--disable-shared \
>  	--without-uiout \
>  	--disable-gdbtk \
>  	--without-x \
> -- 
> 2.43.0
> 
> _______________________________________________
> 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] 3+ messages in thread

* Re: [Buildroot] [PATCH] package/gdb: build and link libbfd and libopcodes as static libraries
  2023-12-25 22:54 [Buildroot] [PATCH] package/gdb: build and link libbfd and libopcodes as static libraries Thomas Petazzoni via buildroot
  2023-12-27 21:13 ` Yann E. MORIN
@ 2024-01-10 15:25 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2024-01-10 15:25 UTC (permalink / raw)
  To: Thomas Petazzoni via buildroot; +Cc: Thomas Petazzoni

>>>>> "Thomas" == Thomas Petazzoni via buildroot <buildroot@buildroot.org> writes:

 > Since GDB 13.x and upstream commit
 > b686ecb5b10be9a33ab8f1bfdcff22eef920d1a5 ("gdb: link executables with
 > libtool"), gdb will be linked against the shared variants of libbfd
 > and libopcodes if they exist. However, this causes host gdb and target
 > gdb to not work, because our gdb package does not install libbfd and
 > libopcodes (to not clash with the ones potentially installed by
 > binutils).

 > In order to get around this, this commit proposes to get back to the
 > situation we had before GDB 13.x: libbfd and libopcodes are only
 > compiled as static libraries, so that they are linked directly inside
 > the gdb binary, avoiding the problem entirely.

 > This resolves:

 >  # gdb --version
 >  gdb: error while loading shared libraries: libopcodes-2.39.50.so: cannot open shared object file: No such file or directory

 > for target gdb, and:

 >  $ ./host/bin/arm-linux-gdb --version
 >  ./host/bin/arm-linux-gdb: error while loading shared libraries:
 > libopcodes-2.39.50.so: cannot open shared object file: No such file or
 > directory

 > for host gdb.

 > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Committed to 2023.11.x, thanks.

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

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

end of thread, other threads:[~2024-01-10 15:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-25 22:54 [Buildroot] [PATCH] package/gdb: build and link libbfd and libopcodes as static libraries Thomas Petazzoni via buildroot
2023-12-27 21:13 ` Yann E. MORIN
2024-01-10 15:25 ` Peter Korsgaard

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