All of lore.kernel.org
 help / color / mirror / Atom feed
* [honister][PATCH] dev86: fix a build race
@ 2022-05-11  2:53 Anuj Mittal
  2022-05-12  4:04 ` [meta-virtualization] " Bruce Ashfield
  0 siblings, 1 reply; 2+ messages in thread
From: Anuj Mittal @ 2022-05-11  2:53 UTC (permalink / raw)
  To: meta-virtualization

From: Ross Burton <ross.burton@arm.com>

Fix a race in cpp/ where token[12].h are written to a temporary file
with the same name.

Also update the status of cross.patch.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
(cherry picked from commit 36433bfef3b690ee1211f04a38022b1f3dc2b383)
---
 ...1-cpp-fix-race-writing-token.h-files.patch | 42 +++++++++++++++++++
 recipes-extended/dev86/dev86/cross.patch      |  2 +-
 recipes-extended/dev86/dev86_git.bb           |  3 +-
 3 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100644 recipes-extended/dev86/dev86/0001-cpp-fix-race-writing-token.h-files.patch

diff --git a/recipes-extended/dev86/dev86/0001-cpp-fix-race-writing-token.h-files.patch b/recipes-extended/dev86/dev86/0001-cpp-fix-race-writing-token.h-files.patch
new file mode 100644
index 0000000..d6e7999
--- /dev/null
+++ b/recipes-extended/dev86/dev86/0001-cpp-fix-race-writing-token.h-files.patch
@@ -0,0 +1,42 @@
+Upstream-Status: Submitted [https://github.com/jbruchon/dev86/pull/23]
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+
+From f507ee398ae20e4e97f01dfbd9a8709a90bc760f Mon Sep 17 00:00:00 2001
+From: Ross Burton <ross.burton@arm.com>
+Date: Fri, 29 Apr 2022 16:44:08 +0100
+Subject: [PATCH] cpp: fix race writing token.h files
+
+The rules for token1.h and token2.h both write to a temporary file tmp.h
+before renaming to token1.h or token2.h. However, in a parallel build
+these will execute at the same time and race.
+
+  gperf -aptTc -N is_ctok -H hash1 token1.tok > tmp.h
+  gperf -aptTc -k1,3 -N is_ckey -H hash2 token2.tok > tmp.h
+  mv tmp.h token1.h
+  mv tmp.h token2.h
+  mv: cannot stat 'tmp.h': No such file or directory
+
+By using gperf --output-file, the race is avoided entirely.
+---
+ cpp/Makefile | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/cpp/Makefile b/cpp/Makefile
+index 0ea43cc..743694f 100644
+--- a/cpp/Makefile
++++ b/cpp/Makefile
+@@ -20,9 +20,7 @@ token1.o: token1.h
+ token2.o: token2.h
+ 
+ token1.h: token1.tok
+-	gperf -aptTc -N is_ctok -H hash1 token1.tok > tmp.h
+-	mv tmp.h token1.h
++	gperf -aptTc -N is_ctok -H hash1 --output-file $@ $<
+ 
+ token2.h: token2.tok
+-	gperf -aptTc -k1,3 -N is_ckey -H hash2 token2.tok > tmp.h
+-	mv tmp.h token2.h
++	gperf -aptTc -k1,3 -N is_ckey -H hash2 --output-file $@ $<
+-- 
+2.25.1
+
diff --git a/recipes-extended/dev86/dev86/cross.patch b/recipes-extended/dev86/dev86/cross.patch
index 041a8d3..fd62c5d 100644
--- a/recipes-extended/dev86/dev86/cross.patch
+++ b/recipes-extended/dev86/dev86/cross.patch
@@ -1,6 +1,6 @@
 Build ifdef using BUILD_CC, not CC.
 
-Upstream-Status: Pending
+Upstream-Status: Submitted [https://github.com/jbruchon/dev86/pull/22]
 Signed-off-by: Ross Burton <ross.burton@arm.com>
 
 diff --git a/Makefile b/Makefile
diff --git a/recipes-extended/dev86/dev86_git.bb b/recipes-extended/dev86/dev86_git.bb
index 88e9cf3..094fcbd 100644
--- a/recipes-extended/dev86/dev86_git.bb
+++ b/recipes-extended/dev86/dev86_git.bb
@@ -11,7 +11,8 @@ SRC_URI = "git://github.com/jbruchon/${BPN}.git;protocol=https;branch=master \
     file://0001-cpp-Makefile-respect-LDFLAGS-when-building-bcc-cpp.patch \
     file://0003-cpp-update-token1.tok-to-make-new-gperf-happy-regen..patch \
     file://0004-regen-token2.h-token1.h-with-gperf-3.1.patch \
-	file://cross.patch \
+    file://cross.patch \
+    file://0001-cpp-fix-race-writing-token.h-files.patch \
 "
 
 S = "${WORKDIR}/git"
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [meta-virtualization] [honister][PATCH] dev86: fix a build race
  2022-05-11  2:53 [honister][PATCH] dev86: fix a build race Anuj Mittal
@ 2022-05-12  4:04 ` Bruce Ashfield
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Ashfield @ 2022-05-12  4:04 UTC (permalink / raw)
  To: Anuj Mittal; +Cc: meta-virtualization

merged to honister.

Bruce

In message: [meta-virtualization] [honister][PATCH] dev86: fix a build race
on 11/05/2022 Anuj Mittal wrote:

> From: Ross Burton <ross.burton@arm.com>
> 
> Fix a race in cpp/ where token[12].h are written to a temporary file
> with the same name.
> 
> Also update the status of cross.patch.
> 
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
> (cherry picked from commit 36433bfef3b690ee1211f04a38022b1f3dc2b383)
> ---
>  ...1-cpp-fix-race-writing-token.h-files.patch | 42 +++++++++++++++++++
>  recipes-extended/dev86/dev86/cross.patch      |  2 +-
>  recipes-extended/dev86/dev86_git.bb           |  3 +-
>  3 files changed, 45 insertions(+), 2 deletions(-)
>  create mode 100644 recipes-extended/dev86/dev86/0001-cpp-fix-race-writing-token.h-files.patch
> 
> diff --git a/recipes-extended/dev86/dev86/0001-cpp-fix-race-writing-token.h-files.patch b/recipes-extended/dev86/dev86/0001-cpp-fix-race-writing-token.h-files.patch
> new file mode 100644
> index 0000000..d6e7999
> --- /dev/null
> +++ b/recipes-extended/dev86/dev86/0001-cpp-fix-race-writing-token.h-files.patch
> @@ -0,0 +1,42 @@
> +Upstream-Status: Submitted [https://github.com/jbruchon/dev86/pull/23]
> +Signed-off-by: Ross Burton <ross.burton@arm.com>
> +
> +From f507ee398ae20e4e97f01dfbd9a8709a90bc760f Mon Sep 17 00:00:00 2001
> +From: Ross Burton <ross.burton@arm.com>
> +Date: Fri, 29 Apr 2022 16:44:08 +0100
> +Subject: [PATCH] cpp: fix race writing token.h files
> +
> +The rules for token1.h and token2.h both write to a temporary file tmp.h
> +before renaming to token1.h or token2.h. However, in a parallel build
> +these will execute at the same time and race.
> +
> +  gperf -aptTc -N is_ctok -H hash1 token1.tok > tmp.h
> +  gperf -aptTc -k1,3 -N is_ckey -H hash2 token2.tok > tmp.h
> +  mv tmp.h token1.h
> +  mv tmp.h token2.h
> +  mv: cannot stat 'tmp.h': No such file or directory
> +
> +By using gperf --output-file, the race is avoided entirely.
> +---
> + cpp/Makefile | 6 ++----
> + 1 file changed, 2 insertions(+), 4 deletions(-)
> +
> +diff --git a/cpp/Makefile b/cpp/Makefile
> +index 0ea43cc..743694f 100644
> +--- a/cpp/Makefile
> ++++ b/cpp/Makefile
> +@@ -20,9 +20,7 @@ token1.o: token1.h
> + token2.o: token2.h
> + 
> + token1.h: token1.tok
> +-	gperf -aptTc -N is_ctok -H hash1 token1.tok > tmp.h
> +-	mv tmp.h token1.h
> ++	gperf -aptTc -N is_ctok -H hash1 --output-file $@ $<
> + 
> + token2.h: token2.tok
> +-	gperf -aptTc -k1,3 -N is_ckey -H hash2 token2.tok > tmp.h
> +-	mv tmp.h token2.h
> ++	gperf -aptTc -k1,3 -N is_ckey -H hash2 --output-file $@ $<
> +-- 
> +2.25.1
> +
> diff --git a/recipes-extended/dev86/dev86/cross.patch b/recipes-extended/dev86/dev86/cross.patch
> index 041a8d3..fd62c5d 100644
> --- a/recipes-extended/dev86/dev86/cross.patch
> +++ b/recipes-extended/dev86/dev86/cross.patch
> @@ -1,6 +1,6 @@
>  Build ifdef using BUILD_CC, not CC.
>  
> -Upstream-Status: Pending
> +Upstream-Status: Submitted [https://github.com/jbruchon/dev86/pull/22]
>  Signed-off-by: Ross Burton <ross.burton@arm.com>
>  
>  diff --git a/Makefile b/Makefile
> diff --git a/recipes-extended/dev86/dev86_git.bb b/recipes-extended/dev86/dev86_git.bb
> index 88e9cf3..094fcbd 100644
> --- a/recipes-extended/dev86/dev86_git.bb
> +++ b/recipes-extended/dev86/dev86_git.bb
> @@ -11,7 +11,8 @@ SRC_URI = "git://github.com/jbruchon/${BPN}.git;protocol=https;branch=master \
>      file://0001-cpp-Makefile-respect-LDFLAGS-when-building-bcc-cpp.patch \
>      file://0003-cpp-update-token1.tok-to-make-new-gperf-happy-regen..patch \
>      file://0004-regen-token2.h-token1.h-with-gperf-3.1.patch \
> -	file://cross.patch \
> +    file://cross.patch \
> +    file://0001-cpp-fix-race-writing-token.h-files.patch \
>  "
>  
>  S = "${WORKDIR}/git"
> -- 
> 2.35.3
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#7275): https://lists.yoctoproject.org/g/meta-virtualization/message/7275
> Mute This Topic: https://lists.yoctoproject.org/mt/91028521/1050810
> Group Owner: meta-virtualization+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-12  4:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  2:53 [honister][PATCH] dev86: fix a build race Anuj Mittal
2022-05-12  4:04 ` [meta-virtualization] " Bruce Ashfield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.