public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
@ 2020-11-30  9:00 Dmitry V. Levin
  2020-12-06 12:06 ` Mark Wielaard
  0 siblings, 1 reply; 21+ messages in thread
From: Dmitry V. Levin @ 2020-11-30  9:00 UTC (permalink / raw)
  To: elfutils-devel

Add DEBUGINFOD_SONAME macro to API for use by those of libdebuginfod
clients that would like to dlopen the library in the same way as
__libdwfl_debuginfod_init does.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 ChangeLog                                    |  5 +++++
 configure.ac                                 |  5 ++++-
 debuginfod/ChangeLog                         |  8 ++++++++
 debuginfod/Makefile.am                       | 13 ++++++-------
 debuginfod/{debuginfod.h => debuginfod.h.in} |  3 +++
 5 files changed, 26 insertions(+), 8 deletions(-)
 rename debuginfod/{debuginfod.h => debuginfod.h.in} (97%)

diff --git a/ChangeLog b/ChangeLog
index 565d021c..71e80a25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-30  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* configure.ac (LIBDEBUGINFOD_SONAME): New AC_SUBST variable.
+	(AC_CONFIG_FILES): Add debuginfod/debuginfod.h.
+
 2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
 
 	* configure.ac: Check for fts and obstack from outside libc.
diff --git a/configure.ac b/configure.ac
index c1a6954d..2f7316e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,9 @@ m4_ifndef([AC_PACKAGE_URL],
                     [Define to home page for this package])
           AC_SUBST([PACKAGE_URL], ["http://elfutils.org/"])])
 
+LIBDEBUGINFOD_SONAME=libdebuginfod.so.1
+AC_SUBST([LIBDEBUGINFOD_SONAME])
+
 # We want eu- as default program prefix if none was given by the user.
 # But if the user explicitly provided --program-prefix="" then pretend
 # it wasn't set at all (NONE). We want to test this really early before
@@ -61,7 +64,7 @@ dnl The RPM spec file.  We substitute a few values in the file.
 AC_CONFIG_FILES([elfutils.spec:config/elfutils.spec.in])
 
 dnl debuginfo-server client & server parts.
-AC_CONFIG_FILES([debuginfod/Makefile])
+AC_CONFIG_FILES([debuginfod/Makefile debuginfod/debuginfod.h])
 
 AC_CANONICAL_HOST
 
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 3039371f..77fc49e1 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,5 +1,13 @@
 2020-11-30  Dmitry V. Levin  <ldv@altlinux.org>
 
+	* Makefile.am (VERSION): Remove.
+	(libdebuginfod.so): Replace $@.$(VERSION) with $(LIBDEBUGINFOD_SONAME)
+	(install, uninstall, MOSTLYCLEANFILES): Replace
+	libdebuginfod.so.$(VERSION) with $(LIBDEBUGINFOD_SONAME).
+	* debuginfod.h: Rename to ...
+	* debuginfod.h.in ... this.
+	(DEBUGINFOD_SONAME): New macro.
+
 	* Makefile.am (libdebuginfod.so$(EXEEXT)): Drop $(EXEEXT) suffix.
 
 2020-11-25  Frank Ch. Eigler  <fche@redhat.com>
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 352b4915..93423c85 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -34,7 +34,6 @@ AM_CPPFLAGS += -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
 	   -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
 	   $(libmicrohttpd_CFLAGS) $(libcurl_CFLAGS) $(sqlite3_CFLAGS) \
 	   $(libarchive_CFLAGS)
-VERSION = 1
 
 # Disable eu- prefixing for artifacts (binaries & man pages) in this
 # directory, since they do not conflict with binutils tools.
@@ -102,30 +101,30 @@ libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
 endif
 libdebuginfod.so: $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
-		-Wl,--soname,$@.$(VERSION) \
+		-Wl,--soname,$(LIBDEBUGINFOD_SONAME) \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(libdebuginfod_so_LIBS) -Wl,--no-whole-archive \
 		$(libdebuginfod_so_LDLIBS)
 	@$(textrel_check)
-	$(AM_V_at)ln -fs $@ $@.$(VERSION)
+	$(AM_V_at)ln -fs $@ $(LIBDEBUGINFOD_SONAME)
 endif
 
 if LIBDEBUGINFOD
 install: install-am libdebuginfod.so
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
 	$(INSTALL_PROGRAM) libdebuginfod.so $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
-	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so.$(VERSION)
-	ln -fs libdebuginfod.so.$(VERSION) $(DESTDIR)$(libdir)/libdebuginfod.so
+	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
+	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so
 
 uninstall: uninstall-am
 	rm -f $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
-	rm -f $(DESTDIR)$(libdir)/libdebuginfod.so.$(VERSION)
+	rm -f $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
 	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)
+MOSTLYCLEANFILES = $(am_libdebuginfod_pic_a_OBJECTS) $(LIBDEBUGINFOD_SONAME)
 CLEANFILES += $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so
 
 # automake std-options override: arrange to pass LD_LIBRARY_PATH
diff --git a/debuginfod/debuginfod.h b/debuginfod/debuginfod.h.in
similarity index 97%
rename from debuginfod/debuginfod.h
rename to debuginfod/debuginfod.h.in
index 4ee86ce9..559ea947 100644
--- a/debuginfod/debuginfod.h
+++ b/debuginfod/debuginfod.h.in
@@ -36,6 +36,9 @@
 #define DEBUGINFOD_PROGRESS_ENV_VAR "DEBUGINFOD_PROGRESS"
 #define DEBUGINFOD_VERBOSE_ENV_VAR "DEBUGINFOD_VERBOSE"
 
+/* The libdebuginfod soname.  */
+#define DEBUGINFOD_SONAME "@LIBDEBUGINFOD_SONAME@"
+
 /* Handle for debuginfod-client connection.  */
 typedef struct debuginfod_client debuginfod_client;
 
-- 
ldv

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

* Re: [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-11-30  9:00 [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h Dmitry V. Levin
@ 2020-12-06 12:06 ` Mark Wielaard
  2020-12-06 12:28   ` Dmitry V. Levin
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Wielaard @ 2020-12-06 12:06 UTC (permalink / raw)
  To: Dmitry V. Levin, elfutils-devel

Hi Dmitry,

On Mon, 2020-11-30 at 09:00 +0000, Dmitry V. Levin wrote:
> Add DEBUGINFOD_SONAME macro to API for use by those of libdebuginfod
> clients that would like to dlopen the library in the same way as
> __libdwfl_debuginfod_init does.

I can see how this is useful, but shouldn't libdwfl/debuginfod-client.c 
then also use this method/new constants?

Don't we need both versioned and versionless names (at least dwfl tries
the versioned one first, then falls back to the unversioned one).

It would be nice to see documentation in
doc/debuginfod_find_debuginfo.3

Finally, I am actually using the Makefile VERSION variable in a
downstream (DTS) to make sure the so name of all libraries is different
from the system one. This is just a minor issue though, and I should
probably upstream a tweak to do this upstream so others can also more
easily use this.

Cheers,

Mark

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

* Re: [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-06 12:06 ` Mark Wielaard
@ 2020-12-06 12:28   ` Dmitry V. Levin
  2020-12-06 13:32     ` Frank Ch. Eigler
  2020-12-08 12:02     ` [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h Mark Wielaard
  0 siblings, 2 replies; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-06 12:28 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

Hi Mark,

On Sun, Dec 06, 2020 at 01:06:42PM +0100, Mark Wielaard wrote:
> Hi Dmitry,
> 
> On Mon, 2020-11-30 at 09:00 +0000, Dmitry V. Levin wrote:
> > Add DEBUGINFOD_SONAME macro to API for use by those of libdebuginfod
> > clients that would like to dlopen the library in the same way as
> > __libdwfl_debuginfod_init does.
> 
> I can see how this is useful, but shouldn't libdwfl/debuginfod-client.c 
> then also use this method/new constants?

Thanks, I think libdwfl/debuginfod-client.c should use the versioned name
only, and it shouldn't fallback to "libdebuginfod.so" as it does now.
I'll submit a separate patch to address that.

> Don't we need both versioned and versionless names (at least dwfl tries
> the versioned one first, then falls back to the unversioned one).

I don't think the versioned name should be exported because it changes
in every version while clients don't have to be rebuilt that often.

> It would be nice to see documentation in
> doc/debuginfod_find_debuginfo.3

Yes, it would be nice, agreed.

> Finally, I am actually using the Makefile VERSION variable in a
> downstream (DTS) to make sure the so name of all libraries is different
> from the system one. This is just a minor issue though, and I should
> probably upstream a tweak to do this upstream so others can also more
> easily use this.

Do you suggest to keep the Makefile VERSION variable?
It would become an unused variable with the remaining part of the patch
applied unless you upstream the tweak you are talking about.


-- 
ldv

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

* Re: [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-06 12:28   ` Dmitry V. Levin
@ 2020-12-06 13:32     ` Frank Ch. Eigler
  2020-12-06 13:34       ` Dmitry V. Levin
  2020-12-08 12:02     ` [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h Mark Wielaard
  1 sibling, 1 reply; 21+ messages in thread
From: Frank Ch. Eigler @ 2020-12-06 13:32 UTC (permalink / raw)
  To: Dmitry V. Levin; +Cc: Mark Wielaard, elfutils-devel

Hi -

> Thanks, I think libdwfl/debuginfod-client.c should use the versioned name
> only, and it shouldn't fallback to "libdebuginfod.so" as it does now.

I believe the code falls back to the unversioned soname because only
that is available in the build tree (as opposed to the install tree).

- FChE


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

* Re: [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-06 13:32     ` Frank Ch. Eigler
@ 2020-12-06 13:34       ` Dmitry V. Levin
  2020-12-06 13:54         ` [PATCH v2 1/3] " Dmitry V. Levin
                           ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-06 13:34 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: Mark Wielaard, elfutils-devel

