93 lines
3.0 KiB
Diff
93 lines
3.0 KiB
Diff
From 19c46bafab94716141a8e2ec9ade2f7dd47a6384 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Wed, 5 Mar 2025 11:31:10 +0000
|
|
Subject: [PATCH] rust: Disable clippy warnings unless --enable-gcc-warnings is
|
|
used
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Turn ./configure --enable-gcc-warnings into a general "enable compiler
|
|
warnings" option (we'll probably need to change the name of it later).
|
|
Then use this option to control whether Rust clippy warnings are
|
|
enabled or not.
|
|
|
|
Note that CI generally enables this option so we should still see Rust
|
|
errors in CI.
|
|
|
|
Reported-by: Thomas Weißschuh
|
|
(cherry picked from commit aa6b3a9954418659c5d27aae3ef3fe9005961510)
|
|
---
|
|
configure.ac | 14 +++++++++-----
|
|
plugins/rust/Makefile.am | 5 ++++-
|
|
2 files changed, 13 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/configure.ac b/configure.ac
|
|
index c3ef3aff..ff4a4049 100644
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -225,17 +225,20 @@ AS_IF([$CXX --version >&AS_MESSAGE_LOG_FD 2>&1],[have_cxx=yes],[have_cxx=no])
|
|
AC_MSG_RESULT([$have_cxx])
|
|
AM_CONDITIONAL([HAVE_CXX], [test "$have_cxx" = "yes"])
|
|
|
|
+dnl If --enable-gcc-warnings is used, then compiler warnings are
|
|
+dnl turned on. Despite the name this applies to GCC, Clang and
|
|
+dnl Rust (clippy) warnings.
|
|
AC_ARG_ENABLE([gcc-warnings],
|
|
[AS_HELP_STRING([--enable-gcc-warnings],
|
|
- [turn on lots of GCC warnings (for developers)])],
|
|
+ [turn on compiler warnings (for developers)])],
|
|
[case $enableval in
|
|
yes|no) ;;
|
|
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
|
|
esac
|
|
- gcc_warnings=$enableval],
|
|
- [gcc_warnings=no]
|
|
+ compiler_warnings=$enableval],
|
|
+ [compiler_warnings=no]
|
|
)
|
|
-if test "x$gcc_warnings" = "xyes"; then
|
|
+if test "x$compiler_warnings" = "xyes"; then
|
|
WARNINGS_CFLAGS="-Wall -Wshadow -Wvla -Werror"
|
|
AC_SUBST([WARNINGS_CFLAGS])
|
|
|
|
@@ -251,8 +254,8 @@ if test "x$gcc_warnings" = "xyes"; then
|
|
[AC_MSG_RESULT([no])]
|
|
)
|
|
AC_SUBST([WARNINGS_MODULE_CXXFLAGS])
|
|
-
|
|
fi
|
|
+AM_CONDITIONAL([COMPILER_WARNINGS], [test "$compiler_warnings" = "yes"])
|
|
|
|
dnl Check if the compiler supports -std=c90 flag. This is only used
|
|
dnl during a test. OpenBSD GCC does not support this flag so we skip
|
|
@@ -1818,6 +1821,7 @@ echo
|
|
echo "Other optional features:"
|
|
echo
|
|
feature "allocator=zstd" test "x$HAVE_LIBZSTD_TRUE" = "x"
|
|
+feature "compiler warnings" test "x$COMPILER_WARNINGS_TRUE" = "x"
|
|
feature "tests using libguestfs" \
|
|
test "x$HAVE_LIBGUESTFS_TRUE" = "x" && \
|
|
test "x$USE_LIBGUESTFS_FOR_TESTS_TRUE" = "x"
|
|
diff --git a/plugins/rust/Makefile.am b/plugins/rust/Makefile.am
|
|
index dc774e11..33f13107 100644
|
|
--- a/plugins/rust/Makefile.am
|
|
+++ b/plugins/rust/Makefile.am
|
|
@@ -81,9 +81,12 @@ endif
|
|
TESTS = \
|
|
cargo-tests.sh \
|
|
test-ramdisk.sh \
|
|
- clippy.sh \
|
|
$(NULL)
|
|
|
|
+if COMPILER_WARNINGS
|
|
+TESTS += clippy.sh
|
|
+endif
|
|
+
|
|
if HAVE_POD
|
|
|
|
man_MANS = nbdkit-rust-plugin.3
|
|
--
|
|
2.47.1
|
|
|