selftests/rseq: Fix circular dependencies in Makefile
Subsystems (2)
PATCH 1/1 selftests/rseq: Fix circular dependencies in Makefile
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.
--- tools/testing/selftests/rseq/Makefile | 28 ++++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-)
tools/testing/selftests/rseq/Makefile +12 -16
@@ -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
Signature · 1 line
2.54.0
Mathieu Desnoyers
maintainerQuoted 17 lines · Mahad Ibrahim
TEST_GEN_PROGS_EXTENDEDlists 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_EXTENDEDas 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 likecheck_optimizedcompiles 9 binaries while only 2 are required.
Quoted 7 lines
Fix circular dependencies and unnecessary compilation of binaries in rseq
Makefileby 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
Quoted 67 lines
Fixes cb48828f06af ("selftests/rseq: Don't run tests with runner scripts outside of the scripts")Signed-off-by Mahad Ibrahim <[email protected]>--- tools/testing/selftests/rseq/Makefile | 28 ++++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-)tools/testing/selftests/rseq/Makefile +12
-16@@ -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
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com
Quoted 21 lines · Mahad Ibrahim
TEST_GEN_PROGS_EXTENDEDlists 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_EXTENDEDas 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 likecheck_optimizedcompiles 9 binaries while only 2 are required.Fix circular dependencies and unnecessary compilation of binaries in rseq
Makefileby isolating librseq.so and headers into a single variable which is added as the prerequisite.
Quoted 6 lines
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 <[email protected]>
Quoted 64 lines
--- tools/testing/selftests/rseq/Makefile | 28 ++++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-)tools/testing/selftests/rseq/Makefile +12
-16@@ -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