diff mbox series

[meta-oe,3/3] uftrace: Fix parallel build races

Message ID 20261127155557.2874294-4-khem.raj@oss.qualcomm.com
State New
Headers show
Series Build fixes for nodejs and uftrace, kernel-selftest OOM skips | expand

Commit Message

Khem Raj Nov. 27, 2026, 3:55 p.m. UTC
misc/symbols and misc/dbginfo link arch/<arch>/common.o, which only the
arch Makefile knows how to build. When the top-level make reaches it
first, it uses the builtin %.o rule without the -iquote include paths:

  arch/x86_64/common.c:10:10: fatal error: 'uftrace.h' file not found
  make: *** [<builtin>: .../arch/x86_64/common.o] Error 1

Make the object depend on uftrace-arch.a so the arch Makefile builds it.
Before the change, "make -j16 --shuffle=2" failed this way, and so did
building $(objdir)/misc/symbols alone in a clean tree.

Also backport the upstream fix for the libmcount dependency on version.h,
a second race that "make --shuffle" exposes in 0.20.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...d-error-with-make-shuffle-for-arch-c.patch | 44 +++++++++++++++++++
 ...-Fix-a-build-error-with-make-shuffle.patch | 43 ++++++++++++++++++
 .../recipes-devtools/uftrace/uftrace_0.20.bb  |  2 +
 3 files changed, 89 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/uftrace/uftrace/0002-build-Fix-a-build-error-with-make-shuffle-for-arch-c.patch
 create mode 100644 meta-oe/recipes-devtools/uftrace/uftrace/0003-build-Fix-a-build-error-with-make-shuffle.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/uftrace/uftrace/0002-build-Fix-a-build-error-with-make-shuffle-for-arch-c.patch b/meta-oe/recipes-devtools/uftrace/uftrace/0002-build-Fix-a-build-error-with-make-shuffle-for-arch-c.patch