On Sun, Dec 06, 2020 at 08:32:43AM -0500, Frank Ch. Eigler wrote:
> Hi -
> 
> > Thanks, I think libdwfl/debuginfod-client.c should use the versioned name
> > only, and it shouldn't fallback to "libdebuginfod.so" as it does now.
> 
> I believe the code falls back to the unversioned soname because only
> that is available in the build tree (as opposed to the install tree).

Yes, and this is exactly the thing I'm going to fix.


-- 
ldv

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

* [PATCH v2 1/3] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-06 13:34       ` Dmitry V. Levin
@ 2020-12-06 13:54         ` Dmitry V. Levin
  2020-12-06 13:54         ` [PATCH v2 2/3] debuginfod: create the fully versioned libdebuginfod file name during build Dmitry V. Levin
  2020-12-06 13:54         ` [PATCH v2 3/3] libdwfl: do not fall back to dlopen of libdebuginfod.so Dmitry V. Levin
  2 siblings, 0 replies; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-06 13:54 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard, Frank Ch. Eigler

Add DEBUGINFOD_SONAME macro to API for use by those of libdebuginfod
clients that would like to dlopen the library in the same way as
__libdwfl_debuginfod_init does.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 ChangeLog                                    |  5 +++++
 configure.ac                                 |  5 ++++-
 debuginfod/ChangeLog                         |  8 ++++++++
 debuginfod/Makefile.am                       | 12 ++++++------
 debuginfod/{debuginfod.h => debuginfod.h.in} |  3 +++
 doc/ChangeLog                                |  4 ++++
 doc/debuginfod_find_debuginfo.3              | 15 +++++++++++++++
 7 files changed, 45 insertions(+), 7 deletions(-)
 rename debuginfod/{debuginfod.h => debuginfod.h.in} (97%)

diff --git a/ChangeLog b/ChangeLog
index 565d021c..71e80a25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-30  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* configure.ac (LIBDEBUGINFOD_SONAME): New AC_SUBST variable.
+	(AC_CONFIG_FILES): Add debuginfod/debuginfod.h.
+
 2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
 
 	* configure.ac: Check for fts and obstack from outside libc.
diff --git a/configure.ac b/configure.ac
index c1a6954d..2f7316e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,9 @@ m4_ifndef([AC_PACKAGE_URL],
                     [Define to home page for this package])
           AC_SUBST([PACKAGE_URL], ["http://elfutils.org/"])])
 
+LIBDEBUGINFOD_SONAME=libdebuginfod.so.1
+AC_SUBST([LIBDEBUGINFOD_SONAME])
+
 # We want eu- as default program prefix if none was given by the user.
 # But if the user explicitly provided --program-prefix="" then pretend
 # it wasn't set at all (NONE). We want to test this really early before
@@ -61,7 +64,7 @@ dnl The RPM spec file.  We substitute a few values in the file.
 AC_CONFIG_FILES([elfutils.spec:config/elfutils.spec.in])
 
 dnl debuginfo-server client & server parts.
-AC_CONFIG_FILES([debuginfod/Makefile])
+AC_CONFIG_FILES([debuginfod/Makefile debuginfod/debuginfod.h])
 
 AC_CANONICAL_HOST
 
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 3039371f..07899289 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,5 +1,13 @@
 2020-11-30  Dmitry V. Levin  <ldv@altlinux.org>
 
