The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
To: mathieu.desnoyers@efficios.com, peterz@infradead.org,
	paulmck@kernel.org, boqun@kernel.org, shuah@kernel.org
Cc: broonie@kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
Subject: [PATCH] selftests/rseq: Fix circular dependencies in Makefile
Date: Tue, 18 Aug 2026 15:53:37 +0000	[thread overview]
Message-ID: <20260818155337.4774-1-mahad.ibrahim.dev@gmail.com> (raw)

TEST_GEN_PROGS_EXTENDED lists the binaries which are to be built but not
run. However it is also listed as prerequisite for every generated binary
to link against; all binaries only require librseq.so.

This results in the following warnings:

  make: Circular .../rseq/check_optimized <- .../rseq/check_optimized dependency dropped.

Such warnings are emitted 36 times in in-tree and out-of-tree builds.

Additionally, the generation of a single binary pulls in all of
TEST_GEN_PROGS_EXTENDED as they are listed as prerequisites for each
other. However since Make drops all the prerequisites which form a cycle,
the build succeeds, but results in unintended behavior. For example
building a single binary like check_optimized compiles 9 binaries while
only 2 are required.

Fix circular dependencies and unnecessary compilation of binaries in rseq
Makefile by isolating librseq.so and headers into a single variable which
is added as the prerequisite.

No warnings are emitted after the change, and building a single binary
only compiles that binary and librseq.so. Verified in-tree and with
OUTPUT= set to a separate directory.

Fixes: cb48828f06af ("selftests/rseq: Don't run tests with runner scripts outside of the scripts")
Signed-off-by: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
---
 tools/testing/selftests/rseq/Makefile | 28 ++++++++++++---------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/rseq/Makefile b/tools/testing/selftests/rseq/Makefile
index aba6317f6cb8..9c369e59bb2d 100644
--- a/tools/testing/selftests/rseq/Makefile
+++ b/tools/testing/selftests/rseq/Makefile
@@ -37,41 +37,37 @@ TEST_FILES := settings
 
 include ../lib.mk
 
+RSEQ_DEPS := $(OUTPUT)/librseq.so rseq.h rseq-*.h
+
 $(OUTPUT)/librseq.so: rseq.c rseq.h rseq-*.h
 	$(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@
 
-$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
+$(OUTPUT)/%: %.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
 
-$(OUTPUT)/basic_percpu_ops_mm_cid_test: basic_percpu_ops_test.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
+$(OUTPUT)/basic_percpu_ops_mm_cid_test: basic_percpu_ops_test.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID $< $(LDLIBS) -lrseq -o $@
 
-$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
-					rseq.h rseq-*.h
+$(OUTPUT)/param_test_benchmark: param_test.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
 
-$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
-					rseq.h rseq-*.h
+$(OUTPUT)/param_test_compare_twice: param_test.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
 
-$(OUTPUT)/param_test_mm_cid: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
-					rseq.h rseq-*.h
+$(OUTPUT)/param_test_mm_cid: param_test.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID $< $(LDLIBS) -lrseq -o $@
 
-$(OUTPUT)/param_test_mm_cid_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
-					rseq.h rseq-*.h
+$(OUTPUT)/param_test_mm_cid_benchmark: param_test.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
 
-$(OUTPUT)/param_test_mm_cid_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
-					rseq.h rseq-*.h
+$(OUTPUT)/param_test_mm_cid_compare_twice: param_test.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
 
-$(OUTPUT)/syscall_errors_test: syscall_errors_test.c $(TEST_GEN_PROGS_EXTENDED) \
-					rseq.h rseq-*.h
+$(OUTPUT)/syscall_errors_test: syscall_errors_test.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
 
-$(OUTPUT)/slice_test: slice_test.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
+$(OUTPUT)/slice_test: slice_test.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
 
-$(OUTPUT)/check_optimized: check_optimized.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
+$(OUTPUT)/check_optimized: check_optimized.c $(RSEQ_DEPS)
 	$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@

base-commit: 0f23d56f17fdfc7db69d51f64c8b91bbab947aa9
-- 
2.54.0


                 reply	other threads:[~2026-08-18 15:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260818155337.4774-1-mahad.ibrahim.dev@gmail.com \
    --to=mahad.ibrahim.dev@gmail.com \
    --cc=boqun@kernel.org \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox