mirror of
https://git.yoctoproject.org/meta-arm
synced 2026-04-20 11:29:54 +00:00
arm/scp-firmware: backport a build race fix
There is a build race when generating the module includes which causes errors, backport the fix. Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
Upstream-Status: Backport
|
||||
Signed-off-by: Ross Burton <ross.burton@arm.com>
|
||||
|
||||
From 8aba6e5159273e2ed82d55780f35356262cb79c8 Mon Sep 17 00:00:00 2001
|
||||
From: Ross Burton <ross.burton@arm.com>
|
||||
Date: Tue, 8 Sep 2020 11:49:08 +0100
|
||||
Subject: [PATCH] tools/gen_module_code: atomically rewrite the generated files
|
||||
|
||||
The gen_module rule in rules.mk is marked as .PHONY, so make will
|
||||
execute it whenever it is mentioned. This results in gen_module_code
|
||||
being executed 64 times for a Juno build.
|
||||
|
||||
However in heavily parallel builds there's a good chance that
|
||||
gen_module_code is writing a file whilst the compiler is reading it
|
||||
because make also doesn't know what files are generated by
|
||||
gen_module_code.
|
||||
|
||||
The correct fix is to adjust the Makefiles so that the dependencies are
|
||||
correct but this isn't trivial, so band-aid the problem by atomically
|
||||
writing the generated files.
|
||||
|
||||
Change-Id: I82d44f9ea6537a91002e1f80de8861d208571630
|
||||
Signed-off-by: Ross Burton <ross.burton@arm.com>
|
||||
---
|
||||
tools/gen_module_code.py | 19 ++++++++++++++-----
|
||||
1 file changed, 14 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/tools/gen_module_code.py b/tools/gen_module_code.py
|
||||
index 7b3953845..ee099b713 100755
|
||||
--- a/tools/gen_module_code.py
|
||||
+++ b/tools/gen_module_code.py
|
||||
@@ -17,6 +17,7 @@
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
+import tempfile
|
||||
|
||||
DEFAULT_PATH = 'build/'
|
||||
|
||||
@@ -53,13 +54,21 @@ TEMPLATE_C = "/* This file was auto generated using {} */\n" \
|
||||
|
||||
def generate_file(path, filename, content):
|
||||
full_filename = os.path.join(path, filename)
|
||||
- with open(full_filename, 'a+') as f:
|
||||
- f.seek(0)
|
||||
- if f.read() != content:
|
||||
+
|
||||
+ try:
|
||||
+ with open(full_filename) as f:
|
||||
+ rewrite = f.read() != content
|
||||
+ except FileNotFoundError:
|
||||
+ rewrite = True
|
||||
+
|
||||
+ if rewrite:
|
||||
+ with tempfile.NamedTemporaryFile(prefix="gen-module-code",
|
||||
+ dir=path,
|
||||
+ delete=False,
|
||||
+ mode="wt") as f:
|
||||
print("[GEN] {}...".format(full_filename))
|
||||
- f.seek(0)
|
||||
- f.truncate()
|
||||
f.write(content)
|
||||
+ os.replace(f.name, full_filename)
|
||||
|
||||
|
||||
def generate_header(path, modules):
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -11,6 +11,7 @@ LIC_FILES_CHKSUM += "file://cmsis/LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c2
|
||||
SRC_URI = "\
|
||||
git://github.com/ARM-software/SCP-firmware.git;protocol=https;name=scp;destsuffix=src;nobranch=1 \
|
||||
git://github.com/ARM-software/CMSIS_5.git;protocol=https;name=cmsis;destsuffix=src/cmsis;lfs=0;nobranch=1 \
|
||||
file://0001-tools-gen_module_code-atomically-rewrite-the-generat.patch \
|
||||
"
|
||||
|
||||
PV = "2.6+git${SRCPV}"
|
||||
|
||||
Reference in New Issue
Block a user