summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-03-25 13:58:03 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-02-09 16:36:05 -0300
commit28396b7ee87df0b7673af133544e90144e853425 (patch)
tree30722fe5101459df13f5efd4b9c704074e960bbb
parent1a9ed641ae9bdbfac4bedec7b35d332dc94d31c3 (diff)
downloadglibc-28396b7ee87df0b7673af133544e90144e853425.tar.gz
Only use -finput-charset=ascii iff compiler supports it
-rw-r--r--Makefile2
-rw-r--r--Rules2
-rwxr-xr-xconfigure22
-rw-r--r--configure.ac10
-rw-r--r--scripts/check-installed-headers.sh12
5 files changed, 45 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 224c792185..d97979f30b 100644
--- a/Makefile
+++ b/Makefile
@@ -544,6 +544,7 @@ $(objpfx)check-installed-headers-c.out: \
scripts/check-installed-headers.sh $(headers)
$(SHELL) $(..)scripts/check-installed-headers.sh c \
"$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
+ $(config-cflags-charset-ascii) \
$(headers) > $@; \
$(evaluate-test)
@@ -554,6 +555,7 @@ $(objpfx)check-installed-headers-cxx.out: \
scripts/check-installed-headers.sh $(headers)
$(SHELL) $(..)scripts/check-installed-headers.sh c++ \
"$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
+ $(config-cflags-charset-ascii) \
$(headers) > $@; \
$(evaluate-test)
endif # $(CXX)
diff --git a/Rules b/Rules
index fdff415fdc..29e556bfe4 100644
--- a/Rules
+++ b/Rules
@@ -90,6 +90,7 @@ $(objpfx)check-installed-headers-c.out: \
$(..)scripts/check-installed-headers.sh $(headers)
$(SHELL) $(..)scripts/check-installed-headers.sh c \
"$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
+ $(config-cflags-charset-ascii) \
$(headers) > $@; \
$(evaluate-test)
@@ -102,6 +103,7 @@ $(objpfx)check-installed-headers-cxx.out: \
$(..)scripts/check-installed-headers.sh $(headers)
$(SHELL) $(..)scripts/check-installed-headers.sh c++ \
"$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
+ $(config-cflags-charset-ascii) \
$(headers) > $@; \
$(evaluate-test)
endif # $(CXX)
diff --git a/configure b/configure
index b9ba9958c2..6c5ee947ea 100755
--- a/configure
+++ b/configure
@@ -6362,6 +6362,28 @@ $as_echo "$libc_cv_cc_trampoline" >&6; }
config_vars="$config_vars
have-cc-trampoline = $libc_cv_cc_trampoline"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -finput-charset=ascii" >&5
+$as_echo_n "checking if $CC supports -finput-charset=ascii... " >&6; }
+if ${libc_cv_cc_charset_ascii+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if { ac_try='${CC-cc} -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=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ libc_cv_cc_charset_ascii=yes
+else
+ libc_cv_cc_charset_ascii=no
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_charset_ascii" >&5
+$as_echo "$libc_cv_cc_charset_ascii" >&6; }
+config_vars="$config_vars
+config-cflags-charset-ascii = $libc_cv_cc_charset_ascii"
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
$as_echo_n "checking for libgd... " >&6; }
if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 6f97d8d4b0..68d80cb591 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1616,6 +1616,16 @@ rm -f conftest*])
LIBC_CONFIG_VAR([have-cc-trampoline],
[$libc_cv_cc_trampoline])
+dnl Check if -finput-charset accepts ascii
+AC_CACHE_CHECK([if $CC supports -finput-charset=ascii],
+ libc_cv_cc_charset_ascii, [dnl
+LIBC_TRY_CC_OPTION([-Werror -finput-charset=ascii],
+ [libc_cv_cc_charset_ascii=yes],
+ [libc_cv_cc_charset_ascii=no])
+])
+LIBC_CONFIG_VAR([config-cflags-charset-ascii],
+ [$libc_cv_cc_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 5a50a491ca..7efb4ba980 100644
--- a/scripts/check-installed-headers.sh
+++ b/scripts/check-installed-headers.sh
@@ -29,8 +29,8 @@ cxx_modes="-std=c++98 -std=gnu++98 -std=c++11 -std=gnu++11"
# These are probably the most commonly used three.
lib_modes="-D_DEFAULT_SOURCE=1 -D_GNU_SOURCE=1 -D_XOPEN_SOURCE=700"
-if [ $# -lt 3 ]; then
- echo "usage: $0 c|c++ \"compile command\" header header header..." >&2
+if [ $# -lt 4 ]; then
+ echo "usage: $0 c|c++ \"compile command\" \"yes|no\" header header header..." >&2
exit 2
fi
case "$1" in
@@ -49,6 +49,12 @@ esac
shift
cc_cmd="$1"
shift
+if [ "$1" = "yes" ]; then
+ finputcharset="-finput-charset=ascii"
+else
+ finputcharset=""
+fi
+shift
trap "rm -f '$cih_test_c'" 0
failed=0
@@ -118,7 +124,7 @@ $expanded_lib_mode
#include <$header>
int avoid_empty_translation_unit;
EOF
- if $cc_cmd -finput-charset=ascii -fsyntax-only $lang_mode \
+ if $cc_cmd $finputcharset -fsyntax-only $lang_mode \
"$cih_test_c" 2>&1
then :
else failed=1