Re: [PATCH] newlib: libm: workaround ar duplicate member behavior
Joel Sherrill <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CAF9ehCUdDQk20r_6EcPkUGfMxECun=qZo5fpxA5Q5W=iRUe36A@mail.gmail.com> |
Could this be de-duped with the gnu make sort command? That would avoid the copy. Alternatively, I see some awk one liners on the web to uniq the set. Or just invoke uniq. --joel On Mon, Feb 21, 2022, 2:43 PM Mike Frysinger <[email protected]> wrote: > GNU ar has undocumented behavior where it doesn't dedupe its inputs if > they're all on the same command line, so we have to dedupe ourselves. > --- > newlib/Makefile.am | 16 ++++++++++++++++ > newlib/Makefile.in | 15 ++++++++++----- > 2 files changed, 26 insertions(+), 5 deletions(-) > > diff --git a/newlib/Makefile.am b/newlib/Makefile.am > index 80256952da3d..5bbe266cc4d5 100644 > --- a/newlib/Makefile.am > +++ b/newlib/Makefile.am > @@ -124,6 +124,22 @@ libm_a_CCASFLAGS = $(AM_CCASFLAGS) > $(libm_a_CCASFLAGS_$(subst /,_,$(@D))) $(libm > libm_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/libm/common > $(libm_a_CPPFLAGS_$(subst /,_,$(@D))) $(libm_a_CPPFLAGS_$(subst > /,_,$(@D)_$(<F))) > $(libm_a_OBJECTS): stmp-targ-include > > +## GNU ar has undocumented behavior when specifying the same name > multiple times > +## in a single invocation, so we have to dedupe ourselves by copying > objects to > +## a temporary directory. We start with using ln to create fast > hardlinks. If > +## that fails, GNU cp has annoying behavior where you can't copy multiple > files > +## to the same target filename, so have to run cp for each input in a > loop. > +## https://sourceware.org/PR28917 > +libm.a: $(libm_a_OBJECTS) $(libm_a_DEPENDENCIES) > + $(AM_V_at)rm -rf $@ [email protected] && mkdir [email protected] > + $(AM_V_AR)if ! ln $(libm_a_OBJECTS) [email protected]/ 2>/dev/null; then \ > + rm -f [email protected]/*; \ > + for o in $(libm_a_OBJECTS); do cp $$o [email protected]/ || exit $$?; > done; \ > + fi; \ > + $(AR) $(ARFLAGS) $@ [email protected]/*.o > + $(AM_V_at)rm -rf [email protected] > + $(AM_V_at)$(RANLIB) $@ > + > if HAVE_MULTISUBDIR > $(BUILD_MULTISUBDIR): > $(MKDIR_P) $@ > diff --git a/newlib/Makefile.in b/newlib/Makefile.in > index 2b60ef1ca96c..84f3e0cbde37 100644 > --- a/newlib/Makefile.in > +++ b/newlib/Makefile.in > @@ -3248,11 +3248,6 @@ libm/machine/x86_64/libm_a-fetestexcept.$(OBJEXT): > \ > libm/machine/x86_64/libm_a-feupdateenv.$(OBJEXT): \ > libm/machine/x86_64/$(am__dirstamp) > > -libm.a: $(libm_a_OBJECTS) $(libm_a_DEPENDENCIES) > $(EXTRA_libm_a_DEPENDENCIES) > - $(AM_V_at)-rm -f libm.a > - $(AM_V_AR)$(libm_a_AR) libm.a $(libm_a_OBJECTS) $(libm_a_LIBADD) > - $(AM_V_at)$(RANLIB) libm.a > - > mostlyclean-compile: > -rm -f *.$(OBJEXT) > -rm -f libm/common/*.$(OBJEXT) > @@ -8650,6 +8645,16 @@ libg.a: libc.a > $(AM_V_GEN)ln libc.a libg.a >/dev/null 2>/dev/null || cp libc.a > libg.a > $(libm_a_OBJECTS): stmp-targ-include > > +libm.a: $(libm_a_OBJECTS) $(libm_a_DEPENDENCIES) > + $(AM_V_at)rm -rf $@ [email protected] && mkdir [email protected] > + $(AM_V_AR)if ! ln $(libm_a_OBJECTS) [email protected]/ 2>/dev/null; then \ > + rm -f [email protected]/*; \ > + for o in $(libm_a_OBJECTS); do cp $$o [email protected]/ || exit $$?; > done; \ > + fi; \ > + $(AR) $(ARFLAGS) $@ [email protected]/*.o > + $(AM_V_at)rm -rf [email protected] > + $(AM_V_at)$(RANLIB) $@ > + > @HAVE_MULTISUBDIR_TRUE@$(BUILD_MULTISUBDIR): > @HAVE_MULTISUBDIR_TRUE@ $(MKDIR_P) $@ > > -- > 2.34.1 > >