All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v4 00/11] Make the SDK relocatable
Date: Tue, 27 Jun 2017 12:26:36 +0200	[thread overview]
Message-ID: <1498559207-8050-1-git-send-email-wg@grandegger.com> (raw)

Hello,

this is v4 of my patch series to make the buildroot SDK (HOST_DIR)
relocatable. It sanitizes the RPATH of all ELF files in the "target",
"staging" and "host" tree using "patchelf --make-rpath-relative". I
have started the mainlining process to implement "--make-rpath-relative"
using GitHub pull request [1]... till now, no answer!

Furthermore this patch creates the script "relocate-sdk.sh" in the top
directory of the "host" tree allowing to relocate the SDK after it has
been moved to a new location. It replaces the old path with the new
one in all text files identified by "file --mime-type". The location
is stored in "usr/share/buildroot/sdk-location".

Unfortunately, "qmake" uses hard-coded pathes compiled into the QT5
libraries. To overcome this problem, "qt5pase" now creates "qt.conf".

I also checked if the rpath sanitation could be done per package
after package installation into the host, staging or target tree
using GLOBAL_INSTRUMENTATION_HOOKS, similar to "check-bin-arch"
or "check-host-rpath". Unfortunately, this approach does required
bigger changes to the infrastructure, mainly to maintain a list of
ELF files installed per package into the various trees. This needs
more thought/discussion...

Other Questions:

Things not yet addressed:

- "make toolchain" creates a toolchain tree which still has references
  to the build system (in ELF and text files).

Changes since v3:

- The patchelf patch implementing " --make-rpath-relative" now supports
  the option "--relative-to-file" instructing to use "$ORIGIN" in
  RPATHs. Otherwise an absolute path relative to the root directory will
  be used.
- The staging tree is now sanitized as well using the options
  "--relative-to-file" and "--no-standard-libs".
- For the "target" tree, relative RPATHs do not use "$ORIGIN" any
  longer. An absolute path relative to the root directory is used
  instead.

Changes since v2:

- provide "qt.conf" to make "qmake" relocatable
- sed now uses the separator "\" to substitute the directory path.
  It's one of the few characters not allowed in file names. To
  avoid interpreting it as escape character, the "read -r" is used.
- The paranoia substituion check is done before doing the real
  substituion.

Changes since v1:

- The name SDK has been chosen for the relocatabed "HOST_DIR" (instead
  of toolchanin).
- The patchelf version bump and patching are now done by 2 patches
- No more helper functions are used in the Makefile to call "fix-rpath"
  but added directly.
- The staging tree is not touched any more... until we have a good
  reason to do so. 
- The sanitation is now performed by an optimized "fix-rpath" script.
- The relocate-sdk script is now copied for support/misc to the
  top directory of the host tree.

[1] https://github.com/NixOS/patchelf/pull/118

Samuel Martin (1):
  support/scripts: add fix-rpath script to sanitize the rpath

Wolfgang Grandegger (10):
  package/patchelf: use most recent version as a base for rpath
    sanitation
  package/patchelf: add patch for rpath sanitation under a root
    directory
  core: sanitize RPATH in staging tree at the end of the target
    finalization
  core: sanitize RPATH in target tree at the end of the target
    finalization
  core: sanitize RPATH in host tree at the very end of the build
  support/scripts: add reloacte-sdk.sh script for SDK relocation
  core: install relocation script and location at the end of the build
  external-toolchain: check if a buildroot SDK has already been
    relocated
  support/scripts: check-host-rpath now handles $ORIGIN as well
  package/qt5base: provide "qt.conf" to make "qmake" relocatable

 Makefile                                           |  12 +
 ...to-make-the-rpath-relative-under-a-specif.patch | 326 +++++++++++++++++++++
 package/patchelf/patchelf.hash                     |   2 +-
 package/patchelf/patchelf.mk                       |   8 +-
 package/qt5/qt5base/qt.conf.in                     |   6 +
 package/qt5/qt5base/qt5base.mk                     |   8 +
 support/misc/relocate-sdk.sh                       |  47 +++
 support/scripts/check-host-rpath                   |   2 +-
 support/scripts/fix-rpath                          | 112 +++++++
 toolchain/helpers.mk                               |  15 +
 .../toolchain-external/pkg-toolchain-external.mk   |   1 +
 11 files changed, 533 insertions(+), 6 deletions(-)
 create mode 100644 package/patchelf/0001-Add-option-to-make-the-rpath-relative-under-a-specif.patch
 create mode 100644 package/qt5/qt5base/qt.conf.in
 create mode 100755 support/misc/relocate-sdk.sh
 create mode 100755 support/scripts/fix-rpath

-- 
2.7.4

             reply	other threads:[~2017-06-27 10:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 10:26 Wolfgang Grandegger [this message]
2017-06-27 10:26 ` [Buildroot] [PATCH v4 01/11] package/patchelf: use most recent version as a base for rpath sanitation Wolfgang Grandegger
2017-06-27 10:26 ` [Buildroot] [PATCH v4 02/11] package/patchelf: add patch for rpath sanitation under a root directory Wolfgang Grandegger
2017-06-27 10:26 ` [Buildroot] [PATCH v4 03/11] support/scripts: add fix-rpath script to sanitize the rpath Wolfgang Grandegger
2017-07-04 12:15   ` Arnout Vandecappelle
2017-07-04 12:36     ` Wolfgang Grandegger
2017-07-04 13:23       ` Arnout Vandecappelle
2017-07-04 14:52         ` Wolfgang Grandegger
2017-07-04 15:00           ` Samuel Martin
2017-06-27 10:26 ` [Buildroot] [PATCH v4 04/11] core: sanitize RPATH in staging tree at the end of the target finalization Wolfgang Grandegger
2017-06-27 10:26 ` [Buildroot] [PATCH v4 05/11] core: sanitize RPATH in target " Wolfgang Grandegger
2017-06-27 10:26 ` [Buildroot] [PATCH v4 06/11] core: sanitize RPATH in host tree at the very end of the build Wolfgang Grandegger
2017-06-27 10:26 ` [Buildroot] [PATCH v4 07/11] support/scripts: add reloacte-sdk.sh script for SDK relocation Wolfgang Grandegger
2017-06-27 10:26 ` [Buildroot] [PATCH v4 08/11] core: install relocation script and location at the end of the build Wolfgang Grandegger
2017-06-27 10:26 ` [Buildroot] [PATCH v4 09/11] external-toolchain: check if a buildroot SDK has already been relocated Wolfgang Grandegger
2017-06-27 10:26 ` [Buildroot] [PATCH v4 10/11] support/scripts: check-host-rpath now handles $ORIGIN as well Wolfgang Grandegger
2017-06-27 10:26 ` [Buildroot] [PATCH v4 11/11] package/qt5base: provide "qt.conf" to make "qmake" relocatable Wolfgang Grandegger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498559207-8050-1-git-send-email-wg@grandegger.com \
    --to=wg@grandegger.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.