Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Dmitrii Dolgov and committed by
Arnaldo Carvalho de Melo
804490c3 1a6c4596

+6 -8
+6 -4
tools/build/feature/Makefile
··· 113 113 __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) 114 114 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 115 115 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 - 119 116 ############################### 120 117 121 118 $(OUTPUT)test-all.bin: ··· 390 393 $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \ 391 394 > $(@:.bin=.make.output) 2>&1 392 395 396 + # Testing Rust is special: we don't compile anything, it's enough to check the 397 + # compiler presence. Compiling a test code for this purposes is problematic, 398 + # because Rust will emit a dependency file without any external references, 399 + # meaning that if rustc will be removed the build process will still think it's 400 + # there. 393 401 $(OUTPUT)test-rust.bin: 394 - $(BUILDRS) > $(@:.bin=.make.output) 2>&1 402 + $(RUSTC) --version > /dev/null 2>&1 395 403 396 404 ############################### 397 405
-4
tools/build/feature/test-rust.rs
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - fn main() { 3 - println!("hi") 4 - }