[OE-core] [PATCH RFC] module.bbclass: Fix potential do_compile/do_make_scripts race condition

Paul Barker paul.barker at commagility.com
Sun Dec 6 11:26:34 UTC 2015


In the Linux 3.10.y series, repeatedly running 'make scripts' causes the modpost
script to be rebuilt every time. This causes a potential race condition when
building multiple external modules against a 3.10.y series kernel: one recipe
may be running do_make_scripts and modifying modpost whilst another is running
do_compile and using modpost. In my case this caused a permission error during
do_compile for one recipe as modpost was not executable at the time it tried to
run it.

In Linux 3.11 this was resolved and multiple invocations of 'make scripts' does
not cause modpost to be rebuilt. However, there are still vendor kernels in use
based on the 3.10.y series. Even on later kernel versions it would require more
investigation to conclude that running 'make scripts' whilst also building an
out-of-tree module is always safe. Therefore we should prevent do_make_scripts
from running at the same time as do_compile.

A side effect of this is that only one out-of-tree module recipe can be running
do_compile at any time. This may affect build time if multiple, large
out-of-tree modules are being built but that should be rare and the impact on
overall build time should be low.

Signed-off-by: Paul Barker <paul.barker at commagility.com>
---
 meta/classes/module.bbclass | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass
index 0952c0c..74280f0 100644
--- a/meta/classes/module.bbclass
+++ b/meta/classes/module.bbclass
@@ -4,6 +4,10 @@ addtask make_scripts after do_patch before do_compile
 do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
 do_make_scripts[depends] += "virtual/kernel:do_shared_workdir"
 
+# Ensure one recipe isn't running do_make_scripts whilst another is using those
+# scripts in do_compile.
+do_compile[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
+
 EXTRA_OEMAKE += "KERNEL_SRC=${STAGING_KERNEL_DIR}"
 
 module_do_compile() {
-- 
1.8.3.1




More information about the Openembedded-core mailing list