diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2024-03-14 13:39:18 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2024-03-14 13:40:08 -0400 |
commit | da48217f315084097ef25226c0acab3bbd55ebd3 (patch) | |
tree | 22b9b0342f9b0923ec951b9cd9a238579c95e93c /gdbserver/configure.ac | |
parent | 91e15dbaf9d05747fab0d33e5af7ae69c983398a (diff) | |
download | gdb-da48217f315084097ef25226c0acab3bbd55ebd3.zip gdb-da48217f315084097ef25226c0acab3bbd55ebd3.tar.gz gdb-da48217f315084097ef25226c0acab3bbd55ebd3.tar.bz2 |
gdbserver/linux: probe for libiconv in configure
Make gdbserver's build system locate libiconv when building for Linux.
Commit 07b3255c3bae ("Filter invalid encodings from Linux thread names")
make libiconv madantory for building gdbserver on Linux.
While trying to cross-compile gdb for xtensa-fsf-linux-uclibc (with a
toolchain generated with crosstool-ng), I got:
/home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:48:10: fatal error: iconv.h: No such file or directory
48 | #include <iconv.h>
| ^~~~~~~~~
I downloaded GNU libiconv, built it for that host, and installed it in
an arbitrary directory. I had to modify the gdbserver build system to
locate libiconv and use it, the result is this patch.
I eventually found that crosstool-ng has a config option to make uclibc
provide an implementation of iconv, which is of course much easier. But
given that this patch is now written, I think it would be worth merging
it, it could help some people who do not have iconv built-in their libc
in the future (and may not have the luxury of rebuilding their libc like
I do).
Using AM_ICONV in configure.ac adds these options for configure (the
same we have for gdb):
--with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
--without-libiconv-prefix don't search for libiconv in includedir and libdir
--with-libiconv-type=TYPE type of library to search for (auto/static/shared)
It sets the `LIBICONV` variable with whatever is needed to link with
libiconv, and adds the necessary `-I` flag to `CPPFLAGS`.
To avoid unnecessarily linking against libiconv on hosts that don't need
it, set `MAYBE_LIBICONV` with the contents of `LIBICONV` only if the
host is Linux, and use `MAYBE_LIBICONV` in `Makefile.in`.
Since libiconv is a hard requirement for Linux hosts, error out if it is
not found.
The bits in acinclude.m4 are similar to what we have in
gdb/acinclude.m4.
Update the top-level build system to support building against an in-tree
libiconv (I did not test this part though). Something tells me that the
all-gdbserver dependency on all-libiconv is unnecessary, since there is
already a dependency of configure-gdbserver on all-libiconv (and
all-gdbserver surely depends on configure-gdbserver). I just copied
what's done for GDB though.
ChangeLog:
* Makefile.def: Add configure-gdbserver and all-gdbserver
dependencies on all-libiconv.
* Makefile.in: Re-generate.
Change-Id: I90f8ef88dd4917df5a68b45550d93622fc9cfed4
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdbserver/configure.ac')
-rw-r--r-- | gdbserver/configure.ac | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac index 280043d..ee0de9d 100644 --- a/gdbserver/configure.ac +++ b/gdbserver/configure.ac @@ -456,6 +456,22 @@ if test x"$STDINT_H" != x; then fi AC_SUBST(GNULIB_STDINT_H) +# Check for libiconv. It is a requirement for Linux hosts, and others hosts +# don't use it at all. Define MAYBE_LIBICONV only if the host is Linux. +AM_ICONV +MAYBE_LIBICONV= +case "$host" in + *linux*) + if test "$am_cv_func_iconv" != yes; then + AC_MSG_ERROR([could not find libiconv (required for host $host)]) + fi + + MAYBE_LIBICONV="$LIBICONV" + ;; +esac + +AC_SUBST(MAYBE_LIBICONV) + AC_CONFIG_FILES([Makefile]) AC_OUTPUT |