From c1f5acd4f49a390ba536af0104835be37cba19ca Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 3 Jul 2014 20:35:42 -0700 Subject: [PATCH] Robustify Linux kernel headers configure checks --- ChangeLog | 5 ++ sysdeps/unix/sysv/linux/configure | 169 +++++------------------------------ sysdeps/unix/sysv/linux/configure.ac | 16 ++-- 3 files changed, 37 insertions(+), 153 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22b8f23..996b346 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2014-07-03 Roland McGrath + * sysdeps/unix/sysv/linux/configure.ac: Use AC_TRY_COMPILE rather than + AC_EGREP_CPP for kernel header checks, so they only succeed if + including actually works right. + * sysdeps/unix/sysv/linux/configure: Regenerated. + * sysdeps/s390/nptl/tls.h (THREAD_SET_POINTER_GUARD): Refer to the value so it's not diagnosed as unused. diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure index 57fda6c..e8f83fb 100644 --- a/sysdeps/unix/sysv/linux/configure +++ b/sysdeps/unix/sysv/linux/configure @@ -37,137 +37,6 @@ if test -n "$sysheaders"; then CPPFLAGS="$CPPFLAGS $SYSINCLUDES" fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking installed Linux kernel header files" >&5 $as_echo_n "checking installed Linux kernel header files... " >&6; } if ${libc_cv_linux2632+:} false; then : @@ -177,17 +46,22 @@ else /* end confdefs.h. */ #include #if !defined LINUX_VERSION_CODE || LINUX_VERSION_CODE < (2 *65536+ 6 *256+ 32) /* 2.6.32 */ -eat flaming death +# error kernel headers missing or too old #endif +int +main () +{ + + ; + return 0; +} _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "eat flaming death" >/dev/null 2>&1; then : - libc_cv_linux2632='TOO OLD!' -else +if ac_fn_c_try_compile "$LINENO"; then : libc_cv_linux2632='2.6.32 or later' +else + libc_cv_linux2632='missing or too old!' fi -rm -f conftest* - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_linux2632" >&5 $as_echo "$libc_cv_linux2632" >&6; } @@ -231,17 +105,22 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if LINUX_VERSION_CODE < $decnum -eat flaming death +# error kernel headers too old #endif +int +main () +{ + + ; + return 0; +} _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "eat flaming death" >/dev/null 2>&1; then : - libc_minimum_kernel='too old!' -else +if ac_fn_c_try_compile "$LINENO"; then : libc_minimum_kernel=ok +else + libc_minimum_kernel='too old!' fi -rm -f conftest* - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_minimum_kernel" >&5 $as_echo "$libc_minimum_kernel" >&6; } if test "$libc_minimum_kernel" = ok; then diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac index e172ffe..9b09b3f 100644 --- a/sysdeps/unix/sysv/linux/configure.ac +++ b/sysdeps/unix/sysv/linux/configure.ac @@ -8,14 +8,14 @@ if test -n "$sysheaders"; then fi define([libc_cv_linuxVER], [libc_cv_linux]patsubst(LIBC_LINUX_VERSION,[\.]))dnl AC_CACHE_CHECK(installed Linux kernel header files, libc_cv_linuxVER, [dnl -AC_EGREP_CPP([eat flaming death], [#include +AC_TRY_COMPILE([#include #if !defined LINUX_VERSION_CODE || LINUX_VERSION_CODE < ]dnl patsubst(LIBC_LINUX_VERSION,[^\([^.]*\)\.\([^.]*\)\.\([^.]*\)$],dnl [ (\1 *65536+ \2 *256+ \3) /* \1.\2.\3 */])[ -eat flaming death -#endif], - libc_cv_linuxVER='TOO OLD!', - libc_cv_linuxVER='LIBC_LINUX_VERSION or later')]) +# error kernel headers missing or too old +#endif], [], + [libc_cv_linuxVER='LIBC_LINUX_VERSION or later'], + [libc_cv_linuxVER='missing or too old!'])]) if test "$libc_cv_linuxVER" != 'LIBC_LINUX_VERSION or later'; then AC_MSG_ERROR([GNU libc requires kernel header files from Linux LIBC_LINUX_VERSION or later to be installed before configuring. @@ -52,10 +52,10 @@ changequote(,)dnl decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`; abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`; changequote([,])dnl -AC_EGREP_CPP([eat flaming death], [#include +AC_TRY_COMPILE([#include #if LINUX_VERSION_CODE < $decnum -eat flaming death -#endif], libc_minimum_kernel='too old!', libc_minimum_kernel=ok) +# error kernel headers too old +#endif], [], [libc_minimum_kernel=ok], [libc_minimum_kernel='too old!']) AC_MSG_RESULT($libc_minimum_kernel) if test "$libc_minimum_kernel" = ok; then AC_DEFINE_UNQUOTED(__LINUX_KERNEL_VERSION, $decnum) -- 2.7.4