+	* Makefile.am (libdebuginfod.so): Replace $@.$(VERSION) with
+	$(LIBDEBUGINFOD_SONAME).
+	(install, uninstall, MOSTLYCLEANFILES): Replace
+	libdebuginfod.so.$(VERSION) with $(LIBDEBUGINFOD_SONAME).
+	* debuginfod.h: Rename to ...
+	* debuginfod.h.in ... this.
+	(DEBUGINFOD_SONAME): New macro.
+
 	* Makefile.am (libdebuginfod.so$(EXEEXT)): Drop $(EXEEXT) suffix.
 
 2020-11-25  Frank Ch. Eigler  <fche@redhat.com>
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 352b4915..34f34acf 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -102,30 +102,30 @@ libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
 endif
 libdebuginfod.so: $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
-		-Wl,--soname,$@.$(VERSION) \
+		-Wl,--soname,$(LIBDEBUGINFOD_SONAME) \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(libdebuginfod_so_LIBS) -Wl,--no-whole-archive \
 		$(libdebuginfod_so_LDLIBS)
 	@$(textrel_check)
-	$(AM_V_at)ln -fs $@ $@.$(VERSION)
+	$(AM_V_at)ln -fs $@ $(LIBDEBUGINFOD_SONAME)
 endif
 
 if LIBDEBUGINFOD
 install: install-am libdebuginfod.so
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
 	$(INSTALL_PROGRAM) libdebuginfod.so $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
-	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so.$(VERSION)
-	ln -fs libdebuginfod.so.$(VERSION) $(DESTDIR)$(libdir)/libdebuginfod.so
+	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
+	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so
 
 uninstall: uninstall-am
 	rm -f $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
-	rm -f $(DESTDIR)$(libdir)/libdebuginfod.so.$(VERSION)
+	rm -f $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
 	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)
+MOSTLYCLEANFILES = $(am_libdebuginfod_pic_a_OBJECTS) $(LIBDEBUGINFOD_SONAME)
 CLEANFILES += $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so
 
 # automake std-options override: arrange to pass LD_LIBRARY_PATH
diff --git a/debuginfod/debuginfod.h b/debuginfod/debuginfod.h.in
similarity index 97%
rename from debuginfod/debuginfod.h
rename to debuginfod/debuginfod.h.in
index 4ee86ce9..559ea947 100644
--- a/debuginfod/debuginfod.h
+++ b/debuginfod/debuginfod.h.in
@@ -36,6 +36,9 @@
 #define DEBUGINFOD_PROGRESS_ENV_VAR "DEBUGINFOD_PROGRESS"
 #define DEBUGINFOD_VERBOSE_ENV_VAR "DEBUGINFOD_VERBOSE"
 
+/* The libdebuginfod soname.  */
+#define DEBUGINFOD_SONAME "@LIBDEBUGINFOD_SONAME@"
+
 /* Handle for debuginfod-client connection.  */
 typedef struct debuginfod_client debuginfod_client;
 
diff --git a/doc/ChangeLog b/doc/ChangeLog
index fdf352e7..d8f21dd6 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-06  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* debuginfod_find_debuginfo.3: Document DEBUGINFOD_SONAME macro.
+
 2020-11-11  Mark Wielaard  <mark@klomp.org>
 
 	* debuginfod_find_debuginfo.3: Document debuginfod_set_verbose_fd
diff --git a/doc/debuginfod_find_debuginfo.3 b/doc/debuginfod_find_debuginfo.3
index 3c6d52f5..36c08490 100644
--- a/doc/debuginfod_find_debuginfo.3
+++ b/doc/debuginfod_find_debuginfo.3
@@ -209,6 +209,21 @@ removed from the cache during cleaning. These files should contain only an
 ASCII decimal integer representing the interval or max unused age in seconds.
 The default is one day and one week, respectively.  Values of zero mean "immediately".
 
+.SH "MACROS"
+
+.SS "DEBUGINFOD_SONAME"
+
+Defined to the string that could be passed to
+.BR dlopen (3)
+if the library is loaded at runtime, for example
+
+.PP
+.in +4n
+.EX
+void *debuginfod_so = dlopen(DEBUGINFOD_SONAME, RTLD_LAZY);
+.EE
+.in
+
 .SH "SECURITY"
 .BR debuginfod_find_debuginfo (),
 .BR debuginfod_find_executable (),
-- 
ldv

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

* [PATCH v2 2/3] debuginfod: create the fully versioned libdebuginfod file name during build
  2020-12-06 13:34       ` Dmitry V. Levin
  2020-12-06 13:54         ` [PATCH v2 1/3] " Dmitry V. Levin
@ 2020-12-06 13:54         ` Dmitry V. Levin
  2020-12-06 14:44           ` [PATCH v2 4/3] debuginfod: create libdebuginfod files using a race-free method Dmitry V. Levin
  2020-12-06 13:54         ` [PATCH v2 3/3] libdwfl: do not fall back to dlopen of libdebuginfod.so Dmitry V. Levin
  2 siblings, 1 reply; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-06 13:54 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard, Frank Ch. Eigler

When the fully versioned file name is available, the fall back to dlopen
of "libdebuginfod.so" in __libdwfl_debuginfod_init is no longer needed.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 debuginfod/ChangeLog   |  7 +++++++
 debuginfod/Makefile.am | 10 ++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 07899289..27abdfda 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,3 +1,10 @@
+2020-12-06  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* Makefile.am (LIBDEBUGINFOD_FULL_NAME): New variable.
+	(libdebuginfod.so): Use it to create the fully versioned file name.
+	(install, uninstall): Replace libdebuginfod-$(PACKAGE_VERSION).so with
+	$(LIBDEBUGINFOD_FULL_NAME).
+
 2020-11-30  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* Makefile.am (libdebuginfod.so): Replace $@.$(VERSION) with
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 34f34acf..7df66125 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -100,6 +100,7 @@ libdebuginfod_so_LDLIBS =
 else
 libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
 endif
+LIBDEBUGINFOD_FULL_NAME = libdebuginfod-$(PACKAGE_VERSION).so
 libdebuginfod.so: $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
 		-Wl,--soname,$(LIBDEBUGINFOD_SONAME) \
@@ -107,18 +108,19 @@ libdebuginfod.so: $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
 		-Wl,--whole-archive $(libdebuginfod_so_LIBS) -Wl,--no-whole-archive \
 		$(libdebuginfod_so_LDLIBS)
 	@$(textrel_check)
+	$(AM_V_at)ln -fs $@ $(LIBDEBUGINFOD_FULL_NAME)
 	$(AM_V_at)ln -fs $@ $(LIBDEBUGINFOD_SONAME)
 endif
 
 if LIBDEBUGINFOD
 install: install-am libdebuginfod.so
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
-	$(INSTALL_PROGRAM) libdebuginfod.so $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
-	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
-	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so
+	$(INSTALL_PROGRAM) libdebuginfod.so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_FULL_NAME)
+	ln -fs $(LIBDEBUGINFOD_FULL_NAME) $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
+	ln -fs $(LIBDEBUGINFOD_FULL_NAME) $(DESTDIR)$(libdir)/libdebuginfod.so
 
 uninstall: uninstall-am
-	rm -f $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
+	rm -f $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_FULL_NAME)
 	rm -f $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
 	rm -f $(DESTDIR)$(libdir)/libdebuginfod.so
 	rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/elfutils
-- 
ldv

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

* [PATCH v2 3/3] libdwfl: do not fall back to dlopen of libdebuginfod.so
  2020-12-06 13:34       ` Dmitry V. Levin
  2020-12-06 13:54         ` [PATCH v2 1/3] " Dmitry V. Levin
  2020-12-06 13:54         ` [PATCH v2 2/3] debuginfod: create the fully versioned libdebuginfod file name during build Dmitry V. Levin
@ 2020-12-06 13:54         ` Dmitry V. Levin
  2 siblings, 0 replies; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-06 13:54 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard, Frank Ch. Eigler

The fully versioned libdebuginfod file name should always be available.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 libdwfl/ChangeLog           | 5 +++++
 libdwfl/debuginfod-client.c | 3 ---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 67a4d743..2f815b54 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-06  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* debuginfod-client.c (__libdwfl_debuginfod_init): Do not fall back
+	to dlopen of "libdebuginfod.so".
+
 2020-11-28  Mark Wielaard  <mark@klomp.org>
 
 	* dwfl_segment_report_module.c (dwfl_segment_report_module):
diff --git a/libdwfl/debuginfod-client.c b/libdwfl/debuginfod-client.c
index ee604ad9..2c4e1a16 100644
--- a/libdwfl/debuginfod-client.c
+++ b/libdwfl/debuginfod-client.c
@@ -103,9 +103,6 @@ __libdwfl_debuginfod_init (void)
 {
   void *debuginfod_so = dlopen("libdebuginfod-" VERSION ".so", RTLD_LAZY);
 
-  if (debuginfod_so == NULL)
-    debuginfod_so = dlopen("libdebuginfod.so", RTLD_LAZY);
-
   if (debuginfod_so != NULL)
     {
       fp_debuginfod_begin = dlsym (debuginfod_so, "debuginfod_begin");
-- 
ldv

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

* [PATCH v2 4/3] debuginfod: create libdebuginfod files using a race-free method
  2020-12-06 13:54         ` [PATCH v2 2/3] debuginfod: create the fully versioned libdebuginfod file name during build Dmitry V. Levin
@ 2020-12-06 14:44           ` Dmitry V. Levin
  0 siblings, 0 replies; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-06 14:44 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

Before this change, both the soname and the fully versioned
libdebuginfod file name were created after libdebuginfod.so, opening
a race for all libdebuginfod users that have Makefile dependencies
on libdebuginfod.so but actually use libdebuginfod.so.1 or the fully
versioned libdebuginfod file name.

After this change, the libdebuginfod.so symlink is created the last
of all libdebuginfod files, closing the race.
---
 debuginfod/ChangeLog   |  4 ++++
 debuginfod/Makefile.am | 12 ++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 27abdfda..03eabb6b 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,5 +1,9 @@
 2020-12-06  Dmitry V. Levin  <ldv@altlinux.org>
 
+	* Makefile.am [LIBDEBUGINFOD]: Create the fully versioned
+	libdebuginfod file name first, turn the soname and libdebuginfod.so
+	into symlinks.
+
 	* Makefile.am (LIBDEBUGINFOD_FULL_NAME): New variable.
 	(libdebuginfod.so): Use it to create the fully versioned file name.
 	(install, uninstall): Replace libdebuginfod-$(PACKAGE_VERSION).so with
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 7df66125..b667ad6d 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -101,21 +101,25 @@ else
 libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
 endif
 LIBDEBUGINFOD_FULL_NAME = libdebuginfod-$(PACKAGE_VERSION).so
-libdebuginfod.so: $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+$(LIBDEBUGINFOD_FULL_NAME): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
 		-Wl,--soname,$(LIBDEBUGINFOD_SONAME) \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(libdebuginfod_so_LIBS) -Wl,--no-whole-archive \
 		$(libdebuginfod_so_LDLIBS)
 	@$(textrel_check)
-	$(AM_V_at)ln -fs $@ $(LIBDEBUGINFOD_FULL_NAME)
-	$(AM_V_at)ln -fs $@ $(LIBDEBUGINFOD_SONAME)
+
+$(LIBDEBUGINFOD_SONAME): $(LIBDEBUGINFOD_FULL_NAME)
+	ln -fs $< $@
+
+libdebuginfod.so: $(LIBDEBUGINFOD_SONAME)
+	ln -fs $< $@
 endif
 
 if LIBDEBUGINFOD
 install: install-am libdebuginfod.so
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
-	$(INSTALL_PROGRAM) libdebuginfod.so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_FULL_NAME)
+	$(INSTALL_PROGRAM) $(LIBDEBUGINFOD_FULL_NAME) $(DESTDIR)$(libdir)/
 	ln -fs $(LIBDEBUGINFOD_FULL_NAME) $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
 	ln -fs $(LIBDEBUGINFOD_FULL_NAME) $(DESTDIR)$(libdir)/libdebuginfod.so
 
-- 
ldv

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

* Re: [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-06 12:28   ` Dmitry V. Levin
  2020-12-06 13:32     ` Frank Ch. Eigler
@ 2020-12-08 12:02     ` Mark Wielaard
  2020-12-08 13:30       ` Dmitry V. Levin
  2020-12-08 15:15       ` Dmitry V. Levin
  1 sibling, 2 replies; 21+ messages in thread
From: Mark Wielaard @ 2020-12-08 12:02 UTC (permalink / raw)
  To: Dmitry V. Levin; +Cc: elfutils-devel

On Sun, 2020-12-06 at 15:28 +0300, Dmitry V. Levin wrote:
> Hi Mark,
> 
> On Sun, Dec 06, 2020 at 01:06:42PM +0100, Mark Wielaard wrote:
> > Hi Dmitry,
> > 
> > On Mon, 2020-11-30 at 09:00 +0000, Dmitry V. Levin wrote:
> > > Add DEBUGINFOD_SONAME macro to API for use by those of libdebuginfod
> > > clients that would like to dlopen the library in the same way as
> > > __libdwfl_debuginfod_init does.
> > 
> > I can see how this is useful, but shouldn't libdwfl/debuginfod-client.c 
> > then also use this method/new constants?
> 
> Thanks, I think libdwfl/debuginfod-client.c should use the versioned name
> only, and it shouldn't fallback to "libdebuginfod.so" as it does now.
> I'll submit a separate patch to address that.

Thanks.

> > Don't we need both versioned and versionless names (at least dwfl tries
> > the versioned one first, then falls back to the unversioned one).
> 
> I don't think the versioned name should be exported because it changes
> in every version while clients don't have to be rebuilt that often.

I am slightly confused now what we call the versioned name. I assumed
that was the SONAME aka libdebuginfod.so.1. In theory we never change
the version, because we use symbol versioning. But yes, we only need to
export one for dlopen purposes.

> > It would be nice to see documentation in
> > doc/debuginfod_find_debuginfo.3
> 
> Yes, it would be nice, agreed.

Thanks for adding that.

> > Finally, I am actually using the Makefile VERSION variable in a
> > downstream (DTS) to make sure the so name of all libraries is different
> > from the system one. This is just a minor issue though, and I should
> > probably upstream a tweak to do this upstream so others can also more
> > easily use this.
> 
> Do you suggest to keep the Makefile VERSION variable?
> It would become an unused variable with the remaining part of the patch
> applied unless you upstream the tweak you are talking about.

Lets just remove it for now. I'll figure something out for my special
case.

Cheers,

Mark

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

* Re: [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-08 12:02     ` [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h Mark Wielaard
@ 2020-12-08 13:30       ` Dmitry V. Levin
  2020-12-08 15:15       ` Dmitry V. Levin
  1 sibling, 0 replies; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-08 13:30 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Tue, Dec 08, 2020 at 01:02:41PM +0100, Mark Wielaard wrote:
> On Sun, 2020-12-06 at 15:28 +0300, Dmitry V. Levin wrote:
> > On Sun, Dec 06, 2020 at 01:06:42PM +0100, Mark Wielaard wrote:
[...]
> > > Don't we need both versioned and versionless names (at least dwfl tries
> > > the versioned one first, then falls back to the unversioned one).
> > 
> > I don't think the versioned name should be exported because it changes
> > in every version while clients don't have to be rebuilt that often.
> 
> I am slightly confused now what we call the versioned name. I assumed
> that was the SONAME aka libdebuginfod.so.1. In theory we never change
> the version, because we use symbol versioning. But yes, we only need to
> export one for dlopen purposes.

I meant the fully versioned name which is
libdebuginfod-$(PACKAGE_VERSION).so - nothing outside the elfutils project
itself should use it.


-- 
ldv

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

* Re: [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-08 12:02     ` [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h Mark Wielaard
  2020-12-08 13:30       ` Dmitry V. Levin
@ 2020-12-08 15:15       ` Dmitry V. Levin
  2020-12-08 23:07         ` Mark Wielaard
  1 sibling, 1 reply; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-08 15:15 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Tue, Dec 08, 2020 at 01:02:41PM +0100, Mark Wielaard wrote:
> On Sun, 2020-12-06 at 15:28 +0300, Dmitry V. Levin wrote:
> > On Sun, Dec 06, 2020 at 01:06:42PM +0100, Mark Wielaard wrote:
[...]
> > > Finally, I am actually using the Makefile VERSION variable in a
> > > downstream (DTS) to make sure the so name of all libraries is different
> > > from the system one. This is just a minor issue though, and I should
> > > probably upstream a tweak to do this upstream so others can also more
> > > easily use this.
> > 
> > Do you suggest to keep the Makefile VERSION variable?
> > It would become an unused variable with the remaining part of the patch
> > applied unless you upstream the tweak you are talking about.
> 
> Lets just remove it for now. I'll figure something out for my special
> case.

Mark, would you like a re-spin of the patchset containing the VERSION variable
removal, or would you prefer an additional patch removing this variable?


-- 
ldv

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

* Re: [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-08 15:15       ` Dmitry V. Levin
@ 2020-12-08 23:07         ` Mark Wielaard
  2020-12-08 23:20           ` Dmitry V. Levin
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Wielaard @ 2020-12-08 23:07 UTC (permalink / raw)
  To: Dmitry V. Levin; +Cc: elfutils-devel

Hi Dmitry,

On Tue, Dec 08, 2020 at 06:15:40PM +0300, Dmitry V. Levin wrote:
> On Tue, Dec 08, 2020 at 01:02:41PM +0100, Mark Wielaard wrote:
> > On Sun, 2020-12-06 at 15:28 +0300, Dmitry V. Levin wrote:
> > > On Sun, Dec 06, 2020 at 01:06:42PM +0100, Mark Wielaard wrote:
> [...]
> > > > Finally, I am actually using the Makefile VERSION variable in a
> > > > downstream (DTS) to make sure the so name of all libraries is different
> > > > from the system one. This is just a minor issue though, and I should
> > > > probably upstream a tweak to do this upstream so others can also more
> > > > easily use this.
> > > 
> > > Do you suggest to keep the Makefile VERSION variable?
> > > It would become an unused variable with the remaining part of the patch
> > > applied unless you upstream the tweak you are talking about.
> > 
> > Lets just remove it for now. I'll figure something out for my special
> > case.
> 
> Mark, would you like a re-spin of the patchset containing the VERSION variable
> removal, or would you prefer an additional patch removing this variable?

I am not very worried what happens to VERSION in the Makefile.am
file. I think it gets unused in your final patch, so just remove it in
the patch that makes it unused.

I did look at the patchset and do have some comments. Patch 1/3 looks
fine. If you could merge 2/3 and 4/3 that would be nice. I think that
makes things more clear what is going on. In Patch 3/3 I think we can
now use DEBUGINFOD_SONAME in the dlopen call. The code does sanity
checks to make sure all needed symbols are there, so it doesn't
necessarily need the precise VERSION. And that way the code does look
the same as other code that would actually want to dlopen
debuginfod.so.1. Or is there a reason to prefer the full name?

Thanks,

Mark

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

* Re: [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-08 23:07         ` Mark Wielaard
@ 2020-12-08 23:20           ` Dmitry V. Levin
  2020-12-09  0:12             ` [PATCH v3 1/3] " Dmitry V. Levin
                               ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-08 23:20 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

Hi Mark,

On Wed, Dec 09, 2020 at 12:07:04AM +0100, Mark Wielaard wrote:
> Hi Dmitry,
> 
> On Tue, Dec 08, 2020 at 06:15:40PM +0300, Dmitry V. Levin wrote:
> > On Tue, Dec 08, 2020 at 01:02:41PM +0100, Mark Wielaard wrote:
> > > On Sun, 2020-12-06 at 15:28 +0300, Dmitry V. Levin wrote:
> > > > On Sun, Dec 06, 2020 at 01:06:42PM +0100, Mark Wielaard wrote:
> > [...]
> > > > > Finally, I am actually using the Makefile VERSION variable in a
> > > > > downstream (DTS) to make sure the so name of all libraries is different
> > > > > from the system one. This is just a minor issue though, and I should
> > > > > probably upstream a tweak to do this upstream so others can also more
> > > > > easily use this.
> > > > 
> > > > Do you suggest to keep the Makefile VERSION variable?
> > > > It would become an unused variable with the remaining part of the patch
> > > > applied unless you upstream the tweak you are talking about.
> > > 
> > > Lets just remove it for now. I'll figure something out for my special
> > > case.
> > 
> > Mark, would you like a re-spin of the patchset containing the VERSION variable
> > removal, or would you prefer an additional patch removing this variable?
> 
> I am not very worried what happens to VERSION in the Makefile.am
> file. I think it gets unused in your final patch, so just remove it in
> the patch that makes it unused.

OK

> I did look at the patchset and do have some comments. Patch 1/3 looks
> fine. If you could merge 2/3 and 4/3 that would be nice. I think that
> makes things more clear what is going on.

OK

> In Patch 3/3 I think we can
> now use DEBUGINFOD_SONAME in the dlopen call. The code does sanity
> checks to make sure all needed symbols are there, so it doesn't
> necessarily need the precise VERSION. And that way the code does look
> the same as other code that would actually want to dlopen
> debuginfod.so.1. Or is there a reason to prefer the full name?

Either way should work fine for __libdwfl_debuginfod_init,
I'll change it to use DEBUGINFOD_SONAME then.


-- 
ldv

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

* [PATCH v3 1/3] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-08 23:20           ` Dmitry V. Levin
@ 2020-12-09  0:12             ` Dmitry V. Levin
  2020-12-09 22:06               ` Mark Wielaard
  2020-12-09  0:13             ` [PATCH v3 2/3] debuginfod: create libdebuginfod.so.1 before libdebuginfod.so Dmitry V. Levin
  2020-12-09  0:13             ` [PATCH v3 3/3] libdwfl: switch to DEBUGINFOD_SONAME, remove libdebuginfod.so fallback Dmitry V. Levin
  2 siblings, 1 reply; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-09  0:12 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

Add DEBUGINFOD_SONAME macro to API for use by those of libdebuginfod
clients that would like to dlopen the library in the same way as
__libdwfl_debuginfod_init does.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 ChangeLog                                    |  5 +++++
 configure.ac                                 |  5 ++++-
 debuginfod/ChangeLog                         | 11 +++++++++++
 debuginfod/Makefile.am                       | 13 ++++++-------
 debuginfod/{debuginfod.h => debuginfod.h.in} |  3 +++
 doc/ChangeLog                                |  4 ++++
 doc/debuginfod_find_debuginfo.3              | 15 +++++++++++++++
 7 files changed, 48 insertions(+), 8 deletions(-)
 rename debuginfod/{debuginfod.h => debuginfod.h.in} (97%)

diff --git a/ChangeLog b/ChangeLog
index 128da6c6..dcfc1cde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-30  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* configure.ac (LIBDEBUGINFOD_SONAME): New AC_SUBST variable.
+	(AC_CONFIG_FILES): Add debuginfod/debuginfod.h.
+
 2020-10-28  Mark Wielaard  <mark@klomp.org>
 
 	* configure.ac: Set version to 0.182.
diff --git a/configure.ac b/configure.ac
index 515ac704..2270509f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,9 @@ m4_ifndef([AC_PACKAGE_URL],
                     [Define to home page for this package])
           AC_SUBST([PACKAGE_URL], ["http://elfutils.org/"])])
 
+LIBDEBUGINFOD_SONAME=libdebuginfod.so.1
+AC_SUBST([LIBDEBUGINFOD_SONAME])
+
 # We want eu- as default program prefix if none was given by the user.
 # But if the user explicitly provided --program-prefix="" then pretend
 # it wasn't set at all (NONE). We want to test this really early before
@@ -61,7 +64,7 @@ dnl The RPM spec file.  We substitute a few values in the file.
 AC_CONFIG_FILES([elfutils.spec:config/elfutils.spec.in])
 
 dnl debuginfo-server client & server parts.
-AC_CONFIG_FILES([debuginfod/Makefile])
+AC_CONFIG_FILES([debuginfod/Makefile debuginfod/debuginfod.h])
 
 AC_CANONICAL_HOST
 
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 244bcda3..6eff25cc 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,3 +1,14 @@
+2020-11-30  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* Makefile.am (libdebuginfod.so): Replace $@.$(VERSION) with
+	$(LIBDEBUGINFOD_SONAME).
+	(install, uninstall, MOSTLYCLEANFILES): Replace
+	libdebuginfod.so.$(VERSION) with $(LIBDEBUGINFOD_SONAME).
+	(VERSION): Remove.
+	* debuginfod.h: Rename to ...
+	* debuginfod.h.in ... this.
+	(DEBUGINFOD_SONAME): New macro.
+
 2020-11-30  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* Makefile.am (libdebuginfod.so$(EXEEXT)): Drop $(EXEEXT) suffix.
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 9e7dcd54..931a0eb9 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -34,7 +34,6 @@ AM_CPPFLAGS += -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
 	   -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
 	   $(libmicrohttpd_CFLAGS) $(libcurl_CFLAGS) $(sqlite3_CFLAGS) \
 	   $(libarchive_CFLAGS)
-VERSION = 1
 
 # Disable eu- prefixing for artifacts (binaries & man pages) in this
 # directory, since they do not conflict with binutils tools.
@@ -102,30 +101,30 @@ libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
 endif
 libdebuginfod.so: $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
-		-Wl,--soname,$@.$(VERSION) \
+		-Wl,--soname,$(LIBDEBUGINFOD_SONAME) \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(libdebuginfod_so_LIBS) -Wl,--no-whole-archive \
 		$(libdebuginfod_so_LDLIBS)
 	@$(textrel_check)
-	$(AM_V_at)ln -fs $@ $@.$(VERSION)
+	$(AM_V_at)ln -fs $@ $(LIBDEBUGINFOD_SONAME)
 endif
 
 if LIBDEBUGINFOD
 install: install-am libdebuginfod.so
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
 	$(INSTALL_PROGRAM) libdebuginfod.so $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
-	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so.$(VERSION)
-	ln -fs libdebuginfod.so.$(VERSION) $(DESTDIR)$(libdir)/libdebuginfod.so
+	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
+	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so
 
 uninstall: uninstall-am
 	rm -f $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
-	rm -f $(DESTDIR)$(libdir)/libdebuginfod.so.$(VERSION)
+	rm -f $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
 	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)
