Skip to content

Commit 6a32fa5

Browse files
erthalionacmel
authored andcommitted
tools build: Add a feature test for rust compiler
Add a feature test to identify if the rust compiler is available, so that perf could build rust based worloads based on that. Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com> Cc: Ian Rogers <irogers@google.com> Cc: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent ff9aeb6 commit 6a32fa5

5 files changed

Lines changed: 27 additions & 2 deletions

File tree

tools/build/Makefile.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ FEATURE_TESTS_BASIC := \
100100
disassembler-four-args \
101101
disassembler-init-styled \
102102
file-handle \
103-
libopenssl
103+
libopenssl \
104+
rust
104105

105106
# FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
106107
# of all feature tests
@@ -149,7 +150,8 @@ FEATURE_DISPLAY ?= \
149150
bpf \
150151
libaio \
151152
libzstd \
152-
libopenssl
153+
libopenssl \
154+
rust
153155

154156
#
155157
# Declare group members of a feature to display the logical OR of the detection

tools/build/feature/Makefile

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

115+
__BUILDRS = $(RUSTC) $(RUSTC_FLAGS) -o $@ $(patsubst %.bin,%.rs,$(@F))
116+
BUILDRS = $(__BUILDRS) > $(@:.bin=.make.output) 2>&1
117+
115118
###############################
116119

117120
$(OUTPUT)test-all.bin:
@@ -388,6 +391,10 @@ $(OUTPUT)test-libopenssl.bin:
388391
$(OUTPUT)test-bpftool-skeletons.bin:
389392
$(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
390393
> $(@:.bin=.make.output) 2>&1
394+
395+
$(OUTPUT)test-rust.bin:
396+
$(BUILDRS) > $(@:.bin=.make.output) 2>&1
397+
391398
###############################
392399

393400
clean:

tools/build/feature/test-rust.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
fn main() {
3+
println!("hi")
4+
}

tools/perf/Makefile.config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,17 @@ ifneq ($(NO_LIBTRACEEVENT),1)
11531153
endif
11541154
endif
11551155

1156+
ifndef NO_RUST
1157+
ifneq ($(feature-rust), 1)
1158+
$(warning Rust is not found. Test workloads with rust are disabled.)
1159+
NO_RUST := 1
1160+
else
1161+
NO_RUST := 0
1162+
CFLAGS += -DHAVE_RUST_SUPPORT
1163+
$(call detected,CONFIG_RUST_SUPPORT)
1164+
endif
1165+
endif
1166+
11561167
# Among the variables below, these:
11571168
# perfexecdir
11581169
# libbpf_include_dir

tools/perf/builtin-check.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct feature_status supported_features[] = {
6060
FEATURE_STATUS("numa_num_possible_cpus", HAVE_LIBNUMA_SUPPORT),
6161
FEATURE_STATUS("zlib", HAVE_ZLIB_SUPPORT),
6262
FEATURE_STATUS("zstd", HAVE_ZSTD_SUPPORT),
63+
FEATURE_STATUS("rust", HAVE_RUST_SUPPORT),
6364

6465
/* this should remain at end, to know the array end */
6566
FEATURE_STATUS(NULL, _)

0 commit comments

Comments
 (0)