pkg-generic: add per-package staging directory
RFC 1/1 pkg-generic: add per-package staging directory
This commit add a per-package staging directory under output/stagingof/ to improve build reproducibility, because it prevents that a unspecified dependency affects the build.
It also help to enable default top-level parallel make.
TODO: Do more testing like testing "allyespackageconfig".
--- Makefile | 2 +- package/Makefile.in | 1 + package/pkg-generic.mk | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-)
Makefile +1 -1
@@ -829,7 +829,7 @@ printvars: clean: rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \ - $(BUILD_DIR) $(BASE_DIR)/staging \ + $(BUILD_DIR) $(BASE_DIR)/staging $(STAGINGOF_DIR) \ $(LEGAL_INFO_DIR) distclean: clean
package/Makefile.in +1 -0
@@ -108,6 +108,7 @@ endif STAGING_SUBDIR = usr/$(GNU_TARGET_NAME)/sysroot STAGING_DIR = $(HOST_DIR)/$(STAGING_SUBDIR) +STAGINGOF_DIR = $(BASE_DIR)/stagingof TARGET_OPTIMIZATION := $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
package/pkg-generic.mk +16 -0
@@ -428,6 +428,13 @@ endif # Eliminate duplicates in dependencies $(2)_FINAL_DEPENDENCIES = $$(sort $$($(2)_DEPENDENCIES)) +$(2)_TARGET_CPPFLAGS += $(foreach dep,$($(2)_DEPENDENCIES),\ + -I$(STAGINGOF_DIR)/$(dep)/usr/include) + +$(2)_TARGET_LDFLAGS += $(foreach dep,$($(2)_DEPENDENCIES),\ + -L$(STAGINGOF_DIR)/$(dep)/usr/lib \ + $($(call UPPERCASE,$(dep))_TARGET_LDFLAGS)) + $(2)_INSTALL_STAGING ?= NO $(2)_INSTALL_IMAGES ?= NO $(2)_INSTALL_TARGET ?= YES
@@ -598,10 +605,19 @@ $(1)-reconfigure: $(1)-clean-for-reconfigure $(1) # uppercase package variable prefix $$($(2)_TARGET_INSTALL_TARGET): PKG=$(2) $$($(2)_TARGET_INSTALL_STAGING): PKG=$(2) +ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY),YES) +$$($(2)_TARGET_INSTALL_STAGING): STAGING_DIR=$$(STAGINGOF_DIR)/$(1) +else +$$($(2)_TARGET_INSTALL_STAGING): STAGING_DIR:=$$(STAGING_DIR) +endif $$($(2)_TARGET_INSTALL_IMAGES): PKG=$(2) $$($(2)_TARGET_INSTALL_HOST): PKG=$(2) $$($(2)_TARGET_BUILD): PKG=$(2) +$$($(2)_TARGET_BUILD): TARGET_CPPFLAGS=$$($(2)_TARGET_CPPFLAGS) +$$($(2)_TARGET_BUILD): TARGET_LDFLAGS=$$($(2)_TARGET_LDFLAGS) $$($(2)_TARGET_CONFIGURE): PKG=$(2) +$$($(2)_TARGET_CONFIGURE): TARGET_CPPFLAGS=$$($(2)_TARGET_CPPFLAGS) +$$($(2)_TARGET_CONFIGURE): TARGET_LDFLAGS=$$($(2)_TARGET_LDFLAGS) $$($(2)_TARGET_RSYNC): SRCDIR=$$($(2)_OVERRIDE_SRCDIR) $$($(2)_TARGET_RSYNC): PKG=$(2) $$($(2)_TARGET_RSYNC_SOURCE): SRCDIR=$$($(2)_OVERRIDE_SRCDIR)
Signature · 1 line
2.1.0
Dear Fabio Porcedda,
Quoted 5 lines · Fabio Porcedda
This commit add a per-package staging directory under output/stagingof/ to improve build reproducibility, because it prevents that a unspecified dependency affects the build.
It also help to enable default top-level parallel make.
Thanks for attempting to look at this complicated problem. However, there is a fairly fundamental flaw in your proposal:
package/pkg-generic.mk endif · line 432
Quoted 2 lines
+$(2)_TARGET_CPPFLAGS += $(foreach dep,$($(2)_DEPENDENCIES),\
package/pkg-generic.mk +1
-0+ -I$(STAGINGOF_DIR)/$(dep)/usr/include)
How is this going to account for headers installed in subdirs of /usr/include ? Those are normally discovered using pkg-config for example. But with your solution, pkg-config will continue to return paths in the "common" staging directory.
My perception is that it's not really feasible to have one staging directory per-package, because it means that pkg-config would have to know, depending on which library it is asked to provide information for, should use a different sysroot dir.
I believe the only solution is to create a temporary staging directory in which you copy/extract only the libraries that are explicitly listed as the dependency of the package being built.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Quoted 20 lines · Thomas Petazzoni
Dear Fabio Porcedda,
Quoted 5 lines · Fabio Porcedda
This commit add a per-package staging directory under output/stagingof/ to improve build reproducibility, because it prevents that a unspecified dependency affects the build.
It also help to enable default top-level parallel make.
Thanks for attempting to look at this complicated problem. However, there is a fairly fundamental flaw in your proposal:
Quoted 2 lines
+$(2)_TARGET_CPPFLAGS += $(foreach dep,$($(2)_DEPENDENCIES),\
+ -I$(STAGINGOF_DIR)/$(dep)/usr/include)How is this going to account for headers installed in subdirs of
/usr/include? Those are normally discovered using pkg-config for example. But with your solution, pkg-config will continue to return paths in the "common" staging directory.
Quoted 8 lines
My perception is that it's not really feasible to have one staging directory per-package, because it means that pkg-config would have to know, depending on which library it is asked to provide information for, should use a different sysroot dir.
I believe the only solution is to create a temporary staging directory in which you copy/extract only the libraries that are explicitly listed as the dependency of the package being built.
It's just that if there is a way to don't copy files it will be faster.
Now I'm preparing a new version that do as you said. I will try to use hard links if possible.
BR
Signature · 1 line
Fabio Porcedda