summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@windriver.com>2018-08-18 22:50:44 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-19 16:35:22 +0100
commit9af0f1a46bbb6ad9ee8b35957251f4aa826b023f (patch)
treec90fd86b7128672ebc58966bf867af3bef3d00d8 /meta
parent47a73c522817ba352ac4ddae660be8dc47486460 (diff)
downloadpoky-9af0f1a46bbb6ad9ee8b35957251f4aa826b023f.tar.gz
kernel-devsrc: restructure for out of tree (and on target) module builds
The existing kernel-devsrc package starts with a full copy of the kernel source and then starts to strip out elements that are not required. This results in extra time (I/O) and extra space being taken up in the final package. The main purpose of the kernel-devsrc package has been to build modules against the running kernel, not to include a full copy of the source code for re-building the kernel. The end result was a 600M kernel-devsrc package. This restructuring of the package uses an approach similar to other distros, where the kernel-devsrc package is for building against the running kernel and uses a curated set of copied infrastructure, versus a mass copy of the entire kernel. The differences in this approach versus other is largely due to the architecture support and the split build/source directory of the kernel. The result is a kernel-devsrc package of about 10M, which is capable of running "make scripts" and compiling kernel modules against the running kernel. Along with the changes to the copying of the infrascture, we also have the following changes: - a better/more explicit listing of dependencies for on-target builds of "make scripts" or "make modules_prepare" - The kernel source is installed into /lib/modules/<version>/build and a symlink created from /usr/src/kernel to the new location. This aligns with the standard location for module support code - There is also a symlink from /lib/modules/<version>/source -> build to reserve a spot for a new package that is simply the kernel source. That package is not part of this update. (From OE-Core rev: 007ef1f468110b2698a27ea9a6d43fed5a0a9fc2) Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/runtime/cases/stap.py2
-rw-r--r--meta/recipes-core/images/build-appliance-image_15.0.0.bb6
-rw-r--r--meta/recipes-kernel/linux/kernel-devsrc.bb239
3 files changed, 197 insertions, 50 deletions
diff --git a/meta/lib/oeqa/runtime/cases/stap.py b/meta/lib/oeqa/runtime/cases/stap.py
index fc728bfc55..96e197a2d6 100644
--- a/meta/lib/oeqa/runtime/cases/stap.py
+++ b/meta/lib/oeqa/runtime/cases/stap.py
@@ -25,7 +25,7 @@ class StapTest(OERuntimeTestCase):
25 def test_stap(self): 25 def test_stap(self):
26 cmds = [ 26 cmds = [
27 'cd /usr/src/kernel && make scripts prepare', 27 'cd /usr/src/kernel && make scripts prepare',
28 'cd /lib/modules/`uname -r` && (if [ ! -L build ]; then ln -s /usr/src/kernel build; fi)', 28 'cd /lib/modules/`uname -r` && (if [ ! -e build ]; then ln -s /usr/src/kernel build; fi)',
29 'stap --disable-cache -DSTP_NO_VERREL_CHECK /tmp/hello.stp' 29 'stap --disable-cache -DSTP_NO_VERREL_CHECK /tmp/hello.stp'
30 ] 30 ]
31 for cmd in cmds: 31 for cmd in cmds:
diff --git a/meta/recipes-core/images/build-appliance-image_15.0.0.bb b/meta/recipes-core/images/build-appliance-image_15.0.0.bb
index db2f58dfb9..7b210f0969 100644
--- a/meta/recipes-core/images/build-appliance-image_15.0.0.bb
+++ b/meta/recipes-core/images/build-appliance-image_15.0.0.bb
@@ -59,8 +59,10 @@ fakeroot do_populate_poky_src () {
59 cp ${WORKDIR}/README_VirtualBox_Toaster.txt ${IMAGE_ROOTFS}/home/builder/ 59 cp ${WORKDIR}/README_VirtualBox_Toaster.txt ${IMAGE_ROOTFS}/home/builder/
60 60
61 # Create a symlink, needed for out-of-tree kernel modules build 61 # Create a symlink, needed for out-of-tree kernel modules build
62 rm -f ${IMAGE_ROOTFS}/lib/modules/${KERNEL_VERSION}/build 62 if [ ! -e ${IMAGE_ROOTFS}/lib/modules/${KERNEL_VERSION}/build ]; then
63 lnr ${IMAGE_ROOTFS}${KERNEL_SRC_PATH} ${IMAGE_ROOTFS}/lib/modules/${KERNEL_VERSION}/build 63 rm -f ${IMAGE_ROOTFS}/lib/modules/${KERNEL_VERSION}/build
64 lnr ${IMAGE_ROOTFS}${KERNEL_SRC_PATH} ${IMAGE_ROOTFS}/lib/modules/${KERNEL_VERSION}/build
65 fi
64 66
65 echo "INHERIT += \"rm_work\"" >> ${IMAGE_ROOTFS}/home/builder/poky/build/conf/auto.conf 67 echo "INHERIT += \"rm_work\"" >> ${IMAGE_ROOTFS}/home/builder/poky/build/conf/auto.conf
66 echo "export LC_ALL=en_US.utf8" >> ${IMAGE_ROOTFS}/home/builder/.bashrc 68 echo "export LC_ALL=en_US.utf8" >> ${IMAGE_ROOTFS}/home/builder/.bashrc
diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
index 8bbfa23e4b..b3f529237a 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
@@ -30,57 +30,202 @@ do_populate_sysroot[noexec] = "1"
30S = "${STAGING_KERNEL_DIR}" 30S = "${STAGING_KERNEL_DIR}"
31B = "${STAGING_KERNEL_BUILDDIR}" 31B = "${STAGING_KERNEL_BUILDDIR}"
32 32
33KERNEL_VERSION = "${@get_kernelversion_headers('${S}')}"
34
35PACKAGE_ARCH = "${MACHINE_ARCH}" 33PACKAGE_ARCH = "${MACHINE_ARCH}"
36 34
35KERNEL_BUILD_ROOT="/lib/modules/"
36
37do_install() { 37do_install() {
38 kerneldir=${D}${KERNEL_SRC_PATH} 38 kerneldir=${D}${KERNEL_BUILD_ROOT}${KERNEL_VERSION}
39 install -d $kerneldir 39 install -d $kerneldir
40 40
41 # 41 # create the directory structure
42 # Copy the staging dir source (and module build support) into the devsrc structure. 42 rm -f $kerneldir/build
43 # We can keep this copy simple and take everything, since a we'll clean up any build 43 rm -f $kerneldir/source
44 # artifacts afterwards, and the extra i/o is not significant 44 mkdir -p $kerneldir/build
45 # 45
46 cd ${B} 46 # for compatibility with some older variants of this package, we
47 find . -type d -name '.git*' -prune -o -path '.debug' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir 47 # create a /usr/src/kernel symlink to /lib/modules/<version>/source
48 cd ${S} 48 mkdir -p ${D}/usr/src
49 find . -type d -name '.git*' -prune -o -type d -name '.kernel-meta' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir 49 (
50 50 cd ${D}/usr/src
51 # Explicitly set KBUILD_OUTPUT to ensure that the image directory is cleaned and not 51 ln -s ${KERNEL_BUILD_ROOT}${KERNEL_VERSION}/source kernel
52 # The main build artifacts. We clean the directory to avoid QA errors on mismatched 52 )
53 # architecture (since scripts and helpers are native format). 53
54 KBUILD_OUTPUT="$kerneldir" 54 # for on target purposes, we unify build and source
55 oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean _mrproper_scripts 55 (
56 # make clean generates an absolute path symlink called "source" 56 cd $kerneldir
57 # in $kerneldir points to $kerneldir, which doesn't make any 57 ln -s build source
58 # sense, so remove it. 58 )
59 if [ -L $kerneldir/source ]; then 59
60 bbnote "Removing $kerneldir/source symlink" 60 # first copy everything
61 rm -f $kerneldir/source 61 (
62 fi 62 cd ${S}
63 63 cp --parents $(find -type f -name "Makefile*" -o -name "Kconfig*") $kerneldir/build
64 # As of Linux kernel version 3.0.1, the clean target removes 64 cp --parents $(find -type f -name "Build" -o -name "Build.include") $kerneldir/build
65 # arch/powerpc/lib/crtsavres.o which is present in 65 )
66 # KBUILD_LDFLAGS_MODULE, making it required to build external modules. 66
67 if [ ${ARCH} = "powerpc" ]; then 67 # then drop all but the needed Makefiles/Kconfig files
68 mkdir -p $kerneldir/arch/powerpc/lib/ 68 rm -rf $kerneldir/build/Documentation
69 cp ${B}/arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o 69 rm -rf $kerneldir/build/scripts
70 fi 70 rm -rf $kerneldir/build/include
71 71
72 # Remove fixdep/objtool as they won't be target binaries 72 # now copy in parts from the build that we'll need later
73 for i in fixdep objtool; do 73 (
74 if [ -e $kerneldir/tools/objtool/$i ]; then 74 cd ${B}
75 rm -rf $kerneldir/tools/objtool/$i 75
76 fi 76 cp Module.symvers $kerneldir/build
77 done 77 cp System.map* $kerneldir/build
78 78 if [ -s Module.markers ]; then
79 chown -R root:root ${D} 79 cp Module.markers $kerneldir/build
80 fi
81
82 cp .config $kerneldir/build
83
84 # This scripts copy blow up QA, so for now, we require a more
85 # complex 'make scripts' to restore these, versus copying them
86 # here. Left as a reference to indicate that we know the scripts must
87 # be dealt with.
88 # cp -a scripts $kerneldir/build
89
90 if [ -d arch/${ARCH}/scripts ]; then
91 cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
92 fi
93 if [ -f arch/${ARCH}/*lds ]; then
94 cp -a arch/${ARCH}/*lds $kerneldir/build/arch/${ARCH}
95 fi
96
97 rm -f $kerneldir/build/scripts/*.o
98 rm -f $kerneldir/build/scripts/*/*.o
99
100 if [ "${ARCH}" = "powerpc" ]; then
101 if [ -e arch/powerpc/lib/crtsavres.S ] ||
102 [ -e arch/powerpc/lib/crtsavres.o ]; then
103 cp -a --parents arch/powerpc/lib/crtsavres.[So] $kerneldir/build/
104 fi
105 fi
106
107 if [ "${ARCH}" = "arm64" ]; then
108 cp -a --parents arch/arm64/kernel/vdso/vdso.lds $kerneldir/build/
109 fi
110
111 cp -a include $kerneldir/build/include
112 )
113
114 # now grab the chunks from the source tree that we need
115 (
116 cd ${S}
117
118 cp -a scripts $kerneldir/build
119
120 # if our build dir had objtool, it will also be rebuilt on target, so
121 # we copy what is required for that build
122 if [ -f ${B}/tools/objtool/objtool ]; then
123 # these are a few files associated with objtool, since we'll need to
124 # rebuild it
125 cp -a --parents tools/build/Build.include $kerneldir/build/
126 cp -a --parents tools/build/Build $kerneldir/build/
127 cp -a --parents tools/build/fixdep.c $kerneldir/build/
128 cp -a --parents tools/scripts/utilities.mak $kerneldir/build/
129
130 # extra files, just in case
131 cp -a --parents tools/objtool/* $kerneldir/build/
132 cp -a --parents tools/lib/str_error_r.c $kerneldir/build/
133 cp -a --parents tools/lib/string.c $kerneldir/build/
134 cp -a --parents tools/lib/subcmd/* $kerneldir/build/
135
136 cp -a --parents tools/include/* $kerneldir/build/
137 fi
138
139 if [ "${ARCH}" = "arm64" ]; then
140 # arch/arm64/include/asm/xen references arch/arm
141 cp -a --parents arch/arm/include/asm/xen $kerneldir/build/
142 # arch/arm64/include/asm/opcodes.h references arch/arm
143 cp -a --parents arch/arm/include/asm/opcodes.h $kerneldir/build/
144
145 cp -a --parents arch/arm64/kernel/vdso/gettimeofday.S $kerneldir/build/
146 cp -a --parents arch/arm64/kernel/vdso/sigreturn.S $kerneldir/build/
147 cp -a --parents arch/arm64/kernel/vdso/note.S $kerneldir/build/
148 cp -a --parents arch/arm64/kernel/vdso/gen_vdso_offsets.sh $kerneldir/build/
149 fi
150
151 # include the machine specific headers for ARM variants, if available.
152 if [ "${ARCH}" = "arm" ]; then
153 cp -a --parents arch/${ARCH}/mach-*/include $kerneldir/build/
154
155 # include a few files for 'make prepare'
156 cp -a --parents arch/arm/tools/gen-mach-types $kerneldir/build/
157 cp -a --parents arch/arm/tools/mach-types $kerneldir/build/
158 cp -a --parents arch/arm/tools/syscall* $kerneldir/build/
159 fi
160
161 if [ -d arch/${ARCH}/include ]; then
162 cp -a --parents arch/${ARCH}/include $kerneldir/build/
163 fi
164
165 cp -a include $kerneldir/build
166
167 cp -a --parents tools/include/tools/le_byteshift.h $kerneldir/build/
168 cp -a --parents tools/include/tools/be_byteshift.h $kerneldir/build/
169
170 # required for generate missing syscalls prepare phase
171 cp -a --parents arch/x86/entry/syscalls/syscall_32.tbl $kerneldir/build
172
173 if [ "${ARCH}" = "x86" ]; then
174 # files for 'make prepare' to succeed with kernel-devel
175 cp -a --parents arch/x86/entry/syscalls/syscall_32.tbl $kerneldir/build/
176 cp -a --parents arch/x86/entry/syscalls/syscalltbl.sh $kerneldir/build/
177 cp -a --parents arch/x86/entry/syscalls/syscallhdr.sh $kerneldir/build/
178 cp -a --parents arch/x86/entry/syscalls/syscall_64.tbl $kerneldir/build/
179 cp -a --parents arch/x86/tools/relocs_32.c $kerneldir/build/
180 cp -a --parents arch/x86/tools/relocs_64.c $kerneldir/build/
181 cp -a --parents arch/x86/tools/relocs.c $kerneldir/build/
182 cp -a --parents arch/x86/tools/relocs_common.c $kerneldir/build/
183 cp -a --parents arch/x86/tools/relocs.h $kerneldir/build/
184 cp -a --parents arch/x86/purgatory/purgatory.c $kerneldir/build/
185
186 # 4.18 + have unified the purgatory files, so we ignore any errors if
187 # these files are not present
188 cp -a --parents arch/x86/purgatory/sha256.h $kerneldir/build/ 2>/dev/null || :
189 cp -a --parents arch/x86/purgatory/sha256.c $kerneldir/build/ 2>/dev/null || :
190
191 cp -a --parents arch/x86/purgatory/stack.S $kerneldir/build/
192 cp -a --parents arch/x86/purgatory/string.c $kerneldir/build/
193 cp -a --parents arch/x86/purgatory/setup-x86_64.S $kerneldir/build/
194 cp -a --parents arch/x86/purgatory/entry64.S $kerneldir/build/
195 cp -a --parents arch/x86/boot/string.h $kerneldir/build/
196 cp -a --parents arch/x86/boot/string.c $kerneldir/build/
197 cp -a --parents arch/x86/boot/ctype.h $kerneldir/build/
198 fi
199
200 if [ "${ARCH}" = "mips" ]; then
201 cp -a --parents arch/mips/Kbuild.platforms $kerneldir/build/
202 cp --parents $(find -type f -name "Platform") $kerneldir/build
203 cp --parents arch/mips/boot/tools/relocs* $kerneldir/build
204 cp -a --parents arch/mips/kernel/asm-offsets.c $kerneldir/build
205 cp -a --parents kernel/time/timeconst.bc $kerneldir/build
206 cp -a --parents kernel/bounds.c $kerneldir/build
207 cp -a --parents Kbuild $kerneldir/build
208 fi
209 )
210
211 # Make sure the Makefile and version.h have a matching timestamp so that
212 # external modules can be built
213 touch -r $kerneldir/build/Makefile $kerneldir/build/include/generated/uapi/linux/version.h
214
215 # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
216 cp $kerneldir/build/.config $kerneldir/build/include/config/auto.conf
217
218 chown -R root:root ${D}
80} 219}
220
81# Ensure we don't race against "make scripts" during cpio 221# Ensure we don't race against "make scripts" during cpio
82do_install[lockfiles] = "${TMPDIR}/kernel-scripts.lock" 222do_install[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
83 223
84PACKAGES = "kernel-devsrc" 224FILES_${PN} = "${KERNEL_BUILD_ROOT} ${KERNEL_SRC_PATH}"
85FILES_${PN} = "${KERNEL_SRC_PATH}" 225FILES_${PN}-dbg += "${KERNEL_BUILD_ROOT}*/build/scripts/*/.debug/*"
86RDEPENDS_${PN} = "bc" 226
227RDEPENDS_${PN} = "bc python flex bison ${TCLIBC}-utils"
228# 4.15+ needs these next two RDEPENDS
229RDEPENDS_${PN} += "openssl-dev util-linux"
230# and x86 needs a bit more for 4.15+
231RDEPENDS_${PN} += "${@bb.utils.contains('ARCH', 'x86', 'elfutils', '', d)}"