buildroot/support/scripts
Thomas Petazzoni c4e6d5c8be core: implement per-package SDK and target
This commit implements the core of the move to per-package SDK and
target directories. The main idea is that instead of having a global
output/host and output/target in which all packages install files, we
switch to per-package host and target directories, that only contain
their explicit dependencies.

There are two main benefits:

 - Packages will now see only the dependencies they explicitly list in
   their <pkg>_DEPENDENCIES variable, and the recursive dependencies
   thereof.

 - We can support top-level parallel build properly, because a package
   only "sees" its own host directory and target directory, isolated
   from the build of other packages that can happen in parallel.

It works as follows:

 - A new output/per-package/ directory is created, which will contain
   one sub-directory per package, and inside it, a "host" directory
   and a "target" directory:

   output/per-package/busybox/target
   output/per-package/busybox/host
   output/per-package/host-fakeroot/target
   output/per-package/host-fakeroot/host

   This output/per-package/ directory is PER_PACKAGE_DIR.

 - The global TARGET_DIR and HOST_DIR variable now automatically point
   to the per-package directory when PKG is defined. So whenever a
   package references $(HOST_DIR) or $(TARGET_DIR) in its build
   process, it effectively references the per-package host/target
   directories. Note that STAGING_DIR is a sub-dir of HOST_DIR, so it
   is handled as well.

 - Of course, packages have dependencies, so those dependencies must
   be installed in the per-package host and target directories. To do
   so, we simply rsync (using hard links to save space and time) the
   host and target directories of the direct dependencies of the
   package to the current package host and target directories.

   We only need to take care of direct dependencies (and not
   recursively all dependencies), because we accumulate into those
   per-package host and target directories the files installed by the
   dependencies. Note that this only works because we make the
   assumption that one package does *not* overwrite files installed by
   another package.

   This is done for "extract dependencies" at the beginning of the
   extract step, and for "normal dependencies" at the beginning of the
   configure step.

This is basically enough to make per-package SDK and target work. The
only gotcha is that at the end of the build, output/target and
output/host are empty, which means that:

 - The filesystem image creation code cannot work.

 - We don't have a SDK to build code outside of Buildroot.

In order to fix this, this commit extends the target-finalize step so
that it starts by populating output/target and output/host by
rsync-ing into them the target and host directories of all packages
listed in the $(PACKAGES) variable. It is necessary to do this
sequentially in the target-finalize step and not in each
package. Doing it in package installation means that it can be done in
parallel. In that case, there is a chance that two rsyncs are creating
the same hardlink or directory at the same time, which makes one of
them fail.

This change to per-package directories has an impact on the RPATH
built into the host binaries, as those RPATH now point to various
per-package host directories, and no longer to the global host
directory. We do not try to rewrite such RPATHs during the build as
having such RPATHs is perfectly fine, but we still need to handle two
fallouts from this change:

 - The check-host-rpath script, which verifies at the end of each
   package installation that it has the appropriate RPATH, is modified
   to understand that a RPATH to $(PER_PACKAGE_DIR)/<pkg>/host/lib is
   a correct RPAT.

 - The fix-rpath script, which mungles the RPATH mainly for the SDK
   preparation, is modified to rewrite the RPATH to not point to
   per-package directories. Indeed the patchelf --make-rpath-relative
   call only works if the RPATH points to the ROOTDIR passed as
   argument, and this ROOTDIR is the global host directory. Rewriting
   the RPATH to not point to per-package host directories prior to
   this is an easy solution to this issue.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2019-11-29 14:24:05 +01:00
..
apply-patches.sh support/scripts/apply-patches.sh: do not apply patches with renames 2017-09-19 22:51:25 +02:00
br2-external core: allow br2-external trees to provide opensl 2019-08-04 00:13:37 +02:00
brpkgutil.py support/scripts: use show-info to extract dependency graph 2019-05-07 23:03:41 +02:00
check-bin-arch support/scripts/check-bin-arch: ignore /usr/lib/grub 2019-05-20 22:33:14 +02:00
check-host-rpath core: implement per-package SDK and target 2019-11-29 14:24:05 +01:00
check-kernel-headers.sh support/scripts/check-kernel-headers.sh: use a trap to remove the temporary file 2019-09-25 22:07:29 +02:00
check-merged-usr.sh skeleton-custom: use a script to check merged usr structure 2019-02-06 17:03:30 +01:00
eclipse-register-toolchain eclipse-register-toolchain: toolchain is no longer installed in $(HOST_DIR)/usr 2017-07-05 16:06:27 +02:00
expunge-gconv-modules Change /bin/bash shebangs into /usr/bin/env bash 2014-10-25 01:55:37 +02:00
fix-configure-powerpc64.sh support/scripts: fix shebang with bash 2017-06-08 21:43:05 +02:00
fix-rpath core: implement per-package SDK and target 2019-11-29 14:24:05 +01:00
generate-gitlab-ci-yml .gitlab-ci.yml: use "extends" keyword 2019-02-06 11:40:28 +01:00
genimage.sh support/scripts/genimage.sh: pass an empty rootpath to genimage 2019-10-27 12:19:32 +01:00
graph-build-time support/scripts/graph-build-time: replace confusing colors 2019-02-04 15:23:27 +01:00
graph-depends support/scripts/graph-depends: cut on host-ccache 2019-10-02 21:07:14 +02:00
hardlink-or-copy support/scripts: fix shebang with bash 2017-06-08 21:43:05 +02:00
mkmakefile support/scripts/mkmakefile: make wrapper silent by default 2018-11-02 21:23:02 +01:00
mkusers support/scripts/mkusers: preserve group members 2018-09-12 21:22:25 +02:00
pkg-stats support/scripts/pkg-stats: simplify Git commit id retrieval 2019-09-15 16:10:22 +02:00
pycompile.py pycompile: fix code style 2018-01-29 23:14:24 +01:00
setlocalversion support/scripts/setlocalversion: ignore user settings for Mercurial 2019-02-04 21:25:33 +01:00
size-stats support/graph-size: reorder colours assigned to sizes 2019-08-26 22:51:47 +02:00