]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
tools build: Add a feature test for rust compiler
authorDmitrii Dolgov <9erthalion6@gmail.com>
Sun, 8 Feb 2026 12:22:23 +0000 (13:22 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sun, 8 Feb 2026 14:30:45 +0000 (11:30 -0300)
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>
tools/build/Makefile.feature
tools/build/feature/Makefile
tools/build/feature/test-rust.rs [new file with mode: 0644]
tools/perf/Makefile.config
tools/perf/builtin-check.c

index 7f119eafc7c464ae9e5b781c1a5ed5f90d702f2c..64d21152fc81aad60cac4b81da00aac6a90e0ba8 100644 (file)
@@ -100,7 +100,8 @@ FEATURE_TESTS_BASIC :=                  \
         disassembler-four-args         \
         disassembler-init-styled       \
         file-handle                    \
-        libopenssl
+        libopenssl                     \
+        rust
 
 # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
 # of all feature tests
@@ -149,7 +150,8 @@ FEATURE_DISPLAY ?=              \
          bpf                   \
          libaio                        \
          libzstd               \
-         libopenssl
+         libopenssl            \
+         rust
 
 #
 # Declare group members of a feature to display the logical OR of the detection
index 5c15572d505e994b88076318c3425b87a8721b78..9ae69d857166b730f733ab9df9bd742463736160 100644 (file)
@@ -112,6 +112,9 @@ __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(
 __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
   BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
 
+__BUILDRS = $(RUSTC) $(RUSTC_FLAGS) -o $@ $(patsubst %.bin,%.rs,$(@F))
+  BUILDRS = $(__BUILDRS) > $(@:.bin=.make.output) 2>&1
+
 ###############################
 
 $(OUTPUT)test-all.bin:
@@ -388,6 +391,10 @@ $(OUTPUT)test-libopenssl.bin:
 $(OUTPUT)test-bpftool-skeletons.bin:
        $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
                > $(@:.bin=.make.output) 2>&1
+
+$(OUTPUT)test-rust.bin:
+       $(BUILDRS) > $(@:.bin=.make.output) 2>&1
+
 ###############################
 
 clean:
diff --git a/tools/build/feature/test-rust.rs b/tools/build/feature/test-rust.rs
new file mode 100644 (file)
index 0000000..f2fc91c
--- /dev/null
@@ -0,0 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
+fn main() {
+    println!("hi")
+}
index b683aab3ab97e8da16529d5fd08a4fc6af645a8b..94aecfe38b95f716d1ecf19ae7362be0aecd3d66 100644 (file)
@@ -1153,6 +1153,17 @@ ifneq ($(NO_LIBTRACEEVENT),1)
   endif
 endif
 
+ifndef NO_RUST
+  ifneq ($(feature-rust), 1)
+    $(warning Rust is not found. Test workloads with rust are disabled.)
+    NO_RUST := 1
+  else
+    NO_RUST := 0
+    CFLAGS += -DHAVE_RUST_SUPPORT
+    $(call detected,CONFIG_RUST_SUPPORT)
+  endif
+endif
+
 # Among the variables below, these:
 #   perfexecdir
 #   libbpf_include_dir
index d19769a8f68977f8a4cc0917a96e785eaef39a70..27a41beeaddfcf69b77113ddbd01d03efad5682d 100644 (file)
@@ -60,6 +60,7 @@ struct feature_status supported_features[] = {
        FEATURE_STATUS("numa_num_possible_cpus", HAVE_LIBNUMA_SUPPORT),
        FEATURE_STATUS("zlib", HAVE_ZLIB_SUPPORT),
        FEATURE_STATUS("zstd", HAVE_ZSTD_SUPPORT),
+       FEATURE_STATUS("rust", HAVE_RUST_SUPPORT),
 
        /* this should remain at end, to know the array end */
        FEATURE_STATUS(NULL, _)