[PATCH] Don't use -finput-charset=ascii with clang nor clang++

H.J. Lu hjl.tools@gmail.com
Fri Dec 20 21:10:08 GMT 2024


On Fri, Dec 20, 2024 at 11:29 AM Sam James <sam@gentoo.org> wrote:
>
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
> > Since clang and clang++ don't support -finput-charset=ascii, use
> > -finput-charset=ascii in check-installed-headers.sh only if clang
> > and clang++ aren't used.
> >
> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> > ---
> >  Makeconfig                         | 5 +++++
> >  Makefile                           | 6 ++++--
> >  Rules                              | 6 ++++--
> >  scripts/check-installed-headers.sh | 3 +--
> >  4 files changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git a/Makeconfig b/Makeconfig
> > index d33369eaaf..04c43e80f7 100644
> > --- a/Makeconfig
> > +++ b/Makeconfig
> > @@ -66,6 +66,11 @@ export sysdep_dir := $(sysdep_dir)
> >  # Get the values defined by options to `configure'.
> >  include $(common-objpfx)config.make
> >
> > +# Since clang and clang++ don't support -finput-charset=ascii, use it
> > +# only if clang and clang++ aren't used.
> > +cflags-finput-charset = $(if $(filter no,$(have-test-clang)),-finput-charset=ascii)
> > +cxxflags-finput-charset = $(if $(filter no,$(have-test-clangxx)),-finput-charset=ascii)
> > +
> >  # What flags to give to sources which call user provided callbacks
> >  uses-callbacks = -fexceptions
> >
> > diff --git a/Makefile b/Makefile
> > index c84f266ce7..083b1475eb 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) $(cflags-finput-charset) $(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) $(cxxflags-finput-charset) \
> > +          $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
> >         $(headers) > $@; \
> >       $(evaluate-test)
> >  endif # $(CXX)
> > diff --git a/Rules b/Rules
> > index 713c225d2e..d36dde56e2 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) $(cflags-finput-charset) $(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) $(cxxflags-finput-charset) \
> > +          $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
> >         $(headers) > $@; \
> >       $(evaluate-test)
> >  endif # $(CXX)
> > 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
>
> Where does the flag go here?

It is in $cc_cmd now.  I sent out the v2 patch to check if compiler
supports -finput-charset=ascii instead.

>
> >                  then :
> >                  else failed=1
> >                  fi



-- 
H.J.


More information about the Libc-alpha mailing list