[Bug debuginfod/26125] during debuginfod cache cleanup, try harder to rmdir empty dirs

2020-11-30 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=26125

--- Comment #6 from Mark Wielaard  ---
(In reply to Frank Ch. Eigler from comment #5)
> Yeah, I suppose there is that race possibility.
> 
> One way to fix it is to use something like file locks, such as a flock(2) on
> a designated file such as $CACHE/cache_clean_interval_s.  During
> aging/cleanup, hold a LOCK_EX.  During normal operation (creation of
> build-id subdirectories & files), hold a LOCK_SH to permit multiple clients
> to work independently of one another.

That is somewhat unfortunate given that the current scheme is lock-free. I
wonder if there is some way around it using temp names for the directories,
like we do for the actual file names, so that we can atomically rename them
in-place.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug debuginfod/26125] during debuginfod cache cleanup, try harder to rmdir empty dirs

2020-11-30 Thread fche at redhat dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=26125

--- Comment #7 from Frank Ch. Eigler  ---
> I wonder if there is some way around it using temp names for the directories,
> like we do for the actual file names, so that we can atomically rename them
> in-place.

I couldn't think of one without other drawbacks.  There can be races between
two clients downloading info for the same buildid, thus creating two temp dirs.
 One of them would not be able to rename to the final name.

Another simplish approach would be to check the directory mtime before rmdir,
to ensure it's old, plus adding a retry loop at cache-insertion, in case a
client loses the maxage_s race with a cleanup.  But it would only lose it
once (due to the mtime check).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[PATCH] Drop $(EXEEXT) suffix from shared libraries

2020-11-30 Thread Dmitry V. Levin
According to GNU Automake documentation [1], $(EXEEXT) is the suffix
that should be used for executables, it is not applicable for shared libraries.

[1] https://www.gnu.org/software/automake/manual/html_node/EXEEXT.html

Signed-off-by: Dmitry V. Levin 
---
 debuginfod/ChangeLog   | 4 
 debuginfod/Makefile.am | 2 +-
 libasm/ChangeLog   | 4 
 libasm/Makefile.am | 2 +-
 libdw/ChangeLog| 4 
 libdw/Makefile.am  | 2 +-
 libelf/ChangeLog   | 4 
 libelf/Makefile.am | 2 +-
 8 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index aaffac7c..3039371f 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-30  Dmitry V. Levin  
+
+   * Makefile.am (libdebuginfod.so$(EXEEXT)): Drop $(EXEEXT) suffix.
+
 2020-11-25  Frank Ch. Eigler  
 
* debuginfod.cxx (step_ok_done): Correct typo in prom metric label.
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 0af3b58c..352b4915 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -100,7 +100,7 @@ libdebuginfod_so_LDLIBS =
 else
 libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
 endif
-libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
+libdebuginfod.so: $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
-Wl,--soname,$@.$(VERSION) \
-Wl,--version-script,$<,--no-undefined \
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index d7ab8c42..29c23bad 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-30  Dmitry V. Levin  
+
+   * Makefile.am (libasm.so$(EXEEXT)): Drop $(EXEEXT) suffix.
+
 2020-10-29  Mark Wielaard  
 
* asm_align.c (__libasm_ensure_section_space): Use calloc, not
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index b2bff929..4b55d530 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -63,7 +63,7 @@ endif
 
 libasm_so_LIBS = libasm_pic.a
 libasm_so_SOURCES =
-libasm.so$(EXEEXT): $(srcdir)/libasm.map $(libasm_so_LIBS) $(libasm_so_DEPS)
+libasm.so: $(srcdir)/libasm.map $(libasm_so_LIBS) $(libasm_so_DEPS)
$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
-Wl,--soname,$@.$(VERSION) \
-Wl,--version-script,$<,--no-undefined \
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 6f8ebea6..fbe2abc0 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-30  Dmitry V. Levin  
+
+   * Makefile.am (libdw.so$(EXEEXT)): Drop $(EXEEXT) suffix.
+
 2020-11-01  Érico N. Rolim  
 
* Makefile.am (libdw_so_LDLIBS): Add fts_LIBS.
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 1dbb3d5e..f21ee6ae 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -111,7 +111,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a 
../backends/libebl_backends_pic.a \
 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
 libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LIBS) 
$(obstack_LIBS) $(zip_LIBS) -pthread
 libdw_so_SOURCES =
-libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
+libdw.so: $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
-Wl,--soname,$@.$(VERSION),--enable-new-dtags \
-Wl,--version-script,$<,--no-undefined \
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index d685872d..0a9e36a2 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-30  Dmitry V. Levin  
+
+   * Makefile.am (libelf.so$(EXEEXT)): Drop $(EXEEXT) suffix.
+
 2020-11-06  Mark Wielaard  
 
* elf-knowledge.h (SH_ENTSIZE_HASH): Update comment.
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index d5d63f73..f8f2afeb 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -113,7 +113,7 @@ endif
 
 libelf_so_LIBS = libelf_pic.a
 libelf_so_SOURCES =
-libelf.so$(EXEEXT): $(srcdir)/libelf.map $(libelf_so_LIBS) $(libelf_so_DEPS)
+libelf.so: $(srcdir)/libelf.map $(libelf_so_LIBS) $(libelf_so_DEPS)
$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
-Wl,--soname,$@.$(VERSION) \
-Wl,--version-script,$<,--no-undefined \
-- 
ldv


Re: [PATCH] Drop $(EXEEXT) suffix from shared libraries

2020-11-30 Thread Mark Wielaard
On Mon, Nov 30, 2020 at 08:00:00AM +, Dmitry V. Levin wrote:
> According to GNU Automake documentation [1], $(EXEEXT) is the suffix
> that should be used for executables, it is not applicable for shared 
> libraries.
> 
> [1] https://www.gnu.org/software/automake/manual/html_node/EXEEXT.html

I think you are right and this patch is correct.  This probably only
affects non-posix or windows setups.  Ulf (on CC now) was working on
building on windows (although I think we never integrated all the
patches for that). Maybe he has an opinion on this patch?

Thanks,

Mark

