* [PATCH] Support building when fts and obstack aren't part of libc.
@ 2020-10-26 2:41 Érico Nogueira
2020-10-26 9:32 ` Dmitry V. Levin
0 siblings, 1 reply; 3+ messages in thread
From: Érico Nogueira @ 2020-10-26 2:41 UTC (permalink / raw)
To: elfutils-devel
- Make configure.ac test for fts and obstack availability;
- Add fts and obstack ldflags to all files that need them;
- Add missing argp ldflags to programs in debuginfod/.
Signed-off-by: Érico Rolim <erico.erc@gmail.com>
---
This is the start of a series of patches that can enable elfutils to be
built on musl-based distros out of the box.
I will send them as separate mails, since upstreaming any of the
necessary patches should still help with avoiding duplication across
distros as well as lowering the maintenance burden.
ChangeLog | 4 ++++
configure.ac | 54 ++++++++++++++++++++++++++++++++++++++++++
debuginfod/Makefile.am | 6 ++---
libdw/Makefile.am | 2 +-
src/Makefile.am | 6 ++---
5 files changed, 65 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 72e8397c..10587886 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-10-25 Érico N. Rolim <erico.erc@gmail.com>
+
+ * configure.ac: Check for fts and obstack from outside libc.
+
2020-10-01 Frank Ch. Eigler <fche@redhat.com>
PR25461
diff --git a/configure.ac b/configure.ac
index 973409f1..628e7a74 100644
--- a/configure.ac
+++ b/configure.ac
@@ -542,6 +542,60 @@ else
fi
AC_SUBST([argp_LDADD])
+dnl Check if we have fts available from our libc
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#if !defined(__x86_64__)
+ #undef _FILE_OFFSET_BITS
+ #define _FILE_OFFSET_BITS 32
+ #endif
+ #include <fts.h>],
+ [FTS* fts = 0; return fts_close(fts); return 0;]
+ )],
+ [libc_has_fts="true"],
+ [libc_has_fts="false"]
+)
+
+dnl If our libc doesn't provide fts, then test for libfts
+if test "$libc_has_fts" = "false" ; then
+ AC_MSG_WARN("libc does not have fts")
+ AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"])
+
+ if test "$have_fts" = "false"; then
+ AC_MSG_ERROR("no libfts found")
+ else
+ fts_LDADD="-lfts"
+ fi
+else
+ fts_LDADD=""
+fi
+AC_SUBST([fts_LDADD])
+
+dnl Check if we have obstack available from our libc
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#include <obstack.h>],
+ [_obstack_begin(0, 0, 0, NULL, NULL); return 0;]
+ )],
+ [libc_has_obstack="true"],
+ [libc_has_obstack="false"]
+)
+
+dnl If our libc doesn't provide obstack, then test for libobstack
+if test "$libc_has_obstack" = "false" ; then
+ AC_MSG_WARN("libc does not have obstack")
+ AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"])
+
+ if test "$have_obstack" = "false"; then
+ AC_MSG_ERROR("no libobstack found")
+ else
+ obstack_LDADD="-lobstack"
+ fi
+else
+ obstack_LDADD=""
+fi
+AC_SUBST([obstack_LDADD])
+
dnl The directories with content.
dnl Documentation.
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 01985600..bdb6d8a4 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
endif
debuginfod_SOURCES = debuginfod.cxx
-debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
+debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LDADD) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
debuginfod_find_SOURCES = debuginfod-find.c
-debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
+debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LDADD)
if LIBDEBUGINFOD
noinst_LIBRARIES = libdebuginfod.a
@@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
if DUMMY_LIBDEBUGINFOD
libdebuginfod_so_LDLIBS =
else
-libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
+libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LDADD)
endif
libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 33b5838d..af30825b 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
../libcpu/libcpu_pic.a libdw_pic.a ../libdwelf/libdwelf_pic.a \
../libdwfl/libdwfl_pic.a
libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
-libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) -pthread
+libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) $(zip_LIBS) -pthread
libdw_so_SOURCES =
libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
diff --git a/src/Makefile.am b/src/Makefile.am
index e462e7d7..cade82ff 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
unstrip_no_Wstack_usage = yes
readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
+nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD) \
$(demanglelib)
size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
objdump_LDADD = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
+ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD)
strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
+ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD)
unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
--
2.28.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Support building when fts and obstack aren't part of libc.
2020-10-26 2:41 [PATCH] Support building when fts and obstack aren't part of libc Érico Nogueira
@ 2020-10-26 9:32 ` Dmitry V. Levin
2020-10-26 14:52 ` Érico Nogueira
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry V. Levin @ 2020-10-26 9:32 UTC (permalink / raw)
To: Érico Nogueira; +Cc: elfutils-devel
On Sun, Oct 25, 2020 at 11:41:12PM -0300, Érico Nogueira via Elfutils-devel wrote:
> - Make configure.ac test for fts and obstack availability;
> - Add fts and obstack ldflags to all files that need them;
> - Add missing argp ldflags to programs in debuginfod/.
>
> Signed-off-by: Érico Rolim <erico.erc@gmail.com>
> ---
>
> This is the start of a series of patches that can enable elfutils to be
> built on musl-based distros out of the box.
>
> I will send them as separate mails, since upstreaming any of the
> necessary patches should still help with avoiding duplication across
> distros as well as lowering the maintenance burden.
>
> ChangeLog | 4 ++++
> configure.ac | 54 ++++++++++++++++++++++++++++++++++++++++++
> debuginfod/Makefile.am | 6 ++---
> libdw/Makefile.am | 2 +-
> src/Makefile.am | 6 ++---
> 5 files changed, 65 insertions(+), 7 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 72e8397c..10587886 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,7 @@
> +2020-10-25 Érico N. Rolim <erico.erc@gmail.com>
> +
> + * configure.ac: Check for fts and obstack from outside libc.
> +
> 2020-10-01 Frank Ch. Eigler <fche@redhat.com>
>
> PR25461
> diff --git a/configure.ac b/configure.ac
> index 973409f1..628e7a74 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -542,6 +542,60 @@ else
> fi
> AC_SUBST([argp_LDADD])
>
> +dnl Check if we have fts available from our libc
> +AC_LINK_IFELSE(
> + [AC_LANG_PROGRAM(
> + [#if !defined(__x86_64__)
> + #undef _FILE_OFFSET_BITS
> + #define _FILE_OFFSET_BITS 32
> + #endif
> + #include <fts.h>],
> + [FTS* fts = 0; return fts_close(fts); return 0;]
> + )],
> + [libc_has_fts="true"],
> + [libc_has_fts="false"]
> +)
> +
> +dnl If our libc doesn't provide fts, then test for libfts
> +if test "$libc_has_fts" = "false" ; then
> + AC_MSG_WARN("libc does not have fts")
> + AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"])
> +
> + if test "$have_fts" = "false"; then
> + AC_MSG_ERROR("no libfts found")
> + else
> + fts_LDADD="-lfts"
> + fi
> +else
> + fts_LDADD=""
> +fi
> +AC_SUBST([fts_LDADD])
If you are looking for fts providers, I suggest using AC_SEARCH_LIBS
instead, e.g.
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([fts_close], [fts])
LIBS="$saved_LIBS"
case "$ac_cv_search_fts_close" in
no) AC_MSG_FAILURE([failed to find fts_close]) ;;
-l*) fts_LIBS="$ac_cv_search_fts_close" ;;
*) fts_LIBS= ;;
esac
AC_SUBST([fts_LIBS])
> +dnl Check if we have obstack available from our libc
> +AC_LINK_IFELSE(
> + [AC_LANG_PROGRAM(
> + [#include <obstack.h>],
> + [_obstack_begin(0, 0, 0, NULL, NULL); return 0;]
> + )],
> + [libc_has_obstack="true"],
> + [libc_has_obstack="false"]
> +)
> +
> +dnl If our libc doesn't provide obstack, then test for libobstack
> +if test "$libc_has_obstack" = "false" ; then
> + AC_MSG_WARN("libc does not have obstack")
> + AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"])
> +
> + if test "$have_obstack" = "false"; then
> + AC_MSG_ERROR("no libobstack found")
> + else
> + obstack_LDADD="-lobstack"
> + fi
> +else
> + obstack_LDADD=""
> +fi
> +AC_SUBST([obstack_LDADD])
Likewise, e.g.
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([obstack_free], [obstack])
LIBS="$saved_LIBS"
case "$ac_cv_search_obstack_free" in
no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
-l*) obstack_LIBS="$ac_cv_search_obstack_free" ;;
*) obstack_LIBS= ;;
esac
AC_SUBST([obstack_LIBS])
--
ldv
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Support building when fts and obstack aren't part of libc.
2020-10-26 9:32 ` Dmitry V. Levin
@ 2020-10-26 14:52 ` Érico Nogueira
0 siblings, 0 replies; 3+ messages in thread
From: Érico Nogueira @ 2020-10-26 14:52 UTC (permalink / raw)
To: Dmitry V. Levin; +Cc: elfutils-devel
On Mon Oct 26, 2020 at 9:32 AM -03, Dmitry V. Levin wrote:
> On Sun, Oct 25, 2020 at 11:41:12PM -0300, Érico Nogueira via
> Elfutils-devel wrote:
> > diff --git a/configure.ac b/configure.ac
> > index 973409f1..628e7a74 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -542,6 +542,60 @@ else
> > fi
> > AC_SUBST([argp_LDADD])
> >
> > +dnl Check if we have fts available from our libc
> > +AC_LINK_IFELSE(
> > + [AC_LANG_PROGRAM(
> > + [#if !defined(__x86_64__)
> > + #undef _FILE_OFFSET_BITS
> > + #define _FILE_OFFSET_BITS 32
> > + #endif
> > + #include <fts.h>],
> > + [FTS* fts = 0; return fts_close(fts); return 0;]
> > + )],
> > + [libc_has_fts="true"],
> > + [libc_has_fts="false"]
> > +)
> > +
> > +dnl If our libc doesn't provide fts, then test for libfts
> > +if test "$libc_has_fts" = "false" ; then
> > + AC_MSG_WARN("libc does not have fts")
> > + AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"])
> > +
> > + if test "$have_fts" = "false"; then
> > + AC_MSG_ERROR("no libfts found")
> > + else
> > + fts_LDADD="-lfts"
> > + fi
> > +else
> > + fts_LDADD=""
> > +fi
> > +AC_SUBST([fts_LDADD])
>
> If you are looking for fts providers, I suggest using AC_SEARCH_LIBS
> instead, e.g.
>
> saved_LIBS="$LIBS"
> AC_SEARCH_LIBS([fts_close], [fts])
> LIBS="$saved_LIBS"
> case "$ac_cv_search_fts_close" in
> no) AC_MSG_FAILURE([failed to find fts_close]) ;;
> -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
> *) fts_LIBS= ;;
> esac
> AC_SUBST([fts_LIBS])
This does look a bit simpler, thanks. I will check it locally and come
back with a new patch.
> > +dnl Check if we have obstack available from our libc
> > +AC_LINK_IFELSE(
> > + [AC_LANG_PROGRAM(
> > + [#include <obstack.h>],
> > + [_obstack_begin(0, 0, 0, NULL, NULL); return 0;]
> > + )],
> > + [libc_has_obstack="true"],
> > + [libc_has_obstack="false"]
> > +)
> > +
> > +dnl If our libc doesn't provide obstack, then test for libobstack
> > +if test "$libc_has_obstack" = "false" ; then
> > + AC_MSG_WARN("libc does not have obstack")
> > + AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"])
> > +
> > + if test "$have_obstack" = "false"; then
> > + AC_MSG_ERROR("no libobstack found")
> > + else
> > + obstack_LDADD="-lobstack"
> > + fi
> > +else
> > + obstack_LDADD=""
> > +fi
> > +AC_SUBST([obstack_LDADD])
>
> Likewise, e.g.
>
> saved_LIBS="$LIBS"
> AC_SEARCH_LIBS([obstack_free], [obstack])
> LIBS="$saved_LIBS"
> case "$ac_cv_search_obstack_free" in
> no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
> -l*) obstack_LIBS="$ac_cv_search_obstack_free" ;;
> *) obstack_LIBS= ;;
> esac
> AC_SUBST([obstack_LIBS])
>
>
> --
> ldv
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-26 14:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 2:41 [PATCH] Support building when fts and obstack aren't part of libc Érico Nogueira
2020-10-26 9:32 ` Dmitry V. Levin
2020-10-26 14:52 ` Érico Nogueira
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).