new file mode 100644
index 0000000000..cd18eddb00
--- /dev/null
+++ b/meta-oe/recipes-devtools/uftrace/uftrace/0002-build-Fix-a-build-error-with-make-shuffle-for-arch-c.patch
@@ -0,0 +1,44 @@ 
+From 2347c298f7ac45f2a55dea065deadd0eabc410f1 Mon Sep 17 00:00:00 2001
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Thu, 26 Nov 2026 23:25:06 -0800
+Subject: [PATCH] build: Fix a build error with make --shuffle for arch
+ common.o
+
+The misc/symbols and misc/dbginfo link $(objdir)/arch/$(ARCH)/common.o
+but the top-level Makefile has no rule for it; it's built by the arch
+Makefile as a part of uftrace-arch.a.  When make reaches the object
+before uftrace-arch.a, it falls back to the builtin %.o rule which lacks
+the -iquote include paths (or fails with "No rule to make target" when
+objdir is different from srcdir):
+
+  $ make -j16 --shuffle=2
+  ...
+  arch/x86_64/common.c:10:10: fatal error: uftrace.h: No such file or directory
+  make: *** [<builtin>: .../arch/x86_64/common.o] Error 1
+
+Building the tool alone, like `make $PWD/misc/symbols` in a clean tree,
+fails the same way every time.
+
+Add a rule with an empty recipe that makes the object depend on
+uftrace-arch.a so that it's always built by the arch Makefile.
+
+Upstream-Status: Submitted [https://github.com/namhyung/uftrace/pull/2079]
+AI-Generated: Uses Claude Code
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ Makefile | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index a4e43a12..a220cc86 100644
+--- a/Makefile
++++ b/Makefile
+@@ -316,6 +316,8 @@ $(LIBMCOUNT_ARCH_OBJS): $(wildcard $(srcdir)/arch/$(ARCH)/*.[cS]) $(LIBMCOUNT_DE
+ $(UFTRACE_ARCH_OBJS): $(wildcard $(srcdir)/arch/$(ARCH)/*.[cS]) $(COMMON_DEPS)
+ 	@$(MAKE) -B -C $(srcdir)/arch/$(ARCH) $@
+ 
++$(objdir)/arch/$(ARCH)/common.o: $(UFTRACE_ARCH_OBJS) ;
++
+ $(objdir)/uftrace.o: $(srcdir)/uftrace.c $(objdir)/version.h $(COMMON_DEPS)
+ 	$(QUIET_CC)$(CC) $(UFTRACE_CFLAGS) -c -o $@ $<
+ 
diff --git a/meta-oe/recipes-devtools/uftrace/uftrace/0003-build-Fix-a-build-error-with-make-shuffle.patch b/meta-oe/recipes-devtools/uftrace/uftrace/0003-build-Fix-a-build-error-with-make-shuffle.patch
new file mode 100644
index 0000000000..43bc24df07
--- /dev/null
+++ b/meta-oe/recipes-devtools/uftrace/uftrace/0003-build-Fix-a-build-error-with-make-shuffle.patch
@@ -0,0 +1,43 @@ 
+From a18631b7d579746bb91ae55f1d7701d57190012a Mon Sep 17 00:00:00 2001
+From: Namhyung Kim <namhyung@gmail.com>
+Date: Mon, 7 Sep 2026 08:39:29 -0400
+Subject: [PATCH] build: Fix a build error with make --shuffle
+
+The libmcount also has a dependency on version.h but it's not handled by
+make as it's built after the uftrace binary.  In fact, each variant of
+libmcount build should add the dependency for the mcount.c file.
+
+The Gentoo tinderbox CI found the issue when it randomized the make
+target ordering with `make --shuffle`.
+
+Fixed: #2070
+Upstream-Status: Backport [https://github.com/namhyung/uftrace/commit/cb0eec80fd149ce6ad0be2926094095b32ee704c]
+Signed-off-by: Namhyung Kim <namhyung@gmail.com>
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ Makefile | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index a220cc86..7ce81f30 100644
+--- a/Makefile
++++ b/Makefile
+@@ -233,6 +233,9 @@ LIBMCOUNT_FAST_OBJS := $(patsubst $(objdir)/%.op,$(objdir)/%-fast.op,$(LIBMCOUNT
+ LIBMCOUNT_SINGLE_OBJS := $(patsubst $(objdir)/%.op,$(objdir)/%-single.op,$(LIBMCOUNT_OBJS))
+ LIBMCOUNT_FAST_SINGLE_OBJS := $(patsubst $(objdir)/%.op,$(objdir)/%-fast-single.op,$(LIBMCOUNT_OBJS))
+ 
++LIBMCOUNT_OBJS_VERSION := $(objdir)/libmcount/mcount.op $(objdir)/libmcount/mcount-single.op
++LIBMCOUNT_OBJS_VERSION += $(objdir)/libmcount/mcount-fast.op $(objdir)/libmcount/mcount-fast-single.op
++
+ LIBMCOUNT_UTILS_SRCS += $(srcdir)/utils/debug.c $(srcdir)/utils/regs.c
+ LIBMCOUNT_UTILS_SRCS += $(srcdir)/utils/rbtree.c $(srcdir)/utils/filter.c
+ LIBMCOUNT_UTILS_SRCS += $(srcdir)/utils/shmem.c $(srcdir)/utils/utils.c
+@@ -335,7 +338,7 @@ $(objdir)/misc/bench.o: $(srcdir)/misc/bench.c
+ 
+ $(objdir)/cmds/dump.o: $(C_STR_OBJS)
+ 
+-$(UFTRACE_OBJS_VERSION): $(objdir)/version.h
++$(UFTRACE_OBJS_VERSION) $(LIBMCOUNT_OBJS_VERSION): $(objdir)/version.h
+ 
+ $(filter-out $(objdir)/uftrace.o, $(UFTRACE_OBJS)): $(objdir)/%.o: $(srcdir)/%.c $(COMMON_DEPS)
+ 	$(QUIET_CC)$(CC) $(UFTRACE_CFLAGS) -c -o $@ $<
diff --git a/meta-oe/recipes-devtools/uftrace/uftrace_0.20.bb b/meta-oe/recipes-devtools/uftrace/uftrace_0.20.bb
index 28c2186418..80878ee296 100644
--- a/meta-oe/recipes-devtools/uftrace/uftrace_0.20.bb
+++ b/meta-oe/recipes-devtools/uftrace/uftrace_0.20.bb
@@ -11,6 +11,8 @@  DEPENDS:append:libc-musl = " argp-standalone"
 SRCREV = "842ed731248a9daded38774d8fb26c7b09474461"
 SRC_URI = "git://github.com/namhyung/${BPN};branch=master;protocol=https;tag=v${PV} \
            file://0001-include-libgen.h-for-basename.patch \
+           file://0002-build-Fix-a-build-error-with-make-shuffle-for-arch-c.patch \
+           file://0003-build-Fix-a-build-error-with-make-shuffle.patch \
            "
 
 LDFLAGS:append:libc-musl = " -largp"