Skip to content

Commit 804490c

Browse files
erthalionacmel
authored andcommitted
tools build: Fix feature test for rust compiler
Currently a dummy rust code is compiled to detect if the rust feature could be enabled. It turns out that in this case rust emits a dependency file without any external references: /perf/feature/test-rust.d: test-rust.rs /perf/feature/test-rust.bin: test-rust.rs test-rust.rs: This can lead to a situation, when rustc was removed after a successful build, but the build process still thinks it's there and the feature is enabled on subsequent runs. Instead simply check the compiler presence to detect the feature, as suggested by Arnaldo. This way no actual test-rust.bin will be created, meaning the feature check will not be cached and always performed. That's exactly what we want, and the overhead of doing this every time is minimal. Tested with multiple rounds of install/remove of the rust package. Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org> Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org> Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Ian Rogers <irogers@google.com> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 1a6c459 commit 804490c

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

tools/build/feature/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(
113113
__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
114114
BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
115115

116-
__BUILDRS = $(RUSTC) $(RUSTC_FLAGS) --emit=dep-info=$(patsubst %.bin,%.d,$(@F)),link -o $@ $(patsubst %.bin,%.rs,$(@F))
117-
BUILDRS = $(__BUILDRS) > $(@:.bin=.make.output) 2>&1
118-
119116
###############################
120117

121118
$(OUTPUT)test-all.bin:
@@ -393,8 +390,13 @@ $(OUTPUT)test-bpftool-skeletons.bin:
393390
$(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
394391
> $(@:.bin=.make.output) 2>&1
395392

393+
# Testing Rust is special: we don't compile anything, it's enough to check the
394+
# compiler presence. Compiling a test code for this purposes is problematic,
395+
# because Rust will emit a dependency file without any external references,
396+
# meaning that if rustc will be removed the build process will still think it's
397+
# there.
396398
$(OUTPUT)test-rust.bin:
397-
$(BUILDRS) > $(@:.bin=.make.output) 2>&1
399+
$(RUSTC) --version > /dev/null 2>&1
398400

399401
###############################
400402

tools/build/feature/test-rust.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)