> Signed-off-by: Dmitry V. Levin 
> ---
>  debuginfod/ChangeLog   | 4 
>  debuginfod/Makefile.am | 2 +-
>  libasm/ChangeLog   | 4 
>  libasm/Makefile.am | 2 +-
>  libdw/ChangeLog| 4 
>  libdw/Makefile.am  | 2 +-
>  libelf/ChangeLog   | 4 
>  libelf/Makefile.am | 2 +-
>  8 files changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
> index aaffac7c..3039371f 100644
> --- a/debuginfod/ChangeLog
> +++ b/debuginfod/ChangeLog
> @@ -1,3 +1,7 @@
> +2020-11-30  Dmitry V. Levin  
> +
> + * Makefile.am (libdebuginfod.so$(EXEEXT)): Drop $(EXEEXT) suffix.
> +
>  2020-11-25  Frank Ch. Eigler  
>  
>   * debuginfod.cxx (step_ok_done): Correct typo in prom metric label.
> diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
> index 0af3b58c..352b4915 100644
> --- a/debuginfod/Makefile.am
> +++ b/debuginfod/Makefile.am
> @@ -100,7 +100,7 @@ libdebuginfod_so_LDLIBS =
>  else
>  libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
>  endif
> -libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map 
> $(libdebuginfod_so_LIBS)
> +libdebuginfod.so: $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
>   $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
>   -Wl,--soname,$@.$(VERSION) \
>   -Wl,--version-script,$<,--no-undefined \
> diff --git a/libasm/ChangeLog b/libasm/ChangeLog
> index d7ab8c42..29c23bad 100644
> --- a/libasm/ChangeLog
> +++ b/libasm/ChangeLog
> @@ -1,3 +1,7 @@
> +2020-11-30  Dmitry V. Levin  
> +
> + * Makefile.am (libasm.so$(EXEEXT)): Drop $(EXEEXT) suffix.
> +
>  2020-10-29  Mark Wielaard  
>  
>   * asm_align.c (__libasm_ensure_section_space): Use calloc, not
> diff --git a/libasm/Makefile.am b/libasm/Makefile.am
> index b2bff929..4b55d530 100644
> --- a/libasm/Makefile.am
> +++ b/libasm/Makefile.am
> @@ -63,7 +63,7 @@ endif
>  
>  libasm_so_LIBS = libasm_pic.a
>  libasm_so_SOURCES =
> -libasm.so$(EXEEXT): $(srcdir)/libasm.map $(libasm_so_LIBS) $(libasm_so_DEPS)
> +libasm.so: $(srcdir)/libasm.map $(libasm_so_LIBS) $(libasm_so_DEPS)
>   $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
>   -Wl,--soname,$@.$(VERSION) \
>   -Wl,--version-script,$<,--no-undefined \
> diff --git a/libdw/ChangeLog b/libdw/ChangeLog
> index 6f8ebea6..fbe2abc0 100644
> --- a/libdw/ChangeLog
> +++ b/libdw/ChangeLog
> @@ -1,3 +1,7 @@
> +2020-11-30  Dmitry V. Levin  
> +
> + * Makefile.am (libdw.so$(EXEEXT)): Drop $(EXEEXT) suffix.
> +
>  2020-11-01  Érico N. Rolim  
>  
>   * Makefile.am (libdw_so_LDLIBS): Add fts_LIBS.
> diff --git a/libdw/Makefile.am b/libdw/Makefile.am
> index 1dbb3d5e..f21ee6ae 100644
> --- a/libdw/Makefile.am
> +++ b/libdw/Makefile.am
> @@ -111,7 +111,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a 
> ../backends/libebl_backends_pic.a \
>  libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
>  libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LIBS) 
> $(obstack_LIBS) $(zip_LIBS) -pthread
>  libdw_so_SOURCES =
> -libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
> +libdw.so: $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
>   $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
>   -Wl,--soname,$@.$(VERSION),--enable-new-dtags \
>   -Wl,--version-script,$<,--no-undefined \
> diff --git a/libelf/ChangeLog b/libelf/ChangeLog
> index d685872d..0a9e36a2 100644
> --- a/libelf/ChangeLog
> +++ b/libelf/ChangeLog
> @@ -1,3 +1,7 @@
> +2020-11-30  Dmitry V. Levin  
> +
> + * Makefile.am (libelf.so$(EXEEXT)): Drop $(EXEEXT) suffix.
> +
>  2020-11-06  Mark Wielaard  
>  
>   * elf-knowledge.h (SH_ENTSIZE_HASH): Update comment.
> diff --git a/libelf/Makefile.am b/libelf/Makefile.am
> index d5d63f73..f8f2afeb 100644
> --- a/libelf/Makefile.am
> +++ b/libelf/Makefile.am
> @@ -113,7 +113,7 @@ endif
>  
>  libelf_so_LIBS = libelf_pic.a
>  libelf_so_SOURCES =
> -libelf.so$(EXEEXT): $(srcdir)/libelf.map $(libelf_so_LIBS) $(libelf_so_DEPS)
> +libelf.so: $(srcdir)/libelf.map $(libelf_so_LIBS) $(libelf_so_DEPS)
>   $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
>   -Wl,--soname,$@.$(VERSION) \
>   -Wl,--version-script,$<,--no-undefined \
> -- 
> ldv


[PATCH] debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h

2020-11-30 Thread Dmitry V. Levin
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 
---
 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  
+
+   * configure.ac (LIBDEBUGINFOD_SONAME): New AC_SUBST variable.
+   (AC_CONFIG_FILES): Add debuginfod/debuginfod.h.
+
 2020-11-01  Érico N. Rolim  
 
* 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  
 
+   * 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  
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/deb