* [PATCH] selftests/rseq: Fix circular dependencies in Makefile
@ 2026-08-18 15:53 Mahad Ibrahim
2026-08-25 19:43 ` Mathieu Desnoyers
2026-08-26 18:43 ` Michael Jeanson
0 siblings, 2 replies; 3+ messages in thread
From: Mahad Ibrahim @ 2026-08-18 15:53 UTC (permalink / raw)
To: mathieu.desnoyers, peterz, paulmck, boqun, shuah
Cc: broonie, linux-kernel, linux-kselftest, Mahad Ibrahim
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] selftests/rseq: Fix circular dependencies in Makefile
2026-08-18 15:53 [PATCH] selftests/rseq: Fix circular dependencies in Makefile Mahad Ibrahim
@ 2026-08-25 19:43 ` Mathieu Desnoyers
2026-08-26 18:43 ` Michael Jeanson
1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Desnoyers @ 2026-08-25 19:43 UTC (permalink / raw)
To: Mahad Ibrahim, peterz, paulmck, boqun, shuah, Michael Jeanson
Cc: broonie, linux-kernel, linux-kselftest
On 2026-08-18 11:53, Mahad Ibrahim wrote:
> 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.
Adding Michael in CC.
Thanks,
Mathieu
>
> 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
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] selftests/rseq: Fix circular dependencies in Makefile
2026-08-18 15:53 [PATCH] selftests/rseq: Fix circular dependencies in Makefile Mahad Ibrahim
2026-08-25 19:43 ` Mathieu Desnoyers
@ 2026-08-26 18:43 ` Michael Jeanson
1 sibling, 0 replies; 3+ messages in thread
From: Michael Jeanson @ 2026-08-26 18:43 UTC (permalink / raw)
To: Mahad Ibrahim, mathieu.desnoyers, peterz, paulmck, boqun, shuah
Cc: broonie, linux-kernel, linux-kselftest
On 2026-08-18 11:53, Mahad Ibrahim wrote:
> 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>
Tested-by: Michael Jeanson <mjeanson@efficios.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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-26 18:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18 15:53 [PATCH] selftests/rseq: Fix circular dependencies in Makefile Mahad Ibrahim
2026-08-25 19:43 ` Mathieu Desnoyers
2026-08-26 18:43 ` Michael Jeanson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox