* [PATCH 1/2] xfsprogs: turn on more warnings for the filesystem code we modify most @ 2026-10-15 14:46 Darrick J. Wong 2026-10-15 14:51 ` [PATCH 2/2] xfsprogs: even more debug whining Darrick J. Wong 0 siblings, 1 reply; 2+ messages in thread From: Darrick J. Wong @ 2026-10-15 14:46 UTC (permalink / raw) To: Andrey Albershteyn; +Cc: Christoph Hellwig, linux-xfs From: Darrick J. Wong <djwong@kernel.org> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> --- include/builddefs.in | 79 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 80 insertions(+), 3 deletions(-) diff --git a/include/builddefs.in b/include/builddefs.in index acdbc5c865768b..41076ddf389f82 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -21,6 +21,83 @@ BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 # only use what we calculate from the configured options above. LDFLAGS = +# Generate more debugging info +WARNINGS += -femit-struct-debug-detailed=any +WARNINGS += -fstack-usage + +# Base warnings(?) +WARNINGS += -Wall +WARNINGS += -Wpointer-sign +WARNINGS += -Wuninitialized +WARNINGS += -Wno-error=format= # dont trip on printf debugging + +# Fedora wants to modernize C... +WARNINGS += -Wimplicit-int +WARNINGS += -Wimplicit-function-declaration +WARNINGS += -Wint-conversion +WARNINGS += -Wstrict-prototypes +WARNINGS += -Wold-style-definition + +# Derived from scripts/Makefile.extrawarn on 2023-09-12 (v6.6-rc1) + +# W=e +WARNINGS += -Werror + +# W=1 +WARNINGS += -Wextra -Wunused -Wno-unused-parameter +WARNINGS += -Wmissing-declarations +WARNINGS += -Wrestrict +WARNINGS += -Wmissing-format-attribute +WARNINGS += -Wmissing-prototypes +WARNINGS += -Wold-style-definition +WARNINGS += -Wmissing-include-dirs +WARNINGS += -Wunused-but-set-variable +WARNINGS += -Wunused-const-variable +WARNINGS += -Wpacked-not-aligned +WARNINGS += -Wformat-overflow +WARNINGS += -Wformat-truncation +WARNINGS += -Wstringop-overflow +WARNINGS += -Wstringop-truncation + +WARNINGS += -Wundef + +# W=2 +WARNINGS += -Wdisabled-optimization +WARNINGS += -Wshadow +WARNINGS += -Wlogical-op +WARNINGS += -Wmissing-field-initializers +WARNINGS += -Wtype-limits +WARNINGS += -Wmaybe-uninitialized +WARNINGS += -Wno-error=maybe-uninitialized # gcc 14.2 vs xfs_bmap.c +#WARNINGS += -Wunused-macros # dont care about extra macros + +# W=3 +#WARNINGS += -Wbad-function-cast # pagecache +#WARNINGS += -Wcast-align # hits char* to struct* casts on riscv64 +#WARNINGS += -Wcast-qual # rhashtable +#WARNINGS += -Wconversion # everywhere +#WARNINGS += -Wpacked # this whines about unnecesary __packed?? +#WARNINGS += -Wpadded # maple tree +#WARNINGS += -Wpointer-arith # container_of +#WARNINGS += -Wredundant-decls # ftrace +#WARNINGS += -Wsign-compare # percpu +#WARNINGS += -Wswitch-default # everywhere +#WARNINGS += $(call cc-option, -Wpacked-bitfield-compat) # not a gcc thing + +# Stuff we need to fix in xfsprogs +WARNINGS += -Wno-suggest-attribute=format # dont care about printf crap +WARNINGS += -Wno-shadow # many programs have global variables +WARNINGS += -Wno-missing-field-initializers # why is this even a problem? +WARNINGS += -Wno-sign-compare # zomg so much macro +WARNINGS += -Wno-dangling-pointer # gcc 12.2 bug + +WARNINGS += -Wno-error=type-limits # rtgroups patchset +WARNINGS += -Wno-error=array-bounds # rtgroups patchset + +# Comment out for release builds +CFLAGS += $(WARNINGS) +BUILD_CFLAGS += $(WARNINGS) + LIBRT = @librt@ LIBUUID = @libuuid@ LIBURCU = @liburcu@ @@ -128,7 +205,7 @@ NEED_INTERNAL_STATMOUNT = @need_internal_statmount@ HAVE_FANOTIFY_MOUNTINFO = @have_fanotify_mountinfo@ HAVE_QUOTACTL_FD = @have_quotactl_fd@ -GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall +GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall -Werror -Wextra -Wno-unused-parameter # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl # _LGPL_SOURCE is for liburcu to work correctly with GPL/LGPL programs ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] xfsprogs: even more debug whining 2026-10-15 14:46 [PATCH 1/2] xfsprogs: turn on more warnings for the filesystem code we modify most Darrick J. Wong @ 2026-10-15 14:51 ` Darrick J. Wong 0 siblings, 0 replies; 2+ messages in thread From: Darrick J. Wong @ 2026-10-15 14:51 UTC (permalink / raw) To: Andrey Albershteyn; +Cc: Christoph Hellwig, linux-xfs From: Darrick J. Wong <djwong@kernel.org> Yeah these should be consolidated Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> --- configure.ac | 2 ++ include/builddefs.in | 48 +++++++++++++++++++++++++++++++++++++++++++++++ m4/package_sanitizer.m4 | 14 ++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/configure.ac b/configure.ac index a4e491895e020d..3628f53dbb4a96 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,8 @@ fi AC_PROG_CXX # no C++ build tools yet +AC_HAVE_X86_CFLAGS + AC_ARG_ENABLE(shared, [ --enable-shared=[yes/no] Enable use of shared libraries [default=yes]],, enable_shared=yes) diff --git a/include/builddefs.in b/include/builddefs.in index 41076ddf389f82..81678113815330 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -94,6 +94,54 @@ WARNINGS += -Wno-dangling-pointer # gcc 12.2 bug WARNINGS += -Wno-error=type-limits # rtgroups patchset WARNINGS += -Wno-error=array-bounds # rtgroups patchset +# OpenSSF recommendations March 2025 +# https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html +#WARNINGS += -O2 # already set elsewhere +#WARNINGS += -Wall +WARNINGS += -Wformat +WARNINGS += -Wformat=2 +WARNINGS += -Wno-format-nonliteral # xfs_db and friends fail this everywhere +#WARNINGS += -Wconversion +WARNINGS += -Wimplicit-fallthrough +WARNINGS += -Werror=format-security +WARNINGS += -U_FORTIFY_SOURCE +WARNINGS += -D_FORTIFY_SOURCE=2 # debian defaults to 2 +WARNINGS += -D_GLIBCXX_ASSERTIONS +#WARNINGS += -fstrict-flex-arrays=3 # not in gcc 12? +WARNINGS += -fstack-clash-protection +WARNINGS += -fstack-protector-strong +WARNINGS += -Wl,-z,nodlopen +WARNINGS += -Wl,-z,noexecstack +WARNINGS += -Wl,-z,relro +WARNINGS += -Wl,-z,now +WARNINGS += -Wl,--as-needed +WARNINGS += -Wl,--no-copy-dt-needed-entries + +# OpenSSF gcc recommendations +WARNINGS += -Wtrampolines + +# OpenSSF per-arch recommendations + extra assertions +WARNINGS += @arch_cflags@ -D_LIBCXX_ENABLE_ASSERTIONS + +# OpenSSF for production code +WARNINGS += -fno-delete-null-pointer-checks +WARNINGS += -fno-strict-overflow +#WARNINGS += -fno-strict-aliasing # elsewhere +#WARNINGS += -ftrivial-auto-var-init=zero # elsewhere + +# OpenSSF for obsolete C constructs +WARNINGS += -Werror=implicit +WARNINGS += -Werror=incompatible-pointer-types +WARNINGS += -Werror=int-conversion + +# OpenSSF for multithreaded code +WARNINGS += -fexceptions + +# chainguard.dev recommendations +WARNINGS += -fno-omit-frame-pointer +WARNINGS += -mno-omit-leaf-frame-pointer +#WARNINGS += -fhardened # not on gcc 12 + # Comment out for release builds CFLAGS += $(WARNINGS) BUILD_CFLAGS += $(WARNINGS) diff --git a/m4/package_sanitizer.m4 b/m4/package_sanitizer.m4 index 6488f7ebce2f50..c20e5156907ab2 100644 --- a/m4/package_sanitizer.m4 +++ b/m4/package_sanitizer.m4 @@ -71,3 +71,17 @@ AC_DEFUN([AC_HAVE_TRIVIAL_AUTO_VAR_INIT], CFLAGS="${OLD_CFLAGS}" AC_SUBST(autovar_init_cflags) ]) + +# Add arch-specific gcc flags if they exist +AC_DEFUN([AC_HAVE_X86_CFLAGS], + [ AC_MSG_CHECKING([if C compiler supports various x86 CFLAGS]) + OLD_CFLAGS="$CFLAGS" + TEST_CFLAGS="-fcf-protection=full -mshstk" + CFLAGS="$CFLAGS $TEST_CFLAGS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [arch_cflags="$TEST_CFLAGS $arch_cflags"], + [AC_MSG_RESULT([no])]) + CFLAGS="${OLD_CFLAGS}" + AC_SUBST(arch_cflags) + ]) ^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-15 14:51 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-15 14:46 [PATCH 1/2] xfsprogs: turn on more warnings for the filesystem code we modify most Darrick J. Wong 2026-10-15 14:51 ` [PATCH 2/2] xfsprogs: even more debug whining Darrick J. Wong
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox