diff --git a/Makefile b/Makefile index c84f266ce7..430a0942eb 100644 --- a/Makefile +++ b/Makefile @@ -546,7 +546,8 @@ libof-check-installed-headers-c := testsuite $(objpfx)check-installed-headers-c.out: \ scripts/check-installed-headers.sh $(headers) $(SHELL) $(..)scripts/check-installed-headers.sh c $(supported-fortify) \ - "$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \ + "$(CC) $(test-config-cflags-finput-charset-ascii) \ + $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \ $(headers) > $@; \ $(evaluate-test) @@ -556,7 +557,8 @@ libof-check-installed-headers-cxx := testsuite $(objpfx)check-installed-headers-cxx.out: \ scripts/check-installed-headers.sh $(headers) $(SHELL) $(..)scripts/check-installed-headers.sh c++ $(supported-fortify) \ - "$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \ + "$(CXX) $(test-config-cxxflags-finput-charset-ascii) \ + $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \ $(headers) > $@; \ $(evaluate-test) endif # $(CXX) diff --git a/Rules b/Rules index 713c225d2e..cd98fcb006 100644 --- a/Rules +++ b/Rules @@ -86,7 +86,8 @@ libof-check-installed-headers-c := testsuite $(objpfx)check-installed-headers-c.out: \ $(..)scripts/check-installed-headers.sh $(headers) $(SHELL) $(..)scripts/check-installed-headers.sh c $(supported-fortify) \ - "$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \ + "$(CC) $(test-config-cflags-finput-charset-ascii) \ + $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \ $(headers) > $@; \ $(evaluate-test) @@ -98,7 +99,8 @@ libof-check-installed-headers-cxx := testsuite $(objpfx)check-installed-headers-cxx.out: \ $(..)scripts/check-installed-headers.sh $(headers) $(SHELL) $(..)scripts/check-installed-headers.sh c++ $(supported-fortify) \ - "$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \ + "$(CXX) $(test-config-cxxflags-finput-charset-ascii) \ + $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \ $(headers) > $@; \ $(evaluate-test) endif # $(CXX) diff --git a/aclocal.m4 b/aclocal.m4 index fb4c1ef1c4..e06366cdb2 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -167,6 +167,12 @@ AC_DEFUN([LIBC_TRY_CC_OPTION], [AS_IF([AC_TRY_COMMAND([${CC-cc} $1 -xc /dev/null -S -o /dev/null])], [$2], [$3])]) +dnl Test a C++ compiler option or options with an empty input file. +dnl LIBC_TRY_CXX_OPTION([options], [action-if-true], [action-if-false]) +AC_DEFUN([LIBC_TRY_CXX_OPTION], +[AS_IF([AC_TRY_COMMAND([${CXX-c++} $1 -xc++ /dev/null -S -o /dev/null])], + [$2], [$3])]) + dnl Find and source sysdeps/*/preconfigure. dnl LIBC_PRECONFIGURE([$srcdir], [for]) AC_DEFUN([LIBC_PRECONFIGURE], [dnl @@ -447,3 +453,26 @@ LIBC_CHECK_TEST_CXX( fi]) ) rm -f conftest*]) + +dnl Test a TEST_CC compiler option or options with an empty input file. +dnl LIBC_TRY_TEST_CC_OPTION([message], [options], +dnl [TEST_CC-cache-id], [TEST_CC-action-if-true], [TEST_CC-action-if-false]) +AC_DEFUN([LIBC_TRY_TEST_CC_OPTION], +[ +LIBC_CHECK_TEST_CC( + AC_CACHE_CHECK([$1 in testing], $3, + [LIBC_TRY_CC_OPTION([$2], [$4], [$5])]) + ) +]) + +dnl Test a TEST_CXX compiler option or options with an empty input file. +dnl LIBC_TRY_TEST_CXX_OPTION([message], [options], +dnl [TEST_CXX-cache-id], [TEST_CXX-action-if-true], +dnl [TEST_CXX-action-if-false]) +AC_DEFUN([LIBC_TRY_TEST_CXX_OPTION], +[ +LIBC_CHECK_TEST_CXX( + AC_CACHE_CHECK([$1 in testing], $3, + [LIBC_TRY_CXX_OPTION([$2], [$4], [$5])]) + ) +]) diff --git a/configure b/configure index e9c18316fe..b899d39717 100755 --- a/configure +++ b/configure @@ -7774,6 +7774,74 @@ config_vars="$config_vars cc-option-wimplicit-fallthrough = $libc_cv_cc_wimplicit_fallthrough" + + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking -finput-charset=ascii in testing" >&5 +printf %s "checking -finput-charset=ascii in testing... " >&6; } +if test ${libc_cv_test_cflags_finput_charset_ascii+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} -c -Werror -finput-charset=ascii -xc /dev/null -S -o /dev/null' + { { 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_cflags_finput_charset_ascii="-finput-charset=ascii" +else case e in #( + e) libc_cv_test_cflags_finput_charset_ascii= + ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cflags_finput_charset_ascii" >&5 +printf "%s\n" "$libc_cv_test_cflags_finput_charset_ascii" >&6; } + +CC="$saved_CC" + + +config_vars="$config_vars +test-config-cflags-finput-charset-ascii = $libc_cv_test_cflags_finput_charset_ascii" + + + +saved_CXX="$CXX" +CXX="$TEST_CXX" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking -finput-charset=ascii in testing" >&5 +printf %s "checking -finput-charset=ascii in testing... " >&6; } +if test ${libc_cv_test_cxxflags_finput_charset_ascii+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CXX-c++} -c -Werror -finput-charset=ascii -xc++ /dev/null -S -o /dev/null' + { { 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_cxxflags_finput_charset_ascii="-finput-charset=ascii" +else case e in #( + e) libc_cv_test_cxxflags_finput_charset_ascii= + ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cxxflags_finput_charset_ascii" >&5 +printf "%s\n" "$libc_cv_test_cxxflags_finput_charset_ascii" >&6; } + +CXX="$saved_CXX" + + +config_vars="$config_vars +test-config-cxxflags-finput-charset-ascii = $libc_cv_test_cxxflags_finput_charset_ascii" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5 printf %s "checking for libgd... " >&6; } if test "$with_gd" != "no"; then diff --git a/configure.ac b/configure.ac index 85c92e5083..6eaf83b8dc 100644 --- a/configure.ac +++ b/configure.ac @@ -1527,6 +1527,26 @@ LIBC_CONFIG_VAR([cc-option-wimplicit-fallthrough], [$libc_cv_cc_wimplicit_fallthrough]) AC_SUBST(libc_cv_test_cc_wimplicit_fallthrough) +dnl Check if TEST_CC supports -finput-charset=ascii. +LIBC_TRY_TEST_CC_OPTION([-finput-charset=ascii], + [-c -Werror -finput-charset=ascii], + libc_cv_test_cflags_finput_charset_ascii, + [libc_cv_test_cflags_finput_charset_ascii="-finput-charset=ascii"], + [libc_cv_test_cflags_finput_charset_ascii=] +) +LIBC_CONFIG_VAR(test-config-cflags-finput-charset-ascii, + $libc_cv_test_cflags_finput_charset_ascii) + +dnl Check if TEST_CXX supports -finput-charset=ascii. +LIBC_TRY_TEST_CXX_OPTION([-finput-charset=ascii], + [-c -Werror -finput-charset=ascii], + libc_cv_test_cxxflags_finput_charset_ascii, + [libc_cv_test_cxxflags_finput_charset_ascii="-finput-charset=ascii"], + [libc_cv_test_cxxflags_finput_charset_ascii=] +) +LIBC_CONFIG_VAR(test-config-cxxflags-finput-charset-ascii, + $libc_cv_test_cxxflags_finput_charset_ascii) + dnl Check whether we have the gd library available. AC_MSG_CHECKING(for libgd) if test "$with_gd" != "no"; then diff --git a/scripts/check-installed-headers.sh b/scripts/check-installed-headers.sh index b8cdcbf858..64cbfda544 100644 --- a/scripts/check-installed-headers.sh +++ b/scripts/check-installed-headers.sh @@ -130,8 +130,7 @@ $expanded_lib_mode #include <$header> int avoid_empty_translation_unit; EOF - if $cc_cmd -finput-charset=ascii -fsyntax-only $lang_mode \ - "$cih_test_c" 2>&1 + if $cc_cmd -fsyntax-only $lang_mode "$cih_test_c" 2>&1 then : else failed=1 fi