@@ -, +, @@ --enable-libdebuginfod=dummy. --- ChangeLog | 6 ++++++ Makefile.am | 6 +----- configure.ac | 34 ++++++++++++++++++++++++++++------ debuginfod/ChangeLog | 17 +++++++++++++++++ debuginfod/Makefile.am | 32 ++++++++++++++++++++++++++++++-- debuginfod/debuginfod-client.c | 31 +++++++++++++++++++++++++++---- debuginfod/debuginfod.cxx | 1 - doc/ChangeLog | 4 ++++ doc/Makefile.am | 4 +++- tests/ChangeLog | 5 +++++ tests/Makefile.am | 3 +++ 11 files changed, 124 insertions(+), 19 deletions(-) --- a/ChangeLog +++ a/ChangeLog @@ -1,3 +1,9 @@ +2020-06-19 Mark Wielaard + + * Makefile.am (SUBDIRS): Always add debuginfod. + * configure.ac (debuginfod): Split off... + (libdebuginfod): ... this. Also add DUMME_DEBUGINFOD. + 2020-06-15 Sergei Trofimovich * configure.ac: Use READELF in build-id check. --- a/Makefile.am +++ a/Makefile.am @@ -27,11 +27,7 @@ AM_MAKEFLAGS = --no-print-directory pkginclude_HEADERS = version.h SUBDIRS = config m4 lib libelf libcpu backends libebl libdwelf libdwfl libdw \ - libasm src po doc tests - -if DEBUGINFOD -SUBDIRS += debuginfod -endif + libasm debuginfod src po doc tests EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \ COPYING COPYING-GPLV2 COPYING-LGPLV3 --- a/configure.ac +++ a/configure.ac @@ -676,19 +676,40 @@ if test "$HAVE_BUNZIP2" = "no"; then AC_MSG_WARN([No bunzip2, needed to run make check]) fi -# Look for libmicrohttpd, libcurl, libarchive, sqlite for debuginfo server -# minimum versions as per rhel7. Single --enable-* option arranges to build -# both client and server. -AC_ARG_ENABLE([debuginfod],AC_HELP_STRING([--enable-debuginfod], [Build debuginfod server and client])) +# Look for libcurl for libdebuginfod minimum version as per rhel7. +AC_ARG_ENABLE([libdebuginfod],AC_HELP_STRING([--enable-libdebuginfod], [Build debuginfod client library (can be =dummy)])) +AS_IF([test "x$enable_libdebuginfod" != "xno"], [ + if test "x$enable_libdebuginfod" != "xdummy"; then + AC_MSG_NOTICE([checking libdebuginfod dependencies, --disable-libdebuginfod or --enable-libdebuginfo=dummy to skip]) + enable_libdebuginfod=yes # presume success + PKG_PROG_PKG_CONFIG + PKG_CHECK_MODULES([libcurl],[libcurl >= 7.29.0],[],[enable_libdebuginfod=no]) + if test "x$enable_libdebuginfod" = "xno"; then + AC_MSG_ERROR([dependencies not found, use --disable-libdebuginfod to disable or --enable-libdebuginfod=dummy to build a (bootstrap) dummy library.]) + fi + else + AC_MSG_NOTICE([building (bootstrap) dummy libdebuginfo library]) + fi +]) + +AS_IF([test "x$enable_libdebuginfod" = "xdummy"],AC_DEFINE([DUMMY_LIBDEBUGINFOD],[1],[Build dummy libdebuginfod])) +AM_CONDITIONAL([LIBDEBUGINFOD],[test "x$enable_libdebuginfod" = "xyes" || test "x$enable_libdebuginfod" = "xdummy"]) +AM_CONDITIONAL([DUMMY_LIBDEBUGINFOD],[test "x$enable_libdebuginfod" = "xdummy"]) + +# Look for libmicrohttpd, libarchive, sqlite for debuginfo server +# minimum versions as per rhel7. +AC_ARG_ENABLE([debuginfod],AC_HELP_STRING([--enable-debuginfod], [Build debuginfod server])) AC_PROG_CXX AS_IF([test "x$enable_debuginfod" != "xno"], [ AC_MSG_NOTICE([checking debuginfod C++11 support, --disable-debuginfod to skip]) AX_CXX_COMPILE_STDCXX(11, noext, mandatory) AC_MSG_NOTICE([checking debuginfod dependencies, --disable-debuginfod to skip]) + if test "x$enable_libdebuginfod" = "xno"; then + AC_MSG_ERROR([need libdebuginfod (or dummy), use --disable-debuginfod to disable.]) + fi enable_debuginfod=yes # presume success PKG_PROG_PKG_CONFIG PKG_CHECK_MODULES([libmicrohttpd],[libmicrohttpd >= 0.9.33],[],[enable_debuginfod=no]) - PKG_CHECK_MODULES([libcurl],[libcurl >= 7.29.0],[],[enable_debuginfod=no]) PKG_CHECK_MODULES([sqlite3],[sqlite3 >= 3.7.17],[],[enable_debuginfod=no]) PKG_CHECK_MODULES([libarchive],[libarchive >= 3.1.2],[],[enable_debuginfod=no]) if test "x$enable_debuginfod" = "xno"; then @@ -729,7 +750,8 @@ AC_MSG_NOTICE([ Deterministic archives by default : ${default_ar_deterministic} Native language support : ${USE_NLS} Extra Valgrind annotations : ${use_vg_annotations} - Debuginfod client/server support : ${enable_debuginfod} + libdebuginfod client support : ${enable_libdebuginfod} + Debuginfod server support : ${enable_debuginfod} EXTRA TEST FEATURES (used with make check) have bunzip2 installed (required) : ${HAVE_BUNZIP2} --- a/debuginfod/ChangeLog +++ a/debuginfod/ChangeLog @@ -1,3 +1,20 @@ +2020-06-19 Mark Wielaard + + * Makefile.am (bin_PROGRAMS): Guard with DEBUGINFOD and + LIBDEBUGINFOD. + (debuginfod_LDADD): Remove libcurl. + (libdebuginfod): When static and DUMMY_LIBDEBUGINFO remove libcurl. + (noinst_LIBRARIES): Guard with LIBDEBUGINFOD. + (AM_CPPFLAGS): Add -Wno-unused-parameter when DUMMY_LIBDEBUGINFOD. + (pkginclude_headers): Guard with LIBDEBUGINFOD + (libdebuginfod_so_LIBS): Likewise. + (+libdebuginfod_so_LDLIBS): Likewise. + (install): Likewise. + (uninstall): Likewise. + * debuginfod-client.c: Include dummy functions when + DUMMY_LIBDEBUGINFOD. + * debuginfod.cxx: Remove curl.h include. + 2020-03-29 Mark Wielaard * debuginfod-client.c (debuginfod_add_http_header): Check header --- a/debuginfod/Makefile.am +++ a/debuginfod/Makefile.am @@ -45,8 +45,12 @@ if BUILD_STATIC libasm = ../libasm/libasm.a libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) $(libebl) -ldl -lpthread libelf = ../libelf/libelf.a -lz +if DUMMY_LIBDEBUGINFOD libdebuginfod = ./libdebuginfod.a $(libcurl_LIBS) else +libdebuginfod = ./libdebuginfod.a +endif +else libasm = ../libasm/libasm.so libdw = ../libdw/libdw.so libelf = ../libelf/libelf.so @@ -57,24 +61,45 @@ libeu = ../lib/libeu.a AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw:. -bin_PROGRAMS = debuginfod debuginfod-find +bin_PROGRAMS = +if DEBUGINFOD +bin_PROGRAMS += debuginfod +endif + +if LIBDEBUGINFOD +bin_PROGRAMS += debuginfod-find +endif + debuginfod_SOURCES = debuginfod.cxx -debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(libcurl_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl +debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl debuginfod_find_SOURCES = debuginfod-find.c debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) +if LIBDEBUGINFOD noinst_LIBRARIES = libdebuginfod.a noinst_LIBRARIES += libdebuginfod_pic.a +endif libdebuginfod_a_SOURCES = debuginfod-client.c libdebuginfod_pic_a_SOURCES = debuginfod-client.c am_libdebuginfod_pic_a_OBJECTS = $(libdebuginfod_a_SOURCES:.c=.os) +if DUMMY_LIBDEBUGINFOD +AM_CPPFLAGS += -Wno-unused-parameter +endif + +if LIBDEBUGINFOD pkginclude_HEADERS = debuginfod.h +endif +if LIBDEBUGINFOD libdebuginfod_so_LIBS = libdebuginfod_pic.a +if DUMMY_LIBDEBUGINFOD +libdebuginfod_so_LDLIBS = +else libdebuginfod_so_LDLIBS = $(libcurl_LIBS) +endif libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS) $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \ -Wl,--soname,$@.$(VERSION) \ @@ -83,7 +108,9 @@ libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS) $(libdebuginfod_so_LDLIBS) @$(textrel_check) $(AM_V_at)ln -fs $@ $@.$(VERSION) +endif +if LIBDEBUGINFOD install: install-am libdebuginfod.so $(mkinstalldirs) $(DESTDIR)$(libdir) $(INSTALL_PROGRAM) libdebuginfod.so $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so @@ -95,6 +122,7 @@ uninstall: uninstall-am rm -f $(DESTDIR)$(libdir)/libdebuginfod.so.$(VERSION) rm -f $(DESTDIR)$(libdir)/libdebuginfod.so rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/elfutils +endif EXTRA_DIST = libdebuginfod.map MOSTLYCLEANFILES = $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so.$(VERSION) --- a/debuginfod/debuginfod-client.c +++ a/debuginfod/debuginfod-client.c @@ -26,7 +26,6 @@ the GNU Lesser General Public License along with this program. If not, see . */ - /* cargo-cult from libdwfl linux-kernel-modules.c */ /* In case we have a bad fts we include this before config.h because it can't handle _FILE_OFFSET_BITS. @@ -39,15 +38,37 @@ #endif #include "config.h" -#include "debuginfod.h" #include "system.h" +#include +#include +#include "debuginfod.h" + +/* We might be building a bootstrap dummy library, which is really simple. */ +#ifdef DUMMY_LIBDEBUGINFOD + +debuginfod_client *debuginfod_begin (void) { errno = ENOSYS; return NULL; } +int debuginfod_find_debuginfo (debuginfod_client *c, const unsigned char *b, + int s, char **p) { return -ENOSYS; } +int debuginfod_find_executable (debuginfod_client *c, const unsigned char *b, + int s, char **p) { return -ENOSYS; } +int debuginfod_find_source (debuginfod_client *c, const unsigned char *b, + int s, const char *f, char **p) { return -ENOSYS; } +void debuginfod_set_progressfn(debuginfod_client *c, + debuginfod_progressfn_t fn) { } +void debuginfod_set_user_data (debuginfod_client *c, void *d) { } +void* debuginfod_get_user_data (debuginfod_client *c) { return NULL; } +const char* debuginfod_get_url (debuginfod_client *c) { return NULL; } +int debuginfod_add_http_header (debuginfod_client *c, + const char*h) { return -ENOSYS; } +void debuginfod_end (debuginfod_client *c) { } + +#else /* DUMMY_LIBDEBUGINFOD */ + #include #include #include -#include #include #include -#include #include #include #include @@ -1079,3 +1100,5 @@ __attribute__((destructor)) attribute_hidden void libdebuginfod_dtor(void) /* ... so don't do this: */ /* curl_global_cleanup(); */ } + +#endif /* DUMMY_LIBDEBUGINFOD */ --- a/debuginfod/debuginfod.cxx +++ a/debuginfod/debuginfod.cxx @@ -92,7 +92,6 @@ using namespace std; #include #include -#include #include #include #include --- a/doc/ChangeLog +++ a/doc/ChangeLog @@ -1,3 +1,7 @@ +2020-06-19 Mark Wielaard + + * Makefile.am: Guard all client manpages with LIBDEBUGINFOD. + 2020-03-29 Mark Wielaard * debuginfod_find_debuginfo.3 (HTTP HEADER): Document the expected --- a/doc/Makefile.am +++ a/doc/Makefile.am @@ -24,6 +24,9 @@ notrans_dist_man1_MANS= if DEBUGINFOD notrans_dist_man8_MANS += debuginfod.8 +endif + +if LIBDEBUGINFOD notrans_dist_man3_MANS += debuginfod_add_http_header.3 notrans_dist_man3_MANS += debuginfod_begin.3 notrans_dist_man3_MANS += debuginfod_end.3 @@ -36,4 +39,3 @@ notrans_dist_man3_MANS += debuginfod_set_progressfn.3 notrans_dist_man3_MANS += debuginfod_set_user_data.3 notrans_dist_man1_MANS += debuginfod-find.1 endif - --- a/tests/ChangeLog +++ a/tests/ChangeLog @@ -1,3 +1,8 @@ +2020-06-19 Mark Wielaard + + * Makefile.am (TESTS): Don't add run-debuginfod-find.sh when + DUMMY_LIBDEBUGINFOD. + 2020-06-16 Mark Wielaard * coverage.sh: Use /usr/bin/env bash. --- a/tests/Makefile.am +++ a/tests/Makefile.am @@ -210,8 +210,11 @@ endif if DEBUGINFOD check_PROGRAMS += debuginfod_build_id_find +# With the dummy delegation doesn't work +if !DUMMY_LIBDEBUGINFOD TESTS += run-debuginfod-find.sh endif +endif EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ run-show-die-info.sh run-get-files.sh run-get-lines.sh \ --