diff --git a/aclocal.m4 b/aclocal.m4 index 88ed3a6b71..fb4c1ef1c4 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -326,6 +326,16 @@ CC="$TEST_CC" CC="$saved_CC" ]) +dnl Run a test with TEST_CXX. +dnl LIBC_CHECK_TEST_CXX([commands]) +AC_DEFUN([LIBC_CHECK_TEST_CXX], +[ +saved_CXX="$CXX" +CXX="$TEST_CXX" +[$1] +CXX="$saved_CXX" +]) + dnl Test a CC and TEST_CC compiler option or options with an empty input dnl file. dnl LIBC_TRY_CC_AND_TEST_CC_OPTION([message], [options], @@ -398,3 +408,42 @@ else ) fi ]) + +dnl Test a TEST_CC compiler option or options with an input file. +dnl LIBC_TRY_TEST_CC_COMMAND([message], [code], [options], +dnl [TEST_CC-cache-id], [TEST_CC-action-if-true], [TEST_CC-action-if-false]) +AC_DEFUN([LIBC_TRY_TEST_CC_COMMAND], +[ +cat > conftest.c <&AS_MESSAGE_LOG_FD]) + then + [$5] + else + [$6] + fi]) +) +rm -f conftest*]) + +dnl Test a TEST_CXX compiler option or options with an input file. +dnl LIBC_TRY_TEST_CXX_COMMAND([message], [code], [options], +dnl [TEST_CXX-cache-id], [TEST_CXX-action-if-true], +dnl [TEST_CXX-action-if-false]) +AC_DEFUN([LIBC_TRY_TEST_CXX_COMMAND], +[ +cat > conftest.cc <&AS_MESSAGE_LOG_FD]) + then + [$5] + else + [$6] + fi]) +) +rm -f conftest*]) diff --git a/configure b/configure index 2c2b19f9a6..e9c18316fe 100755 --- a/configure +++ b/configure @@ -5993,6 +5993,82 @@ fi printf "%s\n" "$libc_cv_with_fp" >&6; } +conftest_code=" +#ifndef __clang__ +#error Not Clang! +#endif +" + + +cat > conftest.c <&5 +printf %s "checking for clang in testing... " >&6; } +if test ${libc_cv_test_clang+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c -o conftest 1>&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_test_clang=yes + else + libc_cv_test_clang=no + fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_clang" >&5 +printf "%s\n" "$libc_cv_test_clang" >&6; } + +CC="$saved_CC" + +rm -f conftest* +config_vars="$config_vars +have-test-clang = $libc_cv_test_clang" + + +cat > conftest.cc <&5 +printf %s "checking for clang++ in testing... " >&6; } +if test ${libc_cv_test_clangxx+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc -o conftest 1>&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_test_clangxx=yes + else + libc_cv_test_clangxx=no + fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_clangxx" >&5 +printf "%s\n" "$libc_cv_test_clangxx" >&6; } + +CXX="$saved_CXX" + +rm -f conftest* +config_vars="$config_vars +have-test-clangxx = $libc_cv_test_clangxx" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -fstack-protector" >&5 printf %s "checking for -fstack-protector... " >&6; } if test ${libc_cv_ssp+y} diff --git a/configure.ac b/configure.ac index 1de79bd729..85c92e5083 100644 --- a/configure.ac +++ b/configure.ac @@ -641,6 +641,30 @@ fi rm -f conftest*]) AC_SUBST(libc_cv_with_fp) +conftest_code=" +#ifndef __clang__ +#error Not Clang! +#endif +" + +dnl Check if clang is used to test glibc. +LIBC_TRY_TEST_CC_COMMAND([for clang], + [$conftest_code], + [-c], + libc_cv_test_clang, + [libc_cv_test_clang=yes], [libc_cv_test_clang=no], +) +LIBC_CONFIG_VAR([have-test-clang], [$libc_cv_test_clang]) + +dnl Check if clang++ is used to test glibc. +LIBC_TRY_TEST_CXX_COMMAND([for clang++], + [$conftest_code], + [-c], + libc_cv_test_clangxx, + [libc_cv_test_clangxx=yes], [libc_cv_test_clangxx=no], +) +LIBC_CONFIG_VAR([have-test-clangxx], [$libc_cv_test_clangxx]) + AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector], [libc_cv_ssp=yes],