public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3] Check if rpath is supported and throw an error if not
@ 2017-08-18 14:04 Ulf Hermann
  2017-08-19  8:11 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Ulf Hermann @ 2017-08-18 14:04 UTC (permalink / raw)
  To: elfutils-devel

Some systems don't have rpath. In that case the backends need to be
made available by some external mechanism. Provide a configure switch
to explicitly turn off the setting of rpaths. Throw an error if that is
not set and rpath is not supported.

(Reposting rebased patch, as v2 was never reviewed.)

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 ChangeLog         |  5 +++++
 configure.ac      | 22 ++++++++++++++++++++++
 libdw/ChangeLog   |  4 ++++
 libdw/Makefile.am |  8 +++++++-
 4 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index b720f2cd..47b37565 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2017-05-03  Ulf Hermann  <ulf.hermann@qt.io>
 
+	* configure.ac: Check if the linker supports -rpath and add a switch
+	to disable setting of rpath.
+
+2017-05-03  Ulf Hermann  <ulf.hermann@qt.io>
+
 	* configure.ac: Test if symbol versioning is supported.
 
 2017-08-18  Ulf Hermann  <ulf.hermann@qt.io>
diff --git a/configure.ac b/configure.ac
index 4ab8816a..6856ff7e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -208,6 +208,28 @@ fi
 
 AC_SUBST([dso_LDFLAGS])
 
+AC_ARG_ENABLE([rpath],
+AS_HELP_STRING([--disable-rpath], [Disable setting of rpath]))
+
+AC_CACHE_CHECK([for rpath support], ac_cv_rpath, [dnl
+save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$save_LDFLAGS -Wl,--enable-new-dtags,-rpath,/foo/bar"
+AC_LINK_IFELSE([AC_LANG_PROGRAM()], ac_cv_rpath=yes, ac_cv_rpath=no)
+LDFLAGS="$save_LDFLAGS"
+])
+if test "$ac_cv_rpath" = "no"; then
+    if test "x$enable_rpath" != "xno"; then
+        AC_MSG_ERROR([rpath is not supported.
+                      Use --disable-rpath to build without.])
+    fi
+fi
+
+AM_CONDITIONAL(RPATH, [test "x$enable_rpath" != "xno"])
+AS_IF([test "x$enable_rpath" = "xno"],
+      [AC_MSG_WARN([Disabling rpath prevents libdw from automatically
+                    finding the ebl backends.])
+       enable_rpath=no],[enable_rpath=yes])
+
 AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
 # Use the same flags that we use for our DSOs, so the test is representative.
 # Some old compiler/linker/libc combinations fail some ways and not others.
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 79cce5ce..8020c569 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-28  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Don't set rpath if it's disabled.
+
 2017-08-18  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Drop libdw_so_SOURCES.
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index af7d7793..3257c014 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -99,6 +99,12 @@ $(srcdir)/known-dwarf.h: $(top_srcdir)/config/known-dwarf.awk $(srcdir)/dwarf.h
 	mv -f $@.new $@
 endif
 
+if RPATH
+PKG_RPATH = -Wl,--enable-new-dtags,-rpath,$(pkglibdir)
+else
+PKG_RPATH =
+endif
+
 libdw_pic_a_SOURCES =
 am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
 
@@ -111,7 +117,7 @@ libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
 # not fly in a setuid executable that links in libdw.
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
 		-Wl,--soname,$@.$(VERSION) \
-		-Wl,--enable-new-dtags,-rpath,$(pkglibdir) \
+		$(PKG_RPATH) \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(libdw_so_LIBS) -Wl,--no-whole-archive \
 		$(libdw_so_LDLIBS)
-- 
2.11.0

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

* Re: [PATCH v3] Check if rpath is supported and throw an error if not
  2017-08-18 14:04 [PATCH v3] Check if rpath is supported and throw an error if not Ulf Hermann
@ 2017-08-19  8:11 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2017-08-19  8:11 UTC (permalink / raw)
  To: Ulf Hermann; +Cc: elfutils-devel

On Fri, Aug 18, 2017 at 04:04:28PM +0200, Ulf Hermann wrote:
> Some systems don't have rpath. In that case the backends need to be
> made available by some external mechanism. Provide a configure switch
> to explicitly turn off the setting of rpaths. Throw an error if that is
> not set and rpath is not supported.

I think this is not great. This basically just breaks things.
If done we should provide such an "external mechanism".

For DTS I just compile in the supported backends staticly. See the
code on the mjw/RH-DTS branch. That is also not great since it just
hard codes the supported backends (and then just throws away various
tests that are broken in that setup). Which is why that code isn't
on the master branch.

But if we can come up with something like that (but a little bit more
flexible) as alternative for not having/using rpath/ldopen, that would
be good.

What "external mechanism" are you using?

Cheers,

Mark

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

end of thread, other threads:[~2017-08-19  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-18 14:04 [PATCH v3] Check if rpath is supported and throw an error if not Ulf Hermann
2017-08-19  8:11 ` 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).