From: Harald Nordgren Date: Thu, 04 Jun 2026 07:06:49 GMT Subject: Re: [PATCH] Makefile: drop duplicate %.a from link recipes Message-ID: In-Reply-To: On Thu, Jun 4, 2026 at 2:33 AM Junio C Hamano wrote: > > "Harald Nordgren via GitGitGadget" writes: > > > t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS) > > - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS) > > + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) > > I think the reason why the pattern to use only the .o files among > the prerequisites and then use only the .a files among the same > prerequisites (both filters $^) is used here is to make sure that the > linker sees object files first before library archives, so that by > the time its left-to-right scan sees the first library archive, all > the missing symbols in the object files are known. The above change > depends on LIBS being a strict superset of all the library archive > files ($GITLIBS in the current code, but that can be updated in the > future) listed as prerequisites for the rule, but there is nothing to > guarantee that, so it looks brittle. > > Exact same comment applies to the other two rules touched by this patch. Hmm, there are other constructs like this that rely on $(LIBS) being a superset of the archives, so the three rules changed here align with the trend rather than introduce a new trend. Not saying we shouldn't find a way to handle the overall brittleness. Harald