packaging: add the patch for kafel 36/297036/1 accepted/tizen/8.0/unified/20231005.095253 accepted/tizen/unified/20230818.183530 tizen_8.0_m2_release
authorŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 3 Aug 2023 12:09:37 +0000 (14:09 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 9 Aug 2023 08:24:15 +0000 (10:24 +0200)
The patch fixes problems with paralel builds on highly loaded systems,
where bison(1) and flex(2) may be invoked twice and break currently
running compilers.

Change-Id: I1699ad46b5bad49f5076623f7b7b38a482e789f2
Cc: HyungGi Lee <hyunggi.lee@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
packaging/0001-Add-special-rules-for-generated-headers.patch [new file with mode: 0644]
packaging/nsjail.spec

diff --git a/packaging/0001-Add-special-rules-for-generated-headers.patch b/packaging/0001-Add-special-rules-for-generated-headers.patch
new file mode 100644 (file)
index 0000000..c1f2107
--- /dev/null
@@ -0,0 +1,60 @@
+From 2c8beea016055011d3bc9f8d6eba251539aae491 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= <l.stelmach@samsung.com>
+Date: Thu, 3 Aug 2023 12:21:37 +0200
+Subject: [PATCH] Add special rules for generated headers
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+Organization: Samsung R&D Institute Poland
+
+bison(1) and flex(1) pose a problem for make(1) because they generate
+many output files. These files when properly added to dependency tree
+may make make(1) run rules to generate them twice depending on timing
+which in turn results in a race condition and failed build especially
+on heavily loaded systems.
+
+To aviod that special rules that serialise dependencies need to be
+introduced which is what automake(1) has made for long time.
+
+https://git.savannah.gnu.org/cgit/automake.git/commit/?id=788a63b300568b1c1876e4ad30b966df2f0710fc
+
+Additionally to avoid problems when running `make -n`, rm(1) and make(1)
+commands need to be placed under separate `if` statements.
+
+https://git.savannah.gnu.org/cgit/automake.git/commit/?id=d7c1679b14c1ab691927f3243df1cb3cbb2360aa
+
+Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
+---
+ src/Makefile | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/src/Makefile b/src/Makefile
+index d029fc4..b425825 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -65,12 +65,20 @@ ${STATIC_TARGET}: ${OBJECTS}
+       $(AR) rcs $@ libkafel.o
+       $(RM) libkafel.o
+-lexer.h lexer.c: lexer.l
++lexer.c: lexer.l
+       flex $<
+-parser.h parser.c: parser.y
++lexer.h: lexer.c
++      @if test ! -f lexer.h; then rm -f lexer.c; fi
++      @if test ! -f lexer.h; then $(MAKE) lexer.c; fi
++
++parser.c: parser.y
+       bison $<
++parser.h: parser.c
++      @if test ! -f parser.h; then rm -f parser.c; fi
++      @if test ! -f parser.h; then $(MAKE) parser.c; fi
++
+ # DO NOT DELETE THIS LINE -- make depend depends on it.
+ kafel.o: codegen.h context.h includes.h parser_types.h policy.h expression.h
+-- 
+2.39.2
+
index 300c21f128fde68e47cd0581004672235af7591a..77c3692f28278963eb22d167aea7456284e31197 100644 (file)
@@ -15,6 +15,7 @@ Source0:        nsjail-%{version}.tar.gz
 Source1001:    %{name}.manifest
 Source1002:    %{name}.service
 Source1003:    %{name}.sh
+Source2001:    0001-Add-special-rules-for-generated-headers.patch
 BuildRequires:  autoconf
 BuildRequires:  bison
 BuildRequires:  flex
@@ -50,6 +51,12 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN"
 %ifarch %{arm}
 export LDFLAGS="$LDFLAGS -mthumb"
 %endif
+tar -xf kafel.tar.gz
+pushd kafel
+for p in %{SOURCE2001}; do
+       patch -p1 < $p
+done
+popd
 make %{?_smp_mflags}
 
 pushd test