diff options
author | Bruce Ashfield <bruce.ashfield@windriver.com> | 2015-01-15 11:54:15 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-01-16 23:08:18 +0000 |
commit | 46cdaf1c7bc597735d926af6a46f9483f7e57ce5 (patch) | |
tree | e3e9a582d734bc1c6b09dbc3d9af6f5cdd364dbd | |
parent | 92725ad46f4d331bea6a2fa65964158d78a7add8 (diff) | |
download | poky-46cdaf1c7bc597735d926af6a46f9483f7e57ce5.tar.gz |
kernel: move source and build output to work-shared
commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of
moving the kernel source and build artefacts out of sstate control and
into a shared location.
This changed triggered some workflow issues, as well as bugs related
to the kernel source containing build output, and hence being dirty and
breaking kernel rebuilds.
To solve these issues, and to make it clear that the kernel is not under
sstate control, we move the source and build outputs to:
work-shared/MACHINE/kernel-source
work-shared/MACHINE/kernel-build-artifacts
Where kernel-build-artifacts is the kernel build output and
kernel-source is kept "pristine". The build-artifacts contain everything
that is required to build external modules against the kernel source,
and includes the defconfig, the kernel-abiversion, System.map files and
output from "make scripts".
External module builds should either pass O= on the command line, or
set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass
takes care of setting KBUILD_OUTPUT, so most existing external module
recipes are transparently adapted to the new source/build layout.
recipes that depend on the kernel source must have a depedency on the
do_shared_workdir task:
do_configure[depends] += "virtual/kernel:do_shared_workdir"
With this dependency added, the STAGING_KERNEL_DIR will be populated and
available to the rest of the build.
(From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/kernel-module-split.bbclass | 2 | ||||
-rw-r--r-- | meta/classes/kernel.bbclass | 30 | ||||
-rw-r--r-- | meta/classes/module-base.bbclass | 12 | ||||
-rw-r--r-- | meta/classes/module.bbclass | 2 | ||||
-rw-r--r-- | meta/conf/bitbake.conf | 3 | ||||
-rw-r--r-- | meta/recipes-kernel/linux/kernel-devsrc.bb | 14 | ||||
-rw-r--r-- | meta/recipes-kernel/lttng/lttng-modules_2.5.2.bb | 2 | ||||
-rw-r--r-- | meta/recipes-kernel/perf/perf.bb | 2 |
8 files changed, 46 insertions, 21 deletions
diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass index 9a95b72744..2d43b512df 100644 --- a/meta/classes/kernel-module-split.bbclass +++ b/meta/classes/kernel-module-split.bbclass | |||
@@ -70,7 +70,7 @@ python split_kernel_module_packages () { | |||
70 | m = kerverrexp.match(kernelver) | 70 | m = kerverrexp.match(kernelver) |
71 | if m: | 71 | if m: |
72 | kernelver_stripped = m.group(1) | 72 | kernelver_stripped = m.group(1) |
73 | staging_kernel_dir = d.getVar("STAGING_KERNEL_DIR", True) | 73 | staging_kernel_dir = d.getVar("STAGING_KERNEL_BUILDDIR", True) |
74 | system_map_file = "%s/boot/System.map-%s" % (dvar, kernelver) | 74 | system_map_file = "%s/boot/System.map-%s" % (dvar, kernelver) |
75 | if not os.path.exists(system_map_file): | 75 | if not os.path.exists(system_map_file): |
76 | system_map_file = "%s/System.map-%s" % (staging_kernel_dir, kernelver) | 76 | system_map_file = "%s/System.map-%s" % (staging_kernel_dir, kernelver) |
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index 78c8c7cf00..a60de8cc9e 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass | |||
@@ -230,28 +230,33 @@ kernel_do_install() { | |||
230 | [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION} | 230 | [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION} |
231 | install -d ${D}${sysconfdir}/modules-load.d | 231 | install -d ${D}${sysconfdir}/modules-load.d |
232 | install -d ${D}${sysconfdir}/modprobe.d | 232 | install -d ${D}${sysconfdir}/modprobe.d |
233 | } | ||
234 | do_install[prefuncs] += "package_get_auto_pr" | ||
233 | 235 | ||
234 | # | 236 | addtask shared_workdir after do_compile before do_install |
235 | # Support for external module building - create a minimal copy of the | 237 | |
236 | # kernel source tree. | 238 | do_shared_workdir () { |
237 | # | 239 | cd ${B} |
238 | kerneldir=${D}${KERNEL_SRC_PATH} | 240 | |
241 | kerneldir=${STAGING_KERNEL_BUILDDIR} | ||
239 | install -d $kerneldir | 242 | install -d $kerneldir |
240 | mkdir -p ${D}/lib/modules/${KERNEL_VERSION} | ||
241 | ln -sf ${KERNEL_SRC_PATH} "${D}/lib/modules/${KERNEL_VERSION}/build" | ||
242 | 243 | ||
243 | # | 244 | # |
244 | # Store the kernel version in sysroots for module-base.bbclass | 245 | # Store the kernel version in sysroots for module-base.bbclass |
245 | # | 246 | # |
246 | 247 | ||
247 | echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion | 248 | echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion |
248 | 249 | ||
249 | # Copy files required for module builds | 250 | # Copy files required for module builds |
250 | cp System.map $kerneldir/System.map-${KERNEL_VERSION} | 251 | cp System.map $kerneldir/System.map-${KERNEL_VERSION} |
251 | cp Module.symvers $kerneldir/ | 252 | cp Module.symvers $kerneldir/ |
252 | cp .config $kerneldir/ | 253 | cp .config $kerneldir/ |
253 | mkdir -p $kerneldir/include/config | 254 | mkdir -p $kerneldir/include/config |
254 | cp include/config/kernel.release $kerneldir/include/config/kernel.release | 255 | cp include/config/kernel.release $kerneldir/include/config/kernel.release |
256 | |||
257 | # We can also copy over all the generated files and avoid special cases | ||
258 | # like version.h, but we've opted to keep this small until file creep starts | ||
259 | # to happen | ||
255 | if [ -e include/linux/version.h ]; then | 260 | if [ -e include/linux/version.h ]; then |
256 | mkdir -p $kerneldir/include/linux | 261 | mkdir -p $kerneldir/include/linux |
257 | cp include/linux/version.h $kerneldir/include/linux/version.h | 262 | cp include/linux/version.h $kerneldir/include/linux/version.h |
@@ -273,10 +278,11 @@ kernel_do_install() { | |||
273 | cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/ | 278 | cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/ |
274 | fi | 279 | fi |
275 | } | 280 | } |
276 | do_install[prefuncs] += "package_get_auto_pr" | ||
277 | 281 | ||
278 | python sysroot_stage_all () { | 282 | # We have an empty sysroot_stage_all to keep the default routine from |
279 | oe.path.copyhardlinktree(d.expand("${D}${KERNEL_SRC_PATH}"), d.expand("${SYSROOT_DESTDIR}${KERNEL_SRC_PATH}")) | 283 | # package.bbclass from expanding the kernel source into the sysroot and |
284 | # colliding with linux-firmware files | ||
285 | sysroot_stage_all () { | ||
280 | } | 286 | } |
281 | 287 | ||
282 | KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig || yes '' | oe_runmake -C ${S} O=${B} oldconfig" | 288 | KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig || yes '' | oe_runmake -C ${S} O=${B} oldconfig" |
@@ -467,7 +473,7 @@ kernel_do_deploy() { | |||
467 | do_deploy[dirs] = "${DEPLOYDIR} ${B}" | 473 | do_deploy[dirs] = "${DEPLOYDIR} ${B}" |
468 | do_deploy[prefuncs] += "package_get_auto_pr" | 474 | do_deploy[prefuncs] += "package_get_auto_pr" |
469 | 475 | ||
470 | addtask deploy before do_build after do_install | 476 | addtask deploy after do_populate_sysroot |
471 | 477 | ||
472 | EXPORT_FUNCTIONS do_deploy | 478 | EXPORT_FUNCTIONS do_deploy |
473 | 479 | ||
diff --git a/meta/classes/module-base.bbclass b/meta/classes/module-base.bbclass index 9537ba9f43..3eb2e9226e 100644 --- a/meta/classes/module-base.bbclass +++ b/meta/classes/module-base.bbclass | |||
@@ -3,16 +3,24 @@ inherit kernel-arch | |||
3 | export OS = "${TARGET_OS}" | 3 | export OS = "${TARGET_OS}" |
4 | export CROSS_COMPILE = "${TARGET_PREFIX}" | 4 | export CROSS_COMPILE = "${TARGET_PREFIX}" |
5 | 5 | ||
6 | export KERNEL_VERSION = "${@base_read_file('${STAGING_KERNEL_DIR}/kernel-abiversion')}" | 6 | # This points to the build artefacts from the main kernel build |
7 | # such as .config and System.map | ||
8 | # Confusingly it is not the module build output (which is ${B}) but | ||
9 | # we didn't pick the name. | ||
10 | export KBUILD_OUTPUT = "${STAGING_KERNEL_BUILDDIR}" | ||
11 | |||
12 | export KERNEL_VERSION = "${@base_read_file('${STAGING_KERNEL_BUILDDIR}/kernel-abiversion')}" | ||
7 | KERNEL_OBJECT_SUFFIX = ".ko" | 13 | KERNEL_OBJECT_SUFFIX = ".ko" |
8 | 14 | ||
9 | # kernel modules are generally machine specific | 15 | # kernel modules are generally machine specific |
10 | PACKAGE_ARCH = "${MACHINE_ARCH}" | 16 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
11 | 17 | ||
18 | do_configure[depends] += "virtual/kernel:do_shared_workdir" | ||
19 | |||
12 | # Function to ensure the kernel scripts are created. Expected to | 20 | # Function to ensure the kernel scripts are created. Expected to |
13 | # be called before do_compile. See module.bbclass for an exmaple. | 21 | # be called before do_compile. See module.bbclass for an exmaple. |
14 | do_make_scripts() { | 22 | do_make_scripts() { |
15 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS | 23 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS |
16 | make CC="${KERNEL_CC}" LD="${KERNEL_LD}" AR="${KERNEL_AR}" \ | 24 | make CC="${KERNEL_CC}" LD="${KERNEL_LD}" AR="${KERNEL_AR}" \ |
17 | -C ${STAGING_KERNEL_DIR} scripts | 25 | -C ${STAGING_KERNEL_DIR} O=${STAGING_KERNEL_BUILDDIR} scripts |
18 | } | 26 | } |
diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass index 5cb8623a66..a03cc74de4 100644 --- a/meta/classes/module.bbclass +++ b/meta/classes/module.bbclass | |||
@@ -14,6 +14,7 @@ module_do_compile() { | |||
14 | KERNEL_VERSION=${KERNEL_VERSION} \ | 14 | KERNEL_VERSION=${KERNEL_VERSION} \ |
15 | CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ | 15 | CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ |
16 | AR="${KERNEL_AR}" \ | 16 | AR="${KERNEL_AR}" \ |
17 | O=${STAGING_KERNEL_BUILDDIR} \ | ||
17 | ${MAKE_TARGETS} | 18 | ${MAKE_TARGETS} |
18 | } | 19 | } |
19 | 20 | ||
@@ -21,6 +22,7 @@ module_do_install() { | |||
21 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS | 22 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS |
22 | oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" \ | 23 | oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" \ |
23 | CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ | 24 | CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ |
25 | O=${STAGING_KERNEL_BUILDDIR} \ | ||
24 | modules_install | 26 | modules_install |
25 | } | 27 | } |
26 | 28 | ||
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index 7902bd7d01..d22e9e8efe 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf | |||
@@ -395,7 +395,8 @@ SDKPATHNATIVE = "${SDKPATH}/sysroots/${SDK_SYS}" | |||
395 | ################################################################## | 395 | ################################################################## |
396 | 396 | ||
397 | OLDEST_KERNEL = "2.6.32" | 397 | OLDEST_KERNEL = "2.6.32" |
398 | STAGING_KERNEL_DIR = "${STAGING_DIR_HOST}/usr/src/kernel" | 398 | STAGING_KERNEL_DIR = "${TMPDIR}/work-shared/${MACHINE}/kernel-source" |
399 | STAGING_KERNEL_BUILDDIR = "${TMPDIR}/work-shared/${MACHINE}/kernel-build-artifacts" | ||
399 | 400 | ||
400 | ################################################################## | 401 | ################################################################## |
401 | # Specific image creation and rootfs population info. | 402 | # Specific image creation and rootfs population info. |
diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb index dbb3a5c581..a7395c46b9 100644 --- a/meta/recipes-kernel/linux/kernel-devsrc.bb +++ b/meta/recipes-kernel/linux/kernel-devsrc.bb | |||
@@ -15,7 +15,7 @@ inherit module-base | |||
15 | 15 | ||
16 | # We need the kernel to be staged (unpacked, patched and configured) before | 16 | # We need the kernel to be staged (unpacked, patched and configured) before |
17 | # we can grab the source and make the kernel-devsrc package | 17 | # we can grab the source and make the kernel-devsrc package |
18 | do_install[depends] += "virtual/kernel:do_populate_sysroot" | 18 | do_install[depends] += "virtual/kernel:do_shared_workdir" |
19 | # Need the source, not just the output of populate_sysroot | 19 | # Need the source, not just the output of populate_sysroot |
20 | do_install[depends] += "virtual/kernel:do_configure" | 20 | do_install[depends] += "virtual/kernel:do_configure" |
21 | 21 | ||
@@ -30,7 +30,8 @@ do_populate_sysroot[noexec] = "1" | |||
30 | # Define where the kernel headers are installed on the target as well as where | 30 | # Define where the kernel headers are installed on the target as well as where |
31 | # they are staged. | 31 | # they are staged. |
32 | KERNEL_SRC_PATH = "/usr/src/kernel" | 32 | KERNEL_SRC_PATH = "/usr/src/kernel" |
33 | S = "${STAGING_DIR_TARGET}/${KERNEL_SRC_PATH}" | 33 | S = "${STAGING_KERNEL_DIR}" |
34 | B = "${STAGING_KERNEL_BUILDDIR}" | ||
34 | 35 | ||
35 | KERNEL_VERSION = "${@get_kernelversion_headers('${S}')}" | 36 | KERNEL_VERSION = "${@get_kernelversion_headers('${S}')}" |
36 | 37 | ||
@@ -45,8 +46,15 @@ do_install() { | |||
45 | # We can keep this copy simple and take everything, since a we'll clean up any build | 46 | # We can keep this copy simple and take everything, since a we'll clean up any build |
46 | # artifacts afterwards, and the extra i/o is not significant | 47 | # artifacts afterwards, and the extra i/o is not significant |
47 | # | 48 | # |
49 | cd ${B} | ||
50 | find . -type d -name '.git*' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir | ||
48 | cd ${S} | 51 | cd ${S} |
49 | find . -type d -name '.git*' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir | 52 | find . -type d -name '.git*' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir |
53 | |||
54 | # Explicitly set KBUILD_OUTPUT to ensure that the image directory is cleaned and not | ||
55 | # The main build artifacts. We clean the directory to avoid QA errors on mismatched | ||
56 | # architecture (since scripts and helpers are native format). | ||
57 | KBUILD_OUTPUT="$kerneldir" | ||
50 | oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean _mrproper_scripts | 58 | oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean _mrproper_scripts |
51 | 59 | ||
52 | # As of Linux kernel version 3.0.1, the clean target removes | 60 | # As of Linux kernel version 3.0.1, the clean target removes |
@@ -54,7 +62,7 @@ do_install() { | |||
54 | # KBUILD_LDFLAGS_MODULE, making it required to build external modules. | 62 | # KBUILD_LDFLAGS_MODULE, making it required to build external modules. |
55 | if [ ${ARCH} = "powerpc" ]; then | 63 | if [ ${ARCH} = "powerpc" ]; then |
56 | mkdir -p $kerneldir/arch/powerpc/lib/ | 64 | mkdir -p $kerneldir/arch/powerpc/lib/ |
57 | cp ${S}/arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o | 65 | cp ${B}/arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o |
58 | fi | 66 | fi |
59 | } | 67 | } |
60 | # Ensure we don't race against "make scripts" during cpio | 68 | # Ensure we don't race against "make scripts" during cpio |
diff --git a/meta/recipes-kernel/lttng/lttng-modules_2.5.2.bb b/meta/recipes-kernel/lttng/lttng-modules_2.5.2.bb index 55df07f632..6ec83d090a 100644 --- a/meta/recipes-kernel/lttng/lttng-modules_2.5.2.bb +++ b/meta/recipes-kernel/lttng/lttng-modules_2.5.2.bb | |||
@@ -7,7 +7,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=1412caf5a1aa90d6a48588a4794c0eac \ | |||
7 | file://lgpl-2.1.txt;md5=243b725d71bb5df4a1e5920b344b86ad" | 7 | file://lgpl-2.1.txt;md5=243b725d71bb5df4a1e5920b344b86ad" |
8 | 8 | ||
9 | DEPENDS = "virtual/kernel" | 9 | DEPENDS = "virtual/kernel" |
10 | do_configure[depends] += "virtual/kernel:do_install" | 10 | do_configure[depends] += "virtual/kernel:do_shared_workdir" |
11 | 11 | ||
12 | inherit module | 12 | inherit module |
13 | 13 | ||
diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb index a42aa73c53..d2c9805412 100644 --- a/meta/recipes-kernel/perf/perf.bb +++ b/meta/recipes-kernel/perf/perf.bb | |||
@@ -32,7 +32,7 @@ DEPENDS = " \ | |||
32 | bison flex \ | 32 | bison flex \ |
33 | " | 33 | " |
34 | 34 | ||
35 | do_configure[depends] += "virtual/kernel:do_install" | 35 | do_configure[depends] += "virtual/kernel:do_shared_workdir" |
36 | 36 | ||
37 | PROVIDES = "virtual/perf" | 37 | PROVIDES = "virtual/perf" |
38 | 38 | ||