diff mbox series

[meta-oe,41/42] libsmi: Fix a parallel build race between bison and flex

Message ID 20261123052953.3658549-69-khem.raj@oss.qualcomm.com
State New
Headers show
Series exfatprogs upgrade, remove logfsprogs | expand

Commit Message

Khem Raj Nov. 23, 2026, 5:29 a.m. UTC
Only the smi bison rule names its parser-*.tab.h header as an output, so
under parallel make scanner-yang.c could be generated and compiled while
bison was still rewriting parser-yang.tab.h, failing with "unknown type
name YYSTYPE". The recipe regenerates the parsers on every build, since a
patch touches parser-yang.y. Make each header depend on its parser.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...the-scanners-after-the-bison-headers.patch | 41 +++++++++++++++++++
 .../recipes-support/libsmi/libsmi_0.5.0.bb    |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 meta-oe/recipes-support/libsmi/libsmi/0001-lib-Makefile.am-order-the-scanners-after-the-bison-headers.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/libsmi/libsmi/0001-lib-Makefile.am-order-the-scanners-after-the-bison-headers.patch b/meta-oe/recipes-support/libsmi/libsmi/0001-lib-Makefile.am-order-the-scanners-after-the-bison-headers.patch
new file mode 100644
index 0000000000..2c86975617
--- /dev/null
+++ b/meta-oe/recipes-support/libsmi/libsmi/0001-lib-Makefile.am-order-the-scanners-after-the-bison-headers.patch
@@ -0,0 +1,41 @@ 
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Sun, 22 Nov 2026 00:00:00 -0800
+Subject: [PATCH] lib/Makefile.am: order the scanners after the bison headers
+
+bison writes parser-*.tab.h together with parser-*.c, but only the smi
+rule names the header as an output, and that one as a second independent
+target, which can run bison twice. For sming and yang make has no rule
+for the header at all, so a scanner that includes it can be generated and
+compiled while bison is still rewriting it. Under parallel make this
+fails with errors such as "unknown type name 'YYSTYPE'" in
+scanner-yang.c.
+
+Make each header depend on its parser with no recipe of its own, so
+everything that needs a header waits for bison to finish.
+
+Upstream-Status: Pending
+AI-Generated: Uses Claude Code
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ lib/Makefile.am | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+--- a/lib/Makefile.am
++++ b/lib/Makefile.am
+@@ -45,9 +45,14 @@
+ 		  	  parser-yang.c scanner-yang.c
+ libsmi_la_LDFLAGS	= -version-info @VERSION_LIBTOOL@
+ 
+-parser-smi.c parser-smi.tab.h: parser-smi.y scanner-smi.h parser-smi.h error.h
++parser-smi.c: parser-smi.y scanner-smi.h parser-smi.h error.h
+ 	$(BISON) --defines=parser-smi.tab.h -t -psmi -o parser-smi.c parser-smi.y
+ 
++# bison writes the .tab.h headers together with the parsers
++parser-smi.tab.h: parser-smi.c
++parser-sming.tab.h: parser-sming.c
++parser-yang.tab.h: parser-yang.c
++
+ parser-sming.c: parser-sming.y scanner-sming.h parser-sming.h error.h
+ 	$(BISON) --defines=parser-sming.tab.h -t -psming -o parser-sming.c parser-sming.y
+ 
diff --git a/meta-oe/recipes-support/libsmi/libsmi_0.5.0.bb b/meta-oe/recipes-support/libsmi/libsmi_0.5.0.bb
index b57e9201c8..d5b49aaf59 100644
--- a/meta-oe/recipes-support/libsmi/libsmi_0.5.0.bb
+++ b/meta-oe/recipes-support/libsmi/libsmi_0.5.0.bb
@@ -10,6 +10,7 @@  SRC_URI = "https://www.ibr.cs.tu-bs.de/projects/${BPN}/download/${BP}.tar.gz \
            file://0001-Define-createIdentifierRef-prototype-in-yang-complex.patch \
            file://0001-parser-yang-Define-_DEFAULT_SOURCE.patch \
            file://0001-Fix-build-failure-with-gcc-15.patch \
+           file://0001-lib-Makefile.am-order-the-scanners-after-the-bison-headers.patch \
           "
 
 SRC_URI[sha256sum] = "f21accdadb1bb328ea3f8a13fc34d715baac6e2db66065898346322c725754d3"