diff mbox

[v5,2/5] Makefile: add HOST_FIX_RPATH_HOOK to TARGET_FINALIZE_HOOKS

Message ID 1436824511-1601-2-git-send-email-s.martin49@gmail.com
State Changes Requested
Headers show

Commit Message

Samuel Martin July 13, 2015, 9:55 p.m. UTC
This patch adds host-patchelf as a target-finalize dependency, and
introduces the HOST_FIX_RPATH_HOOK hook fixing the ELF files' RPATH of
the HOST_DIR location (excluding the sysroot).

After running this hook, the RPATH from any host ELF files is relative to
the binary location itself.

Note that, we avoid to fix RPATH in the sysroot, and in the external
toolcahin installation location.

As a first step toward a fully relocatable SDK, this change allows to get
the toolchain relocatable, but not yet the whole SDK.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>

---
changes v4->v5:
- add verbose support

changes v3->v4:
- add host-patchelf to PACKAGES instead of target-finalize (Baruch)
- add comment

changes v2->v3:
- move hook in Makefile (Baruch)
---
 Makefile | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Sam Thursfield Jan. 6, 2016, 5:18 p.m. UTC | #1
On 13/07/15 22:55, Samuel Martin wrote:
> This patch adds host-patchelf as a target-finalize dependency, and
> introduces the HOST_FIX_RPATH_HOOK hook fixing the ELF files' RPATH of
> the HOST_DIR location (excluding the sysroot).
>
> After running this hook, the RPATH from any host ELF files is relative to
> the binary location itself.
>
> Note that, we avoid to fix RPATH in the sysroot, and in the external
> toolcahin installation location.
>
> As a first step toward a fully relocatable SDK, this change allows to get
> the toolchain relocatable, but not yet the whole SDK.
>
> Signed-off-by: Samuel Martin <s.martin49@gmail.com>
> ---
> changes v4->v5:
> - add verbose support
>
> changes v3->v4:
> - add host-patchelf to PACKAGES instead of target-finalize (Baruch)
> - add comment
>
> changes v2->v3:
> - move hook in Makefile (Baruch)
> ---
>   Makefile | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 546bcd3..4b88116 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -555,6 +555,22 @@ endef
>   TARGET_FINALIZE_HOOKS += PURGE_LOCALES
>   endif
>
> +# RPATH fixing
> +# - The host hook sets RPATH in host ELF binaries, using relative paths to the
> +#   library locations.
> +PACKAGES += host-patchelf

This should be TARGETS, not PACKAGES.
Yann E. MORIN Jan. 6, 2016, 5:31 p.m. UTC | #2
Sam, All,

On 2016-01-06 17:18 +0000, Sam Thursfield spake thusly:
> On 13/07/15 22:55, Samuel Martin wrote:
> >This patch adds host-patchelf as a target-finalize dependency, and
> >introduces the HOST_FIX_RPATH_HOOK hook fixing the ELF files' RPATH of
> >the HOST_DIR location (excluding the sysroot).
> >
> >After running this hook, the RPATH from any host ELF files is relative to
> >the binary location itself.
> >
> >Note that, we avoid to fix RPATH in the sysroot, and in the external
> >toolcahin installation location.
> >
> >As a first step toward a fully relocatable SDK, this change allows to get
> >the toolchain relocatable, but not yet the whole SDK.
> >
> >Signed-off-by: Samuel Martin <s.martin49@gmail.com>
> >---
> >changes v4->v5:
> >- add verbose support
> >
> >changes v3->v4:
> >- add host-patchelf to PACKAGES instead of target-finalize (Baruch)
> >- add comment
> >
> >changes v2->v3:
> >- move hook in Makefile (Baruch)
> >---
> >  Makefile | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> >
> >diff --git a/Makefile b/Makefile
> >index 546bcd3..4b88116 100644
> >--- a/Makefile
> >+++ b/Makefile
> >@@ -555,6 +555,22 @@ endef
> >  TARGET_FINALIZE_HOOKS += PURGE_LOCALES
> >  endif
> >
> >+# RPATH fixing
> >+# - The host hook sets RPATH in host ELF binaries, using relative paths to the
> >+#   library locations.
> >+PACKAGES += host-patchelf
> 
> This should be TARGETS, not PACKAGES.

Nope, PACKAGES is the correct variable. It has been renamed from TARGETS
to PACKAGES in April2015:

    commit 8a58e0238ef3099d31fdd01cbbcca6ae1421eea5
    Author: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
    Date:   Sun Apr 12 18:37:48 2015 +0200

        Makefile: rename TARGETS to PACKAGES

        For clarity, this commit renames the TARGETS variable to the more
        meaningful PACKAGES variable. Indeed, only packages (handled by one of
        the package infrastructures) should be listed in this variable, and
        not other random non-package targets.

        Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
        Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 546bcd3..4b88116 100644
--- a/Makefile
+++ b/Makefile
@@ -555,6 +555,22 @@  endef
 TARGET_FINALIZE_HOOKS += PURGE_LOCALES
 endif
 
+# RPATH fixing
+# - The host hook sets RPATH in host ELF binaries, using relative paths to the
+#   library locations.
+PACKAGES += host-patchelf
+
+define HOST_FIX_RPATH_HOOK
+	$(TOPDIR)/support/scripts/fix_rpaths \
+		set $(HOST_DIR) \
+		$(if $(V),--verbose) \
+		--patchelf-program $(HOST_DIR)/usr/bin/patchelf \
+		--libdirs $(HOST_DIR)/usr/lib \
+		--exclude-dirs sysroot opt/ext-toolchain
+endef
+
+TARGET_FINALIZE_HOOKS += HOST_FIX_RPATH_HOOK
+
 $(TARGETS_ROOTFS): target-finalize
 
 target-finalize: $(PACKAGES)