From a87abcf6da65f3e6aa257aaab58a24eec32a5903 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Sun, 9 Jun 2024 09:54:44 +0200 Subject: [PATCH] Makefile: run PPD and RPATH fixup in host-fialize Currently, the gdbinit is generated and installed during post install hooks, either from the gdb package, or from the external-toolchain package. When using per-package directories (PPD), the staging directory of the either package is stored in the generated gdbinit, which is not going to be valid when all the PPD staging dirs get merged into the final staging: it would lack any library installed afterwards, i.e. mostly everything would be missing (but the libraries from the C toolchain in the case of an external toolchain). Similarly, all the RPATH will point to various PPD drectories. This does not cause any issue when the final host is aggregated, because the PPD directories still exist when we call programs from there (e.g. from the fs infra, or from post-image scripts). However, we knew that would not always be possible to keep the PPD directories: we have the prepare-sdk rule that runs a cleanup pass on the RPATH, and also applies the generic PPD fixups. When we introduced prepare-sdk in c32ad51cbf2a (core/sdk: generate the SDK tarball ourselves), we did not yet have support for PPD for the host directory, and especially, we did not have the host-finalize rule, which was only introduced in d0f4f95e390b (Makefile: rework main directory creation logic) which kick-started the introduction of PPD. At that point, we did not realise that the rpath fixups from prepare-sdk, would be better moved to the new host-finalize rule, because that had no impact unless one would need an SDK. Later, in 25e60fbe1cab (Makefile: fix SDK relocation for per-package-dirs), we eventually introduced the PPD generic fixups in the prepare-sdk rule. Again, we did not realise that those fixups would be better placed in the host-finalize rule rather than the prepare-sdk. While fixing the RPATH in host-finalize is not critical, fixing up the PPD paths actually is, as the gdbinit case demonstrate. As such, move the PPD fixups to the host-finalize step, and while at it, also move the RPATH fixups. This now does not leave much to do in the prepare-sdk step, and that could very well be moved to the host-finalize rule as well. However, some people may have started to rely on prepare-sdk in its 6 years of existence, and the little script it installs is not needed unless one really needs an SDK. So leave it as it is for now. Reported-by: Casey Reeves Signed-off-by: Yann E. MORIN Tested-by: Casey Reeves Cc: Thomas Petazzoni Cc: Brandon Maier Tested-by: Brandon Maier Acked-by: TIAN Yuanhao --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index b134311cfa..24fe2f42c5 100644 --- a/Makefile +++ b/Makefile @@ -597,14 +597,7 @@ world: target-post-image .PHONY: prepare-sdk prepare-sdk: world - @$(call MESSAGE,"Rendering the SDK relocatable") - PARALLEL_JOBS=$(PARALLEL_JOBS) \ - PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \ - $(TOPDIR)/support/scripts/fix-rpath host - PARALLEL_JOBS=$(PARALLEL_JOBS) \ - PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \ - $(TOPDIR)/support/scripts/fix-rpath staging - $(call ppd-fixup-paths,$(BASE_DIR)) + @$(call MESSAGE,"Preparing the SDK") $(INSTALL) -m 755 $(TOPDIR)/support/misc/relocate-sdk.sh $(HOST_DIR)/relocate-sdk.sh mkdir -p $(HOST_DIR)/share/buildroot echo $(HOST_DIR) > $(HOST_DIR)/share/buildroot/sdk-location @@ -722,6 +715,13 @@ STAGING_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list-staging.t host-finalize: $(PACKAGES) $(HOST_DIR) $(HOST_DIR_SYMLINK) @$(call MESSAGE,"Finalizing host directory") $(call per-package-rsync,$(sort $(PACKAGES)),host,$(HOST_DIR),copy) + $(Q)PARALLEL_JOBS=$(PARALLEL_JOBS) \ + PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \ + $(TOPDIR)/support/scripts/fix-rpath host + $(Q)PARALLEL_JOBS=$(PARALLEL_JOBS) \ + PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \ + $(TOPDIR)/support/scripts/fix-rpath staging + $(call ppd-fixup-paths,$(BASE_DIR)) .PHONY: staging-finalize staging-finalize: $(STAGING_DIR_SYMLINK)