From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1521) id 883793858430; Thu, 24 Feb 2022 02:56:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 883793858430 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Frysinger To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] newlib: libm: workaround ar duplicate member behavior X-Act-Checkin: newlib-cygwin X-Git-Author: Mike Frysinger X-Git-Refname: refs/heads/master X-Git-Oldrev: 8d758283785042589e95c93d7899cecf28ef00ea X-Git-Newrev: 5ad394510bb36aaebd5bb054a5bf4730f666947b Message-Id: <20220224025622.883793858430@sourceware.org> Date: Thu, 24 Feb 2022 02:56:22 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Feb 2022 02:56:22 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D5ad394510bb= 36aaebd5bb054a5bf4730f666947b commit 5ad394510bb36aaebd5bb054a5bf4730f666947b Author: Mike Frysinger Date: Mon Feb 21 15:42:18 2022 -0500 newlib: libm: workaround ar duplicate member behavior =20 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. Diff: --- newlib/Makefile.am | 28 ++++++++++++++++++++++++++++ newlib/Makefile.in | 24 +++++++++++++++++++----- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/newlib/Makefile.am b/newlib/Makefile.am index 80256952d..1a5123f0a 100644 --- a/newlib/Makefile.am +++ b/newlib/Makefile.am @@ -85,6 +85,25 @@ toollib_DATA =3D $(CRT0) $(CRT1) =20 CLEANFILES +=3D libg.a =20 +## GNU ar has undocumented behavior when specifying the same name multiple= times +## in a single invocation, so we have to dedupe ourselves. The algorithm = here: +## - Generates the set of unique objects based on the basename. +## - Favors objects later in the list (since machine objects come last). +## - Outputs object list in same order as input for reproducibility. +## https://sourceware.org/PR28917 +AWK_UNIQUE_OBJS =3D $(AWK) '{ \ + for (i =3D NF; i > 0; --i) { \ + split($$i, parts, "/"); \ + name =3D parts[length(parts)]; \ + if (!(name in seen)) { \ + objs[i] =3D $$i; \ + seen[name] =3D 1; \ + } \ + } \ + for (i in objs) \ + print objs[i]; \ +}' + # The functions ldexp, frexp and modf are traditionally supplied in # both libc.a and libm.a. We build them in libm.a and copy them over, # along with some required supporting routines. @@ -122,8 +141,17 @@ libm_a_SOURCES =3D libm_a_CFLAGS =3D $(AM_CFLAGS) $(libm_a_CFLAGS_$(subst /,_,$(@D))) $(libm_= a_CFLAGS_$(subst /,_,$(@D)_$( 0; --i) { \ + split($$i, parts, "/"); \ + name =3D parts[length(parts)]; \ + if (!(name in seen)) { \ + objs[i] =3D $$i; \ + seen[name] =3D 1; \ + } \ + } \ + for (i in objs) \ + print objs[i]; \ +}' + =20 # The functions ldexp, frexp and modf are traditionally supplied in # both libc.a and libm.a. We build them in libm.a and copy them over, @@ -3248,11 +3261,6 @@ libm/machine/x86_64/libm_a-fetestexcept.$(OBJEXT): \ libm/machine/x86_64/libm_a-feupdateenv.$(OBJEXT): \ libm/machine/x86_64/$(am__dirstamp) =20 -libm.a: $(libm_a_OBJECTS) $(libm_a_DEPENDENCIES) $(EXTRA_libm_a_DEPENDENCI= ES)=20 - $(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 +8658,12 @@ 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 =20 +libm.a: $(libm_a_OBJECTS) $(libm_a_DEPENDENCIES) + $(AM_V_at)rm -f $@ + $(AM_V_AR)objs=3D`echo $(libm_a_OBJECTS) | $(AWK_UNIQUE_OBJS)` || exit $$= ?; \ + $(AR) $(ARFLAGS) $@ $$objs + $(AM_V_at)$(RANLIB) $@ + @HAVE_MULTISUBDIR_TRUE@$(BUILD_MULTISUBDIR): @HAVE_MULTISUBDIR_TRUE@ $(MKDIR_P) $@