* [PATCH] libtraceevent: avoid racing recursive builds of both libraries
@ 2026-04-05 22:21 CaoRuichuang
2026-04-06 6:28 ` [PATCH v2] " CaoRuichuang
0 siblings, 1 reply; 5+ messages in thread
From: CaoRuichuang @ 2026-04-05 22:21 UTC (permalink / raw)
To: linux-trace-devel; +Cc: rostedt, tz.stoyanov, create0818
A top-level parallel build currently starts separate recursive makes for
libtraceevent.a and libtraceevent.so. Both sub-makes rebuild the same
object files in the same output directory, which can corrupt the .o
files and make the final link fail with file format errors.
Make the default libs target descend into src/ only once and build the
shared library plus static archive from the same sub-make. Keep the
individual top-level library targets unchanged for direct use.
This reliably fixes repeated `make -j8` and `make -j8 libs` failures in a
Linux VM, where the unfixed tree reproduces the race within a few runs.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217428
Signed-off-by: CaoRuichuang <create0818@163.com>
---
Makefile | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index e1a10a0..faaeb6c 100644
--- a/Makefile
+++ b/Makefile
@@ -183,9 +183,9 @@ build := -f $(srctree)/build/Makefile.build dir=. obj
LIB_TARGET := libtraceevent.so libtraceevent.a
-CMD_TARGETS = $(LIB_TARGET) $(PKG_CONFIG_FILE)
+CMD_TARGETS = libs $(PKG_CONFIG_FILE)
-TARGETS = $(CMD_TARGETS)
+TARGETS = $(LIB_TARGET) $(PKG_CONFIG_FILE)
all: all_cmd plugins
@@ -206,7 +206,8 @@ all_cmd: $(CMD_TARGETS)
libtraceevent.a: $(bdir) $(LIBTRACEEVENT_STATIC)
libtraceevent.so: $(bdir) $(LIBTRACEEVENT_SHARED)
-libs: libtraceevent.a libtraceevent.so
+libs: $(bdir) force
+ $(Q)$(call descend,$(src)/src,libtraceevent.so $(LIBTRACEEVENT_STATIC))
$(LIBTRACEEVENT_STATIC): force
$(Q)$(call descend,$(src)/src,$@)
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2] libtraceevent: avoid racing recursive builds of both libraries
2026-04-05 22:21 [PATCH] libtraceevent: avoid racing recursive builds of both libraries CaoRuichuang
@ 2026-04-06 6:28 ` CaoRuichuang
2026-05-29 18:07 ` Steven Rostedt
0 siblings, 1 reply; 5+ messages in thread
From: CaoRuichuang @ 2026-04-06 6:28 UTC (permalink / raw)
To: linux-trace-devel; +Cc: rostedt, tz.stoyanov, create0818
A top-level parallel build currently starts separate recursive makes for
libtraceevent.a and libtraceevent.so. Both sub-makes rebuild the same
object files in the same output directory, which can corrupt the .o
files and make the final link fail with file format errors.
The src/ Makefile already builds libtraceevent.so as part of the
libtraceevent.a target. Reflect that at the top level too by making the
shared library target depend on the static library target, so parallel
requests for either or both libraries funnel through a single recursive
make.
This fixes repeated `make -j8`, `make -j8 libs`, and
`make -j8 libtraceevent.a libtraceevent.so` failures in a Linux VM,
where the unfixed tree reproduces the race within a few runs.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217428
Signed-off-by: CaoRuichuang <create0818@163.com>
---
Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index e1a10a0..6649303 100644
--- a/Makefile
+++ b/Makefile
@@ -211,8 +211,7 @@ libs: libtraceevent.a libtraceevent.so
$(LIBTRACEEVENT_STATIC): force
$(Q)$(call descend,$(src)/src,$@)
-$(LIBTRACEEVENT_SHARED): force
- $(Q)$(call descend,$(src)/src,libtraceevent.so)
+$(LIBTRACEEVENT_SHARED): $(LIBTRACEEVENT_STATIC)
$(bdir)/libtraceevent.so: $(bdir)/libtraceevent.so.$(EP_VERSION)
@ln -sf $(<F) $@
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] libtraceevent: avoid racing recursive builds of both libraries
2026-04-06 6:28 ` [PATCH v2] " CaoRuichuang
@ 2026-05-29 18:07 ` Steven Rostedt
2026-06-01 8:20 ` [PATCH v3] " Cao Ruichuang
0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2026-05-29 18:07 UTC (permalink / raw)
To: CaoRuichuang; +Cc: linux-trace-devel, tz.stoyanov
On Mon, 6 Apr 2026 14:28:55 +0800
CaoRuichuang <create0818@163.com> wrote:
Sorry for the late reply, I've been quite busy on the kernel side of things.
> A top-level parallel build currently starts separate recursive makes for
> libtraceevent.a and libtraceevent.so. Both sub-makes rebuild the same
> object files in the same output directory, which can corrupt the .o
> files and make the final link fail with file format errors.
>
> The src/ Makefile already builds libtraceevent.so as part of the
> libtraceevent.a target. Reflect that at the top level too by making the
> shared library target depend on the static library target, so parallel
> requests for either or both libraries funnel through a single recursive
> make.
>
> This fixes repeated `make -j8`, `make -j8 libs`, and
> `make -j8 libtraceevent.a libtraceevent.so` failures in a Linux VM,
> where the unfixed tree reproduces the race within a few runs.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=217428
> Signed-off-by: CaoRuichuang <create0818@163.com>
> ---
> Makefile | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index e1a10a0..6649303 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -211,8 +211,7 @@ libs: libtraceevent.a libtraceevent.so
> $(LIBTRACEEVENT_STATIC): force
> $(Q)$(call descend,$(src)/src,$@)
>
> -$(LIBTRACEEVENT_SHARED): force
> - $(Q)$(call descend,$(src)/src,libtraceevent.so)
> +$(LIBTRACEEVENT_SHARED): $(LIBTRACEEVENT_STATIC)
As you state in the change log, "Makefile already builds
libtraceevent.so as part of the libtraceevent.a target", wouldn't that
mean the above should be:
$(LIBTRACEEVENT_STATIC): $(LIBTRACEEVENT_SHARED)
$(LIBTRACEEVENT_SHARED): force
$(Q)$(call descend,$(src)/src,libtraceevent.so)
??
BTW, thanks for working on this. Sorry I couldn't get to it earlier.
-- Steve
>
> $(bdir)/libtraceevent.so: $(bdir)/libtraceevent.so.$(EP_VERSION)
> @ln -sf $(<F) $@
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] libtraceevent: avoid racing recursive builds of both libraries
2026-05-29 18:07 ` Steven Rostedt
@ 2026-06-01 8:20 ` Cao Ruichuang
2026-06-01 14:03 ` Steven Rostedt
0 siblings, 1 reply; 5+ messages in thread
From: Cao Ruichuang @ 2026-06-01 8:20 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-trace-devel, Tzvetomir Stoyanov, Cao Ruichuang
A top-level parallel build currently starts separate recursive makes for
libtraceevent.a and libtraceevent.so. Both sub-makes rebuild the same
object files in the same output directory, which can corrupt the .o files
and make the final link fail with file format errors.
The src/Makefile already has the static library depend on the shared
library before running objcopy. Reflect that dependency at the top level
too by also making the static library target depend on the shared library
target. This serializes parallel top-level requests for both libraries
while preserving the shared-before-static build order and the existing
forced static-library recursive make.
This fixes the object-file race seen when top-level parallel builds
request both libraries, for example via `make -j8 libs` or
`make -j8 libtraceevent.a libtraceevent.so`.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217428
Assisted-by: Codex:gpt-5.5
Signed-off-by: Cao Ruichuang <create0818@163.com>
---
Changes in v3:
- Follow Steven's review and make the top-level static library target
depend on the shared library target, matching src/Makefile's dependency
direction.
- Preserve the existing forced static-library recursive make while
serializing parallel top-level requests shared-before-static.
Tested on x86_64 Linux with GNU Make 4.3, GCC 11.5.0, and GNU objcopy
2.35.2:
- make -j8 libs
- make -j8 libtraceevent.a libtraceevent.so
- 20 iterations of: make clean && make -j8 libs
- 10 iterations of: make clean && make -j8 libtraceevent.a libtraceevent.so
- make -j8
- make -j8 test
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index e1a10a0..d1ceaee 100644
--- a/Makefile
+++ b/Makefile
@@ -208,7 +208,7 @@ libtraceevent.so: $(bdir) $(LIBTRACEEVENT_SHARED)
libs: libtraceevent.a libtraceevent.so
-$(LIBTRACEEVENT_STATIC): force
+$(LIBTRACEEVENT_STATIC): force $(LIBTRACEEVENT_SHARED)
$(Q)$(call descend,$(src)/src,$@)
$(LIBTRACEEVENT_SHARED): force
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3] libtraceevent: avoid racing recursive builds of both libraries
2026-06-01 8:20 ` [PATCH v3] " Cao Ruichuang
@ 2026-06-01 14:03 ` Steven Rostedt
0 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2026-06-01 14:03 UTC (permalink / raw)
To: Cao Ruichuang; +Cc: linux-trace-devel, Tzvetomir Stoyanov
On Mon, 1 Jun 2026 16:20:24 +0800
Cao Ruichuang <create0818@163.com> wrote:
> A top-level parallel build currently starts separate recursive makes for
> libtraceevent.a and libtraceevent.so. Both sub-makes rebuild the same
> object files in the same output directory, which can corrupt the .o files
> and make the final link fail with file format errors.
>
> The src/Makefile already has the static library depend on the shared
> library before running objcopy. Reflect that dependency at the top level
> too by also making the static library target depend on the shared library
> target. This serializes parallel top-level requests for both libraries
> while preserving the shared-before-static build order and the existing
> forced static-library recursive make.
>
> This fixes the object-file race seen when top-level parallel builds
> request both libraries, for example via `make -j8 libs` or
> `make -j8 libtraceevent.a libtraceevent.so`.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=217428
> Assisted-by: Codex:gpt-5.5
> Signed-off-by: Cao Ruichuang <create0818@163.com>
Thanks for the updates.
For future version updates, please start a new email thread and do not
reply to the old one. It makes it easier to manage for maintainers.
Also, the tracing code uses capital letters to start subjects:
[PATCH v3] libtraceevent: Avoid racing recursive builds of both libraries
> ---
> Changes in v3:
In order to still keep the trail of versions, you can use lore with the
Message-ID of the previous email version:
Changes since v2: https://lore.kernel.org/all/20260406062855.58598-1-create0818@163.com/
If all looks good, I'll go ahead and apply your patches.
Thanks again,
-- Steve
> - Follow Steven's review and make the top-level static library target
> depend on the shared library target, matching src/Makefile's dependency
> direction.
> - Preserve the existing forced static-library recursive make while
> serializing parallel top-level requests shared-before-static.
>
> Tested on x86_64 Linux with GNU Make 4.3, GCC 11.5.0, and GNU objcopy
> 2.35.2:
> - make -j8 libs
> - make -j8 libtraceevent.a libtraceevent.so
> - 20 iterations of: make clean && make -j8 libs
> - 10 iterations of: make clean && make -j8 libtraceevent.a libtraceevent.so
> - make -j8
> - make -j8 test
>
> Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index e1a10a0..d1ceaee 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -208,7 +208,7 @@ libtraceevent.so: $(bdir) $(LIBTRACEEVENT_SHARED)
>
> libs: libtraceevent.a libtraceevent.so
>
> -$(LIBTRACEEVENT_STATIC): force
> +$(LIBTRACEEVENT_STATIC): force $(LIBTRACEEVENT_SHARED)
> $(Q)$(call descend,$(src)/src,$@)
>
> $(LIBTRACEEVENT_SHARED): force
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-01 14:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-05 22:21 [PATCH] libtraceevent: avoid racing recursive builds of both libraries CaoRuichuang
2026-04-06 6:28 ` [PATCH v2] " CaoRuichuang
2026-05-29 18:07 ` Steven Rostedt
2026-06-01 8:20 ` [PATCH v3] " Cao Ruichuang
2026-06-01 14:03 ` Steven Rostedt
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.