btrfs-progs: build: fix detection of std=gnu11 build

Commit 0d5767e664 ("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 <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-02-15 01:51:20 +01:00
parent b473169d2d
commit 18e12e95ab
5 changed files with 5 additions and 62 deletions

View File

@ -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

View File

@ -4,7 +4,6 @@
export
CC = @CC@
CSTD = @BTRFS_CSTD_FLAGS@
LN_S = @LN_S@
AR = @AR@
RM = @RM@

View File

@ -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

View File

@ -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 <stevenj@alum.mit.edu> 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
])

View File

@ -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