Use -finput-charset=ascii only if supported

Check if -finput-charset=ascii is supported before using it in
check-installed-headers.sh.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
This commit is contained in:
H.J. Lu 2024-12-22 08:04:25 +08:00
parent fe925cb045
commit a0704d9fc6
6 changed files with 126 additions and 6 deletions

View File

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

6
Rules
View File

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

29
aclocal.m4 vendored
View File

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

68
configure vendored
View File

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

View File

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

View File

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