* [PATCH] libtracefs: unbreak parallel build
@ 2022-06-24 21:07 Jan Engelhardt
2022-07-11 16:43 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Jan Engelhardt @ 2022-06-24 21:07 UTC (permalink / raw)
To: linux-trace-devel; +Cc: rostedt
The build is not parallel-safe. In particular,
while :; do make clean; make -j8;
ldd -r lib/libtracefs.so.1.4.1; done
randomly emits:
undefined symbol: add_to (/usr/lib64/libtracefs.so.1)
undefined symbol: add_field (/usr/lib64/libtracefs.so.1)
undefined symbol: my_yyinput (/usr/lib64/libtracefs.so.1)
[...]
A file gets regenerated in one job while another reads it. The
hypothesis can be tested by interjecting the linker command. Like so:
@@ -73,7 +73,8 @@ do_build_static_lib = \
do_compile_shared_library = \
($(print_shared_lib_compile) \
- $(CC) --shared $^ '-Wl,-soname,$(1),-rpath=$$ORIGIN' -o $@ $(LDFLAGS) $(LIBS))
+ mkdir -p $$$$; cp -v $^ $$$$/; \
+ $(CC) --shared $$$$/* '-Wl,-soname,$(1),-rpath=$$ORIGIN' -o $@ $(LDFLAGS) $(LIBS))
do_compile_plugin_obj = \
($(print_plugin_obj_compile) \
This then reveals that indeed there is truncation:
$ ls -lgo src/25067/
total 416
drwxr-xr-x 2 4096 Jun 20 17:07 .
drwxr-xr-x 9 4096 Jun 20 17:07 ..
-rw-r--r-- 1 39240 Jun 20 17:07 sqlhist-lex.o
-rw-r--r-- 1 36088 Jun 20 17:07 sqlhist.tab.o
-rw-r--r-- 1 28912 Jun 20 17:07 tracefs-dynevents.o
-rw-r--r-- 1 5288 Jun 20 17:07 tracefs-eprobes.o
-rw-r--r-- 1 46592 Jun 20 17:07 tracefs-events.o
-rw-r--r-- 1 31136 Jun 20 17:07 tracefs-filter.o
-rw-r--r-- 1 66840 Jun 20 17:07 tracefs-hist.o
-rw-r--r-- 1 45368 Jun 20 17:07 tracefs-instance.o
-rw-r--r-- 1 8056 Jun 20 17:07 tracefs-kprobes.o
-rw-r--r-- 1 10912 Jun 20 17:07 tracefs-marker.o
-rw-r--r-- 1 0 Jun 20 17:07 tracefs-sqlhist.o
-rw-r--r-- 1 44968 Jun 20 17:07 tracefs-tools.o
-rw-r--r-- 1 6080 Jun 20 17:07 tracefs-uprobes.o
-rw-r--r-- 1 20784 Jun 20 17:07 tracefs-utils.o
The lines emitted by make also speak a rather clear picture (but I
agree we tend to not read it most of the time, especially when the
build is performed by the infrastructure of distributions and with
make V=1).
$ make clean; make -j16
CLEAN utest
CLEAN src
CLEAN samples
CLEAN libtracefs
DESCEND src libtracefs.so
make[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
COMPILE FPIC tracefs-utils.o
DESCEND src libtracefs.a
make[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
COMPILE FPIC tracefs-utils.o
UPDATE build_prefix
UPDATE tfs_version.h
COMPILE FPIC tracefs-instance.o
COMPILE FPIC tracefs-instance.o
COMPILE FPIC tracefs-events.o
COMPILE FPIC tracefs-events.o
[...]
The problem stems from two targets (libtracefs.a, libtracefs.so)
_individually_ invoking recursive make, which of course have no
knowledge of one another with respect to which targets have already
been made.
So make job #1 processes the libtracefs.a rule, whose command invokes
a sub-make which, at the time of checking, finds no .o files and
queues gcc invocations to build those file. Meanwhile, make job #2
processes the libtracefs.so rule, whose command also invokes a
sub-make which, at the time of checking, *also* finds no .o files and
queues gcc invocations for the *same* objects.
Entering a directory concurrently is worse than anything the
"recursive make considered harmful" essay could ever think of.
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
---
Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makefile b/Makefile
index fa0ba47..0044656 100644
--- a/Makefile
+++ b/Makefile
@@ -388,3 +388,7 @@ clean:
$(BUILD_PREFIX))
.PHONY: clean
+
+# libtracefs.a and libtracefs.so would concurrently enter the same directory -
+# a recipe for collisions.
+.NOTPARALLEL:
--
2.36.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libtracefs: unbreak parallel build
2022-06-24 21:07 [PATCH] libtracefs: unbreak parallel build Jan Engelhardt
@ 2022-07-11 16:43 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2022-07-11 16:43 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: linux-trace-devel
On Fri, 24 Jun 2022 23:07:26 +0200
Jan Engelhardt <jengelh@inai.de> wrote:
> Entering a directory concurrently is worse than anything the
> "recursive make considered harmful" essay could ever think of.
>
> Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Applied, thanks Jan!
-- Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-11 16:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24 21:07 [PATCH] libtracefs: unbreak parallel build Jan Engelhardt
2022-07-11 16:43 ` 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.