[Bug,libdw/32929] 0.193 regression: dwarf_srclang_check: error while loading shared libraries: libelf.so.1: cannot open shared object file: No such file or directory

Message ID bug-32929-10460-UTXboP6WgO@http.sourceware.org/bugzilla/
State Not applicable
Headers
Series [Bug,libdw/32929] 0.193 regression: dwarf_srclang_check: error while loading shared libraries: libelf.so.1: cannot open shared object file: No such file or directory |

Commit Message

mark at klomp dot org May 2, 2025, 5:17 p.m. UTC
  https://sourceware.org/bugzilla/show_bug.cgi?id=32929

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
That is interesting. The test is linked against the system libelf. But it
really should be linked against the just build libelf. I assume nobody else saw
this because libelf is always installed. But you see this because in your
(NixOS) environment you have a totally clean "buildroot".

I think you are right, for these test binaries we'll need to add an RPATH.
Does the following work for you?

_check,,$$@).o,$(libdw_a_OBJECTS)) $$(subst _check,,$$@).c
  

Patch

diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index f024d6524095..298b0c65b972 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -168,7 +168,8 @@  MAINTAINERCLEANFILES = $(srcdir)/known-dwarf.h
 check_PROGRAMS = dwarf_srclang_check
 TESTS = $(check_PROGRAMS)

-CHECK_DEF_FLAGS = $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-DMAIN_CHECK=1
+CHECK_DEF_FLAGS = $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
+       -Wl,-rpath,../libelf -DMAIN_CHECK=1

 .SECONDEXPANSION:
 dwarf_srclang_check$(EXEEXT): $$(filter-out $$(subst