+MOSTLYCLEANFILES = $(am_libdebuginfod_pic_a_OBJECTS) $(LIBDEBUGINFOD_SONAME)
 CLEANFILES += $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so
 
 # automake std-options override: arrange to pass LD_LIBRARY_PATH
diff --git a/debuginfod/debuginfod.h b/debuginfod/debuginfod.h.in
similarity index 97%
rename from debuginfod/debuginfod.h
rename to debuginfod/debuginfod.h.in
index 8d90838b..e919b6e3 100644
--- a/debuginfod/debuginfod.h
+++ b/debuginfod/debuginfod.h.in
@@ -35,6 +35,9 @@
 #define DEBUGINFOD_TIMEOUT_ENV_VAR "DEBUGINFOD_TIMEOUT"
 #define DEBUGINFOD_PROGRESS_ENV_VAR "DEBUGINFOD_PROGRESS"
 
+/* The libdebuginfod soname.  */
+#define DEBUGINFOD_SONAME "@LIBDEBUGINFOD_SONAME@"
+
 /* Handle for debuginfod-client connection.  */
 typedef struct debuginfod_client debuginfod_client;
 
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 8c33f174..8c524fd9 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-06  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* debuginfod_find_debuginfo.3: Document DEBUGINFOD_SONAME macro.
+
 2020-10-29  Frank Ch. Eigler  <fche@redhat.com>
 
 	PR26775
diff --git a/doc/debuginfod_find_debuginfo.3 b/doc/debuginfod_find_debuginfo.3
index eec04e5e..ee5e9b27 100644
--- a/doc/debuginfod_find_debuginfo.3
+++ b/doc/debuginfod_find_debuginfo.3
@@ -198,6 +198,21 @@ removed from the cache during cleaning. These files should contain only an
 ASCII decimal integer representing the interval or max unused age in seconds.
 The default is one day and one week, respectively.  Values of zero mean "immediately".
 
+.SH "MACROS"
+
+.SS "DEBUGINFOD_SONAME"
+
+Defined to the string that could be passed to
+.BR dlopen (3)
+if the library is loaded at runtime, for example
+
+.PP
+.in +4n
+.EX
+void *debuginfod_so = dlopen(DEBUGINFOD_SONAME, RTLD_LAZY);
+.EE
+.in
+
 .SH "SECURITY"
 .BR debuginfod_find_debuginfo (),
 .BR debuginfod_find_executable (),
-- 
ldv

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

* [PATCH v3 2/3] debuginfod: create libdebuginfod.so.1 before libdebuginfod.so
  2020-12-08 23:20           ` Dmitry V. Levin
  2020-12-09  0:12             ` [PATCH v3 1/3] " Dmitry V. Levin
@ 2020-12-09  0:13             ` Dmitry V. Levin
  2020-12-09  0:30               ` Dmitry V. Levin
  2020-12-09  0:13             ` [PATCH v3 3/3] libdwfl: switch to DEBUGINFOD_SONAME, remove libdebuginfod.so fallback Dmitry V. Levin
  2 siblings, 1 reply; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-09  0:13 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

This would allow to switch from "libdebuginfod-" VERSION ".so"
to DEBUGINFOD_SONAME in __libdwfl_debuginfod_init, and to remove the
fall back to dlopen of "libdebuginfod.so" which is no longer needed.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 debuginfod/ChangeLog   |  5 +++++
 debuginfod/Makefile.am | 11 ++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 6eff25cc..3db34b4a 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-08  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* Makefile.am [LIBDEBUGINFOD]: Create libdebuginfod.so.1 first, turn
+	libdebuginfod.so into symlink.
+
 2020-11-30  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* Makefile.am (libdebuginfod.so): Replace $@.$(VERSION) with
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 931a0eb9..13afcd2a 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -99,20 +99,21 @@ libdebuginfod_so_LDLIBS =
 else
 libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
 endif
-libdebuginfod.so: $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+$(LIBDEBUGINFOD_SONAME): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
 		-Wl,--soname,$(LIBDEBUGINFOD_SONAME) \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(libdebuginfod_so_LIBS) -Wl,--no-whole-archive \
 		$(libdebuginfod_so_LDLIBS)
 	@$(textrel_check)
-	$(AM_V_at)ln -fs $@ $(LIBDEBUGINFOD_SONAME)
-endif
 
-if LIBDEBUGINFOD
+libdebuginfod.so: $(LIBDEBUGINFOD_SONAME)
+	ln -fs $< $@
+
 install: install-am libdebuginfod.so
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
-	$(INSTALL_PROGRAM) libdebuginfod.so $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
+	$(INSTALL_PROGRAM) $(LIBDEBUGINFOD_SONAME) \
+		$(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
 	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
 	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so
 
-- 
ldv

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

* [PATCH v3 3/3] libdwfl: switch to DEBUGINFOD_SONAME, remove libdebuginfod.so fallback
  2020-12-08 23:20           ` Dmitry V. Levin
  2020-12-09  0:12             ` [PATCH v3 1/3] " Dmitry V. Levin
  2020-12-09  0:13             ` [PATCH v3 2/3] debuginfod: create libdebuginfod.so.1 before libdebuginfod.so Dmitry V. Levin
@ 2020-12-09  0:13             ` Dmitry V. Levin
  2020-12-09 22:43               ` Mark Wielaard
  2 siblings, 1 reply; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-09  0:13 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

Since DEBUGINFOD_SONAME is as good as ("libdebuginfod-" VERSION ".so")
for dlopen, switch to use the name which is a part of the API.

Given that DEBUGINFOD_SONAME is always available now, remove the no longer
needed fall back to dlopen of "libdebuginfod.so".

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 libdwfl/ChangeLog           | 6 ++++++
 libdwfl/debuginfod-client.c | 5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 344db7c1..d0edc1a1 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-08  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* debuginfod-client.c (__libdwfl_debuginfod_init): Replace
+	"libdebuginfod-" VERSION ".so" with DEBUGINFOD_SONAME in dlopen call.
+	Do not fall back to dlopen of "libdebuginfod.so".
+
 2020-09-18  Mark Wielaard  <mark@klomp.org>
 
 	* zstd.c: New file.
diff --git a/libdwfl/debuginfod-client.c b/libdwfl/debuginfod-client.c
index 6fd83900..61d52db2 100644
--- a/libdwfl/debuginfod-client.c
+++ b/libdwfl/debuginfod-client.c
@@ -109,10 +109,7 @@ __libdwfl_debuginfod_init (void)
   if (urls_envvar == NULL || urls_envvar[0] == '\0')
     return;
 
-  void *debuginfod_so = dlopen("libdebuginfod-" VERSION ".so", RTLD_LAZY);
-
-  if (debuginfod_so == NULL)
-    debuginfod_so = dlopen("libdebuginfod.so", RTLD_LAZY);
+  void *debuginfod_so = dlopen(DEBUGINFOD_SONAME, RTLD_LAZY);
 
   if (debuginfod_so != NULL)
     {
-- 
ldv

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

* Re: [PATCH v3 2/3] debuginfod: create libdebuginfod.so.1 before libdebuginfod.so
  2020-12-09  0:13             ` [PATCH v3 2/3] debuginfod: create libdebuginfod.so.1 before libdebuginfod.so Dmitry V. Levin
@ 2020-12-09  0:30               ` Dmitry V. Levin
  2020-12-09 22:12                 ` Mark Wielaard
  0 siblings, 1 reply; 21+ messages in thread
From: Dmitry V. Levin @ 2020-12-09  0:30 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Wed, Dec 09, 2020 at 03:13:12AM +0300, Dmitry V. Levin wrote:
> This would allow to switch from "libdebuginfod-" VERSION ".so"
> to DEBUGINFOD_SONAME in __libdwfl_debuginfod_init, and to remove the
> fall back to dlopen of "libdebuginfod.so" which is no longer needed.

Correction:
s/which is no longer needed/which would no longer be needed/


-- 
ldv

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

* Re: [PATCH v3 1/3] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
  2020-12-09  0:12             ` [PATCH v3 1/3] " Dmitry V. Levin
@ 2020-12-09 22:06               ` Mark Wielaard
  0 siblings, 0 replies; 21+ messages in thread
From: Mark Wielaard @ 2020-12-09 22:06 UTC (permalink / raw)
  To: Dmitry V. Levin; +Cc: elfutils-devel

On Wed, 2020-12-09 at 03:12 +0300, Dmitry V. Levin wrote:
> Add DEBUGINFOD_SONAME macro to API for use by those of libdebuginfod
> clients that would like to dlopen the library in the same way as
> __libdwfl_debuginfod_init does.

Pushed.

Thanks,

Mark

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

* Re: [PATCH v3 2/3] debuginfod: create libdebuginfod.so.1 before libdebuginfod.so
  2020-12-09  0:30               ` Dmitry V. Levin
@ 2020-12-09 22:12                 ` Mark Wielaard
  0 siblings, 0 replies; 21+ messages in thread
From: Mark Wielaard @ 2020-12-09 22:12 UTC (permalink / raw)
  To: Dmitry V. Levin; +Cc: elfutils-devel

On Wed, 2020-12-09 at 03:30 +0300, Dmitry V. Levin wrote:
> On Wed, Dec 09, 2020 at 03:13:12AM +0300, Dmitry V. Levin wrote:
> > This would allow to switch from "libdebuginfod-" VERSION ".so"
> > to DEBUGINFOD_SONAME in __libdwfl_debuginfod_init, and to remove
> > the
> > fall back to dlopen of "libdebuginfod.so" which is no longer
> > needed.
> 
> Correction:
> s/which is no longer needed/which would no longer be needed/

Pushed with that correction.

Thanks,

Mark

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

* Re: [PATCH v3 3/3] libdwfl: switch to DEBUGINFOD_SONAME, remove libdebuginfod.so fallback
  2020-12-09  0:13             ` [PATCH v3 3/3] libdwfl: switch to DEBUGINFOD_SONAME, remove libdebuginfod.so fallback Dmitry V. Levin
@ 2020-12-09 22:43               ` Mark Wielaard
  0 siblings, 0 replies; 21+ messages in thread
From: Mark Wielaard @ 2020-12-09 22:43 UTC (permalink / raw)
  To: Dmitry V. Levin; +Cc: elfutils-devel

On Wed, 2020-12-09 at 03:13 +0300, Dmitry V. Levin wrote:
> Since DEBUGINFOD_SONAME is as good as ("libdebuginfod-" VERSION ".so")
> for dlopen, switch to use the name which is a part of the API.
> 
> Given that DEBUGINFOD_SONAME is always available now, remove the no longer
> needed fall back to dlopen of "libdebuginfod.so".

Pushed.

Thanks,

Mark

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

end of thread, other threads:[~2020-12-09 22:43 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-30  9:00 [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h Dmitry V. Levin
2020-12-06 12:06 ` Mark Wielaard
2020-12-06 12:28   ` Dmitry V. Levin
2020-12-06 13:32     ` Frank Ch. Eigler
2020-12-06 13:34       ` Dmitry V. Levin
2020-12-06 13:54         ` [PATCH v2 1/3] " Dmitry V. Levin
2020-12-06 13:54         ` [PATCH v2 2/3] debuginfod: create the fully versioned libdebuginfod file name during build Dmitry V. Levin
2020-12-06 14:44           ` [PATCH v2 4/3] debuginfod: create libdebuginfod files using a race-free method Dmitry V. Levin
2020-12-06 13:54         ` [PATCH v2 3/3] libdwfl: do not fall back to dlopen of libdebuginfod.so Dmitry V. Levin
2020-12-08 12:02     ` [PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h Mark Wielaard
2020-12-08 13:30       ` Dmitry V. Levin
2020-12-08 15:15       ` Dmitry V. Levin
2020-12-08 23:07         ` Mark Wielaard
2020-12-08 23:20           ` Dmitry V. Levin
2020-12-09  0:12             ` [PATCH v3 1/3] " Dmitry V. Levin
2020-12-09 22:06               ` Mark Wielaard
2020-12-09  0:13             ` [PATCH v3 2/3] debuginfod: create libdebuginfod.so.1 before libdebuginfod.so Dmitry V. Levin
2020-12-09  0:30               ` Dmitry V. Levin
2020-12-09 22:12                 ` Mark Wielaard
2020-12-09  0:13             ` [PATCH v3 3/3] libdwfl: switch to DEBUGINFOD_SONAME, remove libdebuginfod.so fallback Dmitry V. Levin
2020-12-09 22:43               ` Mark Wielaard

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).