This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH v2] Check if rpath is supported before setting it
- From: Ulf Hermann <ulf dot hermann at qt dot io>
- To: <elfutils-devel at sourceware dot org>
- Date: Wed, 3 May 2017 17:47:03 +0200
- Subject: [PATCH v2] Check if rpath is supported before setting it
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=qt.io;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ucanEQp+y9/tIn32Fn5RMnHhsTPI042u10ljtvGhyXk=; b=Ol3b1FnLZ/aTee2P9uMJM6W4J5+7N6BciQJuT0jio+RELRR8Vw+uyl3dc6k75KsDIHV7oAMVL8RG8kbjPtTGqzQYlPOKl7IvCYFDEw9o9UJHlUiRzelhsjeAllCAOXZ06nSAROFsGBSwvF+0lP80FGrjp2w8k/eSA2qlyfPUMdM=
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
ChangeLog | 5 +++++
configure.ac | 22 ++++++++++++++++++++++
libdw/ChangeLog | 4 ++++
libdw/Makefile.am | 9 +++++++--
4 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 22c46c6..344ae0b 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-04-27 Ulf Hermann <ulf.hermann@qt.io>
diff --git a/configure.ac b/configure.ac
index 48b06de..598b372 100644
--- a/configure.ac
+++ b/configure.ac
@@ -204,6 +204,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 af4aa40..d33ffe3 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-02-27 Ulf Hermann <ulf.hermann@qt.io>
* libdwP.h: Use attribute_hidden.
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 31f7012..055e3f1 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)
@@ -115,8 +121,7 @@ libdw.so$(EXEEXT): $(srcdir)/libdw.map libdw_pic.a ../libdwelf/libdwelf_pic.a \
# The rpath is necessary for libebl because its $ORIGIN use will
# 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) \
- -Wl,--version-script,$<,--no-undefined \
+ -Wl,--version-script,$<,--no-undefined $(PKG_RPATH) \
-Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\
-ldl -lz $(intl_LDADD) $(zip_LIBS) $(libgnu)
@$(textrel_check)
--
2.1.4