From 18e12e95ab8ecc4123df6c0c06a3dee636f7e086 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 15 Feb 2023 01:51:20 +0100 Subject: [PATCH] btrfs-progs: build: fix detection of std=gnu11 build Commit 0d5767e66495 ("btrfs-progs: build: use -std=gnu11") was supposed to set C level to gnu11 to match kernel but it was done only in the C=1 (checker) branch. The std used was still gnu90 that can be verified by running with V=1. Set the std option to gnu11 unconditionally and delete the m4 macros that were detecting support on older gcc (4.5). The reference build on lowest supported distro (Centos 7) compiles fine. Signed-off-by: David Sterba --- Makefile | 5 ++--- Makefile.inc.in | 1 - configure.ac | 4 +++- m4/ax_gcc_version.m4 | 37 ------------------------------------- m4/btrfs_detect_cstd.m4 | 20 -------------------- 5 files changed, 5 insertions(+), 62 deletions(-) delete mode 100644 m4/ax_gcc_version.m4 delete mode 100644 m4/btrfs_detect_cstd.m4 diff --git a/Makefile b/Makefile index 6ca3aad4..fad3b2a6 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,7 @@ ENABLE_WARNING_FLAGS := $(call cc-option, -Wimplicit-fallthrough) # Common build flags CFLAGS = $(SUBST_CFLAGS) \ - $(CSTD) \ + -std=gnu11 \ -include config.h \ -DBTRFS_FLAT_INCLUDES \ -D_XOPEN_SOURCE=700 \ @@ -107,7 +107,7 @@ CFLAGS = $(SUBST_CFLAGS) \ $(EXTRA_CFLAGS) LIBBTRFSUTIL_CFLAGS = $(SUBST_CFLAGS) \ - $(CSTD) \ + -std=gnu11 \ -D_GNU_SOURCE \ -fPIC \ -fvisibility=hidden \ @@ -415,7 +415,6 @@ ifdef C grep -v __SIZE_TYPE__ > $(check_defs)) check = $(CHECKER) check_echo = echo - CSTD = -std=gnu11 else check = true check_echo = true diff --git a/Makefile.inc.in b/Makefile.inc.in index ec06efe2..213e1a98 100644 --- a/Makefile.inc.in +++ b/Makefile.inc.in @@ -4,7 +4,6 @@ export CC = @CC@ -CSTD = @BTRFS_CSTD_FLAGS@ LN_S = @LN_S@ AR = @AR@ RM = @RM@ diff --git a/configure.ac b/configure.ac index ff796bd5..3d482f23 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,6 @@ AC_CONFIG_SRCDIR([btrfs.c]) AC_PREFIX_DEFAULT([/usr/local]) AC_PROG_CC -BTRFS_DETECT_CSTD AC_CANONICAL_HOST AC_C_CONST AC_C_VOLATILE @@ -48,6 +47,9 @@ AX_CHECK_COMPILE_FLAG([-msha], [HAVE_CFLAG_msha=1], [HAVE_CFLAG_msha=0]) AC_SUBST([HAVE_CFLAG_msha]) AC_DEFINE_UNQUOTED([HAVE_CFLAG_msha], [$HAVE_CFLAG_msha], [Compiler supports -msha]) +AX_CHECK_COMPILE_FLAG([-std=gnu11], [], + [AC_MSG_ERROR([std=gnu11 compiler required])]) + AC_SYS_LARGEFILE AC_PROG_INSTALL diff --git a/m4/ax_gcc_version.m4 b/m4/ax_gcc_version.m4 deleted file mode 100644 index ab100265..00000000 --- a/m4/ax_gcc_version.m4 +++ /dev/null @@ -1,37 +0,0 @@ -dnl @synopsis AX_GCC_VERSION(MAJOR, MINOR, PATCHLEVEL, [ACTION-SUCCESS], [ACTION-FAILURE]) -dnl @summary check whether gcc is at least version MAJOR.MINOR.PATCHLEVEL -dnl @category InstalledPackages -dnl -dnl Check whether we are using gcc and, if so, whether its version -dnl is at least MAJOR.MINOR.PATCHLEVEL -dnl -dnl ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -dnl success/failure. -dnl -dnl @version 2005-05-30 -dnl @license GPLWithACException -dnl @author Steven G. Johnson and Matteo Frigo. -AC_DEFUN([AX_GCC_VERSION], -[ -AC_REQUIRE([AC_PROG_CC]) -AC_CACHE_CHECK(whether we are using gcc $1.$2.$3 or later, ax_cv_gcc_$1_$2_$3, -[ -ax_cv_gcc_$1_$2_$3=no -if test "$GCC" = "yes"; then -dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp. -AC_EGREP_CPP(yes, [ -#ifdef __GNUC__ -# if (__GNUC__ > $1) || (__GNUC__ == $1 && __GNUC_MINOR__ > $2) \ - || (__GNUC__ == $1 && __GNUC_MINOR__ == $2 && __GNUC_PATCHLEVEL__ >= $3) - yes; -# endif -#endif -], [ax_cv_gcc_$1_$2_$3=yes]) -fi -]) -if test "$ax_cv_gcc_$1_$2_$3" = yes; then - m4_default([$4], :) -else - m4_default([$5], :) -fi -]) diff --git a/m4/btrfs_detect_cstd.m4 b/m4/btrfs_detect_cstd.m4 deleted file mode 100644 index f0c45d97..00000000 --- a/m4/btrfs_detect_cstd.m4 +++ /dev/null @@ -1,20 +0,0 @@ -dnl We prefer -std=gnu90 but gcc versions prior to 4.5.0 don't support -dnl it. AX_CHECK_COMPILE_FLAG is the right way to determine whether a -dnl particular version of gcc supports a flag, but it requires autoconf -dnl 2.64. Since (for now) we still want to support older releases -dnl that ship with autoconf 2.63, we the also-deprecated AX_GCC_VERSION -dnl macro there. -AC_DEFUN([BTRFS_DETECT_CSTD], -[ - m4_version_prereq([2.64], [ - AX_CHECK_COMPILE_FLAG([-std=gnu90], - [BTRFS_CSTD_FLAGS=-std=gnu90], - [BTRFS_CSTD_FLAGS=-std=gnu89]) - ], [ - AX_GCC_VERSION([4], [5], [0], - [BTRFS_CSTD_FLAGS=-std=gnu90], - [BTRFS_CSTD_FLAGS=-std=gnu89]) - ]) - AC_SUBST([BTRFS_CSTD_FLAGS]) -]) dnl BTRFS_DETECT_CSTD -