From c9ff5c53c319f963cac34a41c86cd43edf902459 Mon Sep 17 00:00:00 2001 From: Adrian Ratiu Date: Mon, 30 Aug 2021 18:43:13 +0300 Subject: [PATCH] configure.ac: rework gnu99 ext check to allow clang It is true that Clang does not support all gnu99 extensions [1], but not all of them are used in the codebase and over time there have been code cleanup efforts to improve Clang support. For example after commit 779c57ea ("readelf: Pull advance_pc() in file scope") there are no more nested function declarations and elfutils now builds fine with Clang. So in the interest of enabling Clang builds we remove the only remaining blocker: the configure checks for nested functions and variable length arrays which are also unused. Considering mixed decls and code is also part of c99 standard, the entire check becomes redundant and we can just replace AC_PROG_CC -> AC_PROG_CC_C99. Upstream-Status: Backport [master commit 6eb991a9] [1] https://sourceware.org/bugzilla/show_bug.cgi?id=24964 [Adrian: backported to v0.185] Signed-off-by: Adrian Ratiu --- configure | 48 ------------------------------------------------ configure.ac | 35 +---------------------------------- 2 files changed, 1 insertion(+), 82 deletions(-) diff --git a/configure b/configure index 4ea75ee..22bda6c 100755 --- a/configure +++ b/configure @@ -5162,54 +5162,6 @@ else fi -# We use -std=gnu99 but have explicit checks for some language constructs -# and GNU extensions since some compilers claim GNU99 support, but don't -# really support all language extensions. In particular we need -# Mixed Declarations and Code -# https://gcc.gnu.org/onlinedocs/gcc/Mixed-Declarations.html -# Nested Functions -# https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html -# Arrays of Variable Length -# https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc with GNU99 support" >&5 -$as_echo_n "checking for gcc with GNU99 support... " >&6; } -if ${ac_cv_c99+:} false; then : - $as_echo_n "(cached) " >&6 -else - old_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -std=gnu99" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo (int a) -{ - for (int i = 0; i < a; ++i) if (i % 4) break; int s = a; return s; -} - -double bar (double a, double b) -{ - double square (double z) { return z * z; } - return square (a) + square (b); -} - -void baz (int n) -{ - struct S { int x[n]; }; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c99=yes -else - ac_cv_c99=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -CFLAGS="$old_CFLAGS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c99" >&5 -$as_echo "$ac_cv_c99" >&6; } -if test "x$ac_cv_c99" != xyes; then : - as_fn_error $? "gcc with GNU99 support required" "$LINENO" 5 -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc supports __attribute__((visibility()))" >&5 $as_echo_n "checking whether gcc supports __attribute__((visibility()))... " >&6; } if ${ac_cv_visibility+:} false; then : diff --git a/configure.ac b/configure.ac index b348a71..6298547 100644 --- a/configure.ac +++ b/configure.ac @@ -87,7 +87,7 @@ AS_IF([test "$use_locks" = yes], AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.]) -AC_PROG_CC +AC_PROG_CC_C99 AC_PROG_RANLIB AC_PROG_YACC AM_PROG_LEX @@ -96,39 +96,6 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AC_CHECK_TOOL([READELF], [readelf]) AC_CHECK_TOOL([NM], [nm]) -# We use -std=gnu99 but have explicit checks for some language constructs -# and GNU extensions since some compilers claim GNU99 support, but don't -# really support all language extensions. In particular we need -# Mixed Declarations and Code -# https://gcc.gnu.org/onlinedocs/gcc/Mixed-Declarations.html -# Nested Functions -# https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html -# Arrays of Variable Length -# https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html -AC_CACHE_CHECK([for gcc with GNU99 support], ac_cv_c99, [dnl -old_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -std=gnu99" -AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl -int foo (int a) -{ - for (int i = 0; i < a; ++i) if (i % 4) break; int s = a; return s; -} - -double bar (double a, double b) -{ - double square (double z) { return z * z; } - return square (a) + square (b); -} - -void baz (int n) -{ - struct S { int x[[n]]; }; -}])], - ac_cv_c99=yes, ac_cv_c99=no) -CFLAGS="$old_CFLAGS"]) -AS_IF([test "x$ac_cv_c99" != xyes], - AC_MSG_ERROR([gcc with GNU99 support required])) - AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))], ac_cv_visibility, [dnl save_CFLAGS="$CFLAGS" -- 2.33.0