[PATCH 06/39] Remove Clang /usr/include/tgmath.h dependency

H.J. Lu hjl.tools@gmail.com
Sun Dec 22 04:50:22 GMT 2024


On Sun, Dec 22, 2024 at 10:45 AM Sam James <sam@gentoo.org> wrote:
>
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
> > Remove the /usr/include/tgmath.h dependency generated by Clang even though
> > Clang never reads /usr/include/tgmath.h.
> >
> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> > ---
>
> I think this is a bit gross but that rule is already gross, so OK.
>
> Please verify that diffing the depfile really only removes undesirable
> parts. If you have, then:

/usr/include/tgmath.h only shows up in .dt files:

./math/bug-tgmath1.o.dt:
../sysdeps/ieee754/ldbl-96/bits/iscanonical.h /usr/include/tgmath.h \
./math/bug-tgmath1.o.dt:/usr/include/tgmath.h:
./math/test-tgmath-int.o.dt:
/usr/bin/../lib/clang/19/include/tgmath.h /usr/include/tgmath.h \
./math/test-tgmath-int.o.dt:/usr/include/tgmath.h:
./math/test-tgmath-ret.o.dt:
/usr/bin/../lib/clang/19/include/tgmath.h /usr/include/tgmath.h \
./math/test-tgmath-ret.o.dt:/usr/include/tgmath.h:
./math/test-tgmath.o.dt:  /usr/bin/../lib/clang/19/include/tgmath.h
/usr/include/tgmath.h \
./math/test-tgmath.o.dt:/usr/include/tgmath.h:
./math/test-tgmath2.o.dt:  /usr/bin/../lib/clang/19/include/tgmath.h
/usr/include/tgmath.h \
./math/test-tgmath2.o.dt:/usr/include/tgmath.h:

and my patch will remove them when .dt file is converted to .d file:

ifndef subdir
# If a makefile needs to do something conditional on something that
# can only be figured out from headers, write a FOO.make.c input
# file that uses cpp constructs and contains @@@ LINE @@@ for each LINE
# to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
#
# We only generate these in the top-level makefile, to avoid any weirdness
# from subdir-specific makefile tweaks creeping in on an update.
$(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
        rm -f $@T $@.dT
        (echo '# Generated from $*.make.c by Makerules.'; \
         $(CC) $(CFLAGS) $(CPPFLAGS) -E -DASSEMBLER $< \
               -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
         | sed -n '/@@@/{s/@@@[  ]*\(.*\)@@@/\1/;s/[     ]*$$//p;}'; \
         echo 'common-generated += $(@F)'; \
         sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
         rm -f $@.dT) > $@T
        mv -f $@T $@
endif

> Reviewed-by: Sam James <sam@gentoo.org>

I am checking it in.

> >  Makerules | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/Makerules b/Makerules
> > index 275110dda8..c8b54f7d9a 100644
> > --- a/Makerules
> > +++ b/Makerules
> > @@ -469,9 +469,13 @@ S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
> >
> >  ifneq (,$(objpfx))
> >  # Continuation lines here are dangerous because they introduce spaces!
> > +# Also remove the /usr/include/tgmath.h dependency generated by Clang
> > +# even though Clang never reads /usr/include/tgmath.h.
> >  define sed-remove-objpfx
> >  -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
> > --e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
> > +-e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g' \
> > +-e 's@/usr/include/tgmath.h:@@' \
> > +-e 's@ /usr/include/tgmath.h@@'
> >  endef
> >  endif
> >



-- 
H.J.


More information about the Libc-alpha mailing list