]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: Add --disable-libdebuginfod and --enable-libdebuginfod=dummy.
authorMark Wielaard <mark@klomp.org>
Fri, 19 Jun 2020 17:41:08 +0000 (19:41 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 3 Jul 2020 23:30:07 +0000 (01:30 +0200)
Make it possible to build just the debuginfod client or to create a
dummy libdebuginfod that doesn't link against libcurl. The dummy library
can be used for bootstrapping. For testing purposes you can also build
debuginfod against the dummy libdebuginfod but then the debuginfod
server will not be able to do delegation.

Signed-off-by: Mark Wielaard <mark@klomp.org>
ChangeLog
Makefile.am
configure.ac
debuginfod/ChangeLog
debuginfod/Makefile.am
debuginfod/debuginfod-client.c
doc/ChangeLog
doc/Makefile.am
tests/ChangeLog
tests/Makefile.am

index 8e79ec5cfd6d1ce1cc84cdf129df1b8c3ff12222..99f5049226cebfceab92cd412cca3244e4340830 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-06-19  Mark Wielaard  <mark@klomp.org>
+
+       * Makefile.am (SUBDIRS): Always add debuginfod.
+       * configure.ac (debuginfod): Split off...
+       (libdebuginfod): ... this. Also add DUMME_DEBUGINFOD.
+
 2020-06-15  Sergei Trofimovich <slyfox@gentoo.org>
 
        * configure.ac: Use READELF in build-id check.
index bd8926b523442fa831652369e0a48abd33275f29..f68f096644a1e409352c2c39aa297f4f55a73093 100644 (file)
@@ -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
index 8d3bcb7b674a778500360258c20ab2ec618e1dad..6f04d2693314d4c0a8266444e3319555352399ef 100644 (file)
@@ -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}
index 2bbd5db5b440a4bc67f0936a808f37c3de2e1a0d..372173e784fbbe093e13c01792a1825a095672d5 100644 (file)
@@ -1,3 +1,20 @@
+2020-06-19  Mark Wielaard  <mark@klomp.org>
+
+       * 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-06-16  Mark Wielaard  <mark@klomp.org>
 
        * debuginfod-client.c (debuginfod_query_server): Check malloc.
index 51965f65dbb781f4e3b405a51b9f75ab8b209cb0..2e8a343ca4dc817dec9279accd09b645bc09e189 100644 (file)
@@ -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)
index c2aa4e10aafce5621edb443bc429693f20a963da..c2e43f743ab64c0a16fb8cec132a7e51df89db6e 100644 (file)
 #include "config.h"
 #include "debuginfod.h"
 #include "system.h"
+#include <errno.h>
+#include <stdlib.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 <assert.h>
 #include <dirent.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <fts.h>
 #include <regex.h>
@@ -1090,3 +1112,5 @@ __attribute__((destructor)) attribute_hidden void libdebuginfod_dtor(void)
   /* ... so don't do this: */
   /* curl_global_cleanup(); */
 }
+
+#endif /* DUMMY_LIBDEBUGINFOD */
index f598b7f271052b23c25a951b585355af8e823f28..e0485004826a1d77278e8090dd27b2c1fccba30a 100644 (file)
@@ -1,3 +1,7 @@
+2020-06-19  Mark Wielaard  <mark@klomp.org>
+
+       * Makefile.am: Guard all client manpages with LIBDEBUGINFOD.
+
 2020-03-29  Mark Wielaard  <mark@klomp.org>
 
        * debuginfod_find_debuginfo.3 (HTTP HEADER): Document the expected
index f0c7e55dfa410a1effc83d1d247785411ca2e85a..ef66fb88e6b00bfa4701e8d388773a88c9036c63 100644 (file)
@@ -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
-
index 05220bd7c387e106664ba72ef548394c6bb07280..b27037eeec3b8b8babafedbee7f5c2dc32c653eb 100644 (file)
@@ -1,3 +1,8 @@
+2020-06-19  Mark Wielaard  <mark@klomp.org>
+
+       * Makefile.am (TESTS): Don't add run-debuginfod-find.sh when
+       DUMMY_LIBDEBUGINFOD.
+
 2020-06-16  Mark Wielaard  <mark@klomp.org>
 
        * coverage.sh: Use /usr/bin/env bash.
index 53dd70a7d0366fab8b5722a9f8f3cf6bb01d316b..5ac805c524035fa687c199e3a9d12be51475a1e1 100644 (file)
@@ -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 \