{"thread":{"id":"65721","subject":"[PATCH] Makefile: drop duplicate %.a from link recipes","startedAt":"2026-05-31T23:16:49Z","lastAt":"2026-06-22T15:49:46Z","messageCount":18,"participants":["Harald Nordgren via GitGitGadget","Junio C Hamano","Harald Nordgren","D. Ben Knoble","Patrick Steinhardt","Paolo Bonzini"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"544333","messageId":"pull.2314.git.git.1780269406949.gitgitgadget@gmail.com","threadId":"65721","inReplyTo":null,"subject":"[PATCH] Makefile: drop duplicate %.a from link recipes","fromName":"Harald Nordgren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-05-31T23:16:46Z","receivedAt":"2026-05-31T23:16:49Z","isPatch":true,"body":"From: Harald Nordgren <haraldnordgren@gmail.com>\n\nThree link recipes list archive files twice on the link line: once\nvia $(filter %.a,$^) and again through $(LIBS), which expands to\n$(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the linker warns\nabout the duplicates:\n\n  ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'\n\nDrop the redundant filter from the test-helper, fuzz-program, and\nunit-test recipes so they match the pattern used by other link\nrecipes in the file.\n\nSigned-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n---\n    Makefile: drop duplicate %.a from test-helper link rule\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v1\nPull-Request: https://github.com/git/git/pull/2314\n\n Makefile | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex b31ecb0756..309d1d1e74 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -3392,7 +3392,7 @@ perf: all\n t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o\n \n t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n+\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n \n check-sha1:: t/helper/test-tool$X\n \tt/helper/test-sha1.sh\n@@ -4015,13 +4015,13 @@ fuzz-all: $(FUZZ_PROGRAMS)\n $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS\n \t$(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \\\n \t\t-Wl,--allow-multiple-definition \\\n-\t\t$(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n+\t\t$(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n \n $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_OBJS) \\\n \t$(GITLIBS) GIT-LDFLAGS\n \t$(call mkdir_p_parent_template)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \\\n-\t\t$(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n+\t\t$(filter %.o,$^) $(LIBS)\n \n GIT-TEST-SUITES: FORCE\n \t@FLAGS='$(CLAR_TEST_SUITES)'; \\\n\nbase-commit: 1666c1265231b0bc5f613fbbf3f0a9896cdef76e\n-- \ngitgitgadget\n"},{"id":"544650","messageId":"xmqqik7zqh4p.fsf@gitster.g","threadId":"65721","inReplyTo":"pull.2314.git.git.1780269406949.gitgitgadget@gmail.com","subject":"Re: [PATCH] Makefile: drop duplicate %.a from link recipes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-06-04T00:33:10Z","receivedAt":"2026-06-04T00:33:12Z","isPatch":true,"body":"\"Harald Nordgren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n>  t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)\n> -\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n> +\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n\nI think the reason why the pattern to use only the .o files among\nthe prerequisites and then use only the .a files among the same\nprerequisites (both filters $^) is used here is to make sure that the\nlinker sees object files first before library archives, so that by\nthe time its left-to-right scan sees the first library archive, all\nthe missing symbols in the object files are known.  The above change\ndepends on LIBS being a strict superset of all the library archive\nfiles ($GITLIBS in the current code, but that can be updated in the\nfuture) listed as prerequisites for the rule, but there is nothing to\nguarantee that, so it looks brittle.\n\nExact same comment applies to the other two rules touched by this patch.\n\n"},{"id":"544674","messageId":"CAHwyqnV6uh_yyO9FcUiXKfKPt15ojR3GOmRC06pW55f=KRu=Zw@mail.gmail.com","threadId":"65721","inReplyTo":"xmqqik7zqh4p.fsf@gitster.g","subject":"Re: [PATCH] Makefile: drop duplicate %.a from link recipes","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2026-06-04T07:06:49Z","receivedAt":"2026-06-04T07:07:29Z","isPatch":true,"body":"On Thu, Jun 4, 2026 at 2:33 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Harald Nordgren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> >  t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)\n> > -     $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n> > +     $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n>\n> I think the reason why the pattern to use only the .o files among\n> the prerequisites and then use only the .a files among the same\n> prerequisites (both filters $^) is used here is to make sure that the\n> linker sees object files first before library archives, so that by\n> the time its left-to-right scan sees the first library archive, all\n> the missing symbols in the object files are known.  The above change\n> depends on LIBS being a strict superset of all the library archive\n> files ($GITLIBS in the current code, but that can be updated in the\n> future) listed as prerequisites for the rule, but there is nothing to\n> guarantee that, so it looks brittle.\n>\n> Exact same comment applies to the other two rules touched by this patch.\n\nHmm, there are other constructs like this that rely on $(LIBS) being a\nsuperset of the archives, so the three rules changed here align with\nthe trend rather than introduce a new trend.\n\nNot saying we shouldn't find a way to handle the overall brittleness.\n\n\nHarald\n"},{"id":"544677","messageId":"CAHwyqnXScbCONOGcP1RY3Ho7t7Y3smOfOMOOVf7eNsrQRnSLJw@mail.gmail.com","threadId":"65721","inReplyTo":"CAHwyqnV6uh_yyO9FcUiXKfKPt15ojR3GOmRC06pW55f=KRu=Zw@mail.gmail.com","subject":"Re: [PATCH] Makefile: drop duplicate %.a from link recipes","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2026-06-04T07:15:29Z","receivedAt":"2026-06-04T07:16:08Z","isPatch":true,"body":"Maybe we can do this to get around the brittleness for all ~10 places:\n\n```\n-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)\n+LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out\n%.o,$(GITLIBS)) $(EXTLIBS))\n\n BASIC_CFLAGS += $(COMPAT_CFLAGS)\n LIB_OBJS += $(COMPAT_OBJS)\n@@ -3392,7 +3395,7 @@ perf: all\n t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))\n$(UNIT_TEST_DIR)/test-lib.o\n\n t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)\n- $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter\n%.o,$^) $(filter %.a,$^) $(LIBS)\n+ $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n\n check-sha1:: t/helper/test-tool$X\n  t/helper/test-sha1.sh\n@@ -4015,13 +4018,13 @@ fuzz-all: $(FUZZ_PROGRAMS)\n $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS\n  $(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \\\n  -Wl,--allow-multiple-definition \\\n- $(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n+ $(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n\n $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o\n$(UNIT_TEST_OBJS) \\\n  $(GITLIBS) GIT-LDFLAGS\n  $(call mkdir_p_parent_template)\n  $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \\\n- $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n+ $(filter %.o,$^) $(LIBS)\n\n GIT-TEST-SUITES: FORCE\n  @FLAGS='$(CLAR_TEST_SUITES)'; \\\n```\n\n\nHarald\n\nOn Thu, Jun 4, 2026 at 9:06 AM Harald Nordgren <haraldnordgren@gmail.com> wrote:\n>\n> On Thu, Jun 4, 2026 at 2:33 AM Junio C Hamano <gitster@pobox.com> wrote:\n> >\n> > \"Harald Nordgren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> >\n> > >  t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)\n> > > -     $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n> > > +     $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n> >\n> > I think the reason why the pattern to use only the .o files among\n> > the prerequisites and then use only the .a files among the same\n> > prerequisites (both filters $^) is used here is to make sure that the\n> > linker sees object files first before library archives, so that by\n> > the time its left-to-right scan sees the first library archive, all\n> > the missing symbols in the object files are known.  The above change\n> > depends on LIBS being a strict superset of all the library archive\n> > files ($GITLIBS in the current code, but that can be updated in the\n> > future) listed as prerequisites for the rule, but there is nothing to\n> > guarantee that, so it looks brittle.\n> >\n> > Exact same comment applies to the other two rules touched by this patch.\n>\n> Hmm, there are other constructs like this that rely on $(LIBS) being a\n> superset of the archives, so the three rules changed here align with\n> the trend rather than introduce a new trend.\n>\n> Not saying we shouldn't find a way to handle the overall brittleness.\n>\n>\n> Harald\n"},{"id":"544767","messageId":"pull.2314.v2.git.git.1780610623006.gitgitgadget@gmail.com","threadId":"65721","inReplyTo":"pull.2314.git.git.1780269406949.gitgitgadget@gmail.com","subject":"[PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them","fromName":"Harald Nordgren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-06-04T22:03:42Z","receivedAt":"2026-06-04T22:03:45Z","isPatch":true,"body":"From: Harald Nordgren <haraldnordgren@gmail.com>\n\nA handful of link recipes listed archive files twice: once explicitly\nvia $(filter %.a,$^) and again implicitly through $(LIBS), which\nexpanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the\nlinker warned about the duplicates:\n\n  ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'\n\nRedefine $(LIBS) to list archive prerequisites from $^ first, then\nthe rest of the library list with those archives filtered out so each\nappears only once.\n\nSigned-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n---\n    Makefile: drop duplicate %.a from test-helper link rule\n    \n    Redefine $(LIBS) to list archive prerequisites from $^ first, then the\n    rest of the library list to avoid brittleness in the future.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v2\nPull-Request: https://github.com/git/git/pull/2314\n\nRange-diff vs v1:\n\n 1:  f6166450b0 ! 1:  0ef442ea05 Makefile: drop duplicate %.a from link recipes\n     @@ Metadata\n      Author: Harald Nordgren <haraldnordgren@gmail.com>\n      \n       ## Commit message ##\n     -    Makefile: drop duplicate %.a from link recipes\n     +    Makefile: dedup archives in $(LIBS) so link recipes don't repeat them\n      \n     -    Three link recipes list archive files twice on the link line: once\n     -    via $(filter %.a,$^) and again through $(LIBS), which expands to\n     -    $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the linker warns\n     -    about the duplicates:\n     +    A handful of link recipes listed archive files twice: once explicitly\n     +    via $(filter %.a,$^) and again implicitly through $(LIBS), which\n     +    expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the\n     +    linker warned about the duplicates:\n      \n            ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'\n      \n     -    Drop the redundant filter from the test-helper, fuzz-program, and\n     -    unit-test recipes so they match the pattern used by other link\n     -    recipes in the file.\n     +    Redefine $(LIBS) to list archive prerequisites from $^ first, then\n     +    the rest of the library list with those archives filtered out so each\n     +    appears only once.\n      \n          Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n      \n       ## Makefile ##\n     +@@ Makefile: endif\n     + #\n     + # where we use it as a dependency. Since we also pull object files\n     + # from the dependency list, that would make each entry appear twice.\n     +-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)\n     ++# Archives from $^ come first, then the rest with those archives\n     ++# filtered out so each appears only once.\n     ++LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))\n     + \n     + BASIC_CFLAGS += $(COMPAT_CFLAGS)\n     + LIB_OBJS += $(COMPAT_OBJS)\n      @@ Makefile: perf: all\n       t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o\n       \n\n\n Makefile | 10 ++++++----\n 1 file changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex b31ecb0756..a828a66f28 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2503,7 +2503,9 @@ endif\n #\n # where we use it as a dependency. Since we also pull object files\n # from the dependency list, that would make each entry appear twice.\n-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)\n+# Archives from $^ come first, then the rest with those archives\n+# filtered out so each appears only once.\n+LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))\n \n BASIC_CFLAGS += $(COMPAT_CFLAGS)\n LIB_OBJS += $(COMPAT_OBJS)\n@@ -3392,7 +3394,7 @@ perf: all\n t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o\n \n t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n+\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n \n check-sha1:: t/helper/test-tool$X\n \tt/helper/test-sha1.sh\n@@ -4015,13 +4017,13 @@ fuzz-all: $(FUZZ_PROGRAMS)\n $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS\n \t$(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \\\n \t\t-Wl,--allow-multiple-definition \\\n-\t\t$(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n+\t\t$(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n \n $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_OBJS) \\\n \t$(GITLIBS) GIT-LDFLAGS\n \t$(call mkdir_p_parent_template)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \\\n-\t\t$(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n+\t\t$(filter %.o,$^) $(LIBS)\n \n GIT-TEST-SUITES: FORCE\n \t@FLAGS='$(CLAR_TEST_SUITES)'; \\\n\nbase-commit: 9ac3f193c05c2237e2b14ebaa1149e9fc8a1abe0\n-- \ngitgitgadget\n"},{"id":"545144","messageId":"CAHwyqnWSLymeW-yQcjP-5shHGqYg+vu3rN-uwX21dY-dTR2CnQ@mail.gmail.com","threadId":"65721","inReplyTo":"pull.2314.v2.git.git.1780610623006.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2026-06-10T13:24:04Z","receivedAt":"2026-06-10T13:24:42Z","isPatch":true,"body":"Hi Johannes!\n\nMaybe this could be interesting for you to look at too.\n\n\n\nHarald\n\nOn Fri, Jun 5, 2026 at 12:03 AM Harald Nordgren via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> From: Harald Nordgren <haraldnordgren@gmail.com>\n>\n> A handful of link recipes listed archive files twice: once explicitly\n> via $(filter %.a,$^) and again implicitly through $(LIBS), which\n> expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the\n> linker warned about the duplicates:\n>\n>   ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'\n>\n> Redefine $(LIBS) to list archive prerequisites from $^ first, then\n> the rest of the library list with those archives filtered out so each\n> appears only once.\n>\n> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n> ---\n>     Makefile: drop duplicate %.a from test-helper link rule\n>\n>     Redefine $(LIBS) to list archive prerequisites from $^ first, then the\n>     rest of the library list to avoid brittleness in the future.\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v2\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v2\n> Pull-Request: https://github.com/git/git/pull/2314\n>\n> Range-diff vs v1:\n>\n>  1:  f6166450b0 ! 1:  0ef442ea05 Makefile: drop duplicate %.a from link recipes\n>      @@ Metadata\n>       Author: Harald Nordgren <haraldnordgren@gmail.com>\n>\n>        ## Commit message ##\n>      -    Makefile: drop duplicate %.a from link recipes\n>      +    Makefile: dedup archives in $(LIBS) so link recipes don't repeat them\n>\n>      -    Three link recipes list archive files twice on the link line: once\n>      -    via $(filter %.a,$^) and again through $(LIBS), which expands to\n>      -    $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the linker warns\n>      -    about the duplicates:\n>      +    A handful of link recipes listed archive files twice: once explicitly\n>      +    via $(filter %.a,$^) and again implicitly through $(LIBS), which\n>      +    expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the\n>      +    linker warned about the duplicates:\n>\n>             ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'\n>\n>      -    Drop the redundant filter from the test-helper, fuzz-program, and\n>      -    unit-test recipes so they match the pattern used by other link\n>      -    recipes in the file.\n>      +    Redefine $(LIBS) to list archive prerequisites from $^ first, then\n>      +    the rest of the library list with those archives filtered out so each\n>      +    appears only once.\n>\n>           Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n>\n>        ## Makefile ##\n>      +@@ Makefile: endif\n>      + #\n>      + # where we use it as a dependency. Since we also pull object files\n>      + # from the dependency list, that would make each entry appear twice.\n>      +-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)\n>      ++# Archives from $^ come first, then the rest with those archives\n>      ++# filtered out so each appears only once.\n>      ++LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))\n>      +\n>      + BASIC_CFLAGS += $(COMPAT_CFLAGS)\n>      + LIB_OBJS += $(COMPAT_OBJS)\n>       @@ Makefile: perf: all\n>        t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o\n>\n>\n>\n>  Makefile | 10 ++++++----\n>  1 file changed, 6 insertions(+), 4 deletions(-)\n>\n> diff --git a/Makefile b/Makefile\n> index b31ecb0756..a828a66f28 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -2503,7 +2503,9 @@ endif\n>  #\n>  # where we use it as a dependency. Since we also pull object files\n>  # from the dependency list, that would make each entry appear twice.\n> -LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)\n> +# Archives from $^ come first, then the rest with those archives\n> +# filtered out so each appears only once.\n> +LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))\n>\n>  BASIC_CFLAGS += $(COMPAT_CFLAGS)\n>  LIB_OBJS += $(COMPAT_OBJS)\n> @@ -3392,7 +3394,7 @@ perf: all\n>  t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o\n>\n>  t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)\n> -       $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n> +       $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n>\n>  check-sha1:: t/helper/test-tool$X\n>         t/helper/test-sha1.sh\n> @@ -4015,13 +4017,13 @@ fuzz-all: $(FUZZ_PROGRAMS)\n>  $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS\n>         $(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \\\n>                 -Wl,--allow-multiple-definition \\\n> -               $(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n> +               $(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n>\n>  $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_OBJS) \\\n>         $(GITLIBS) GIT-LDFLAGS\n>         $(call mkdir_p_parent_template)\n>         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \\\n> -               $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n> +               $(filter %.o,$^) $(LIBS)\n>\n>  GIT-TEST-SUITES: FORCE\n>         @FLAGS='$(CLAR_TEST_SUITES)'; \\\n>\n> base-commit: 9ac3f193c05c2237e2b14ebaa1149e9fc8a1abe0\n> --\n> gitgitgadget\n"},{"id":"545925","messageId":"CAHwyqnWBb65dC+qSYTw9SKdufjibUmTm065feM5D9906H5SQ4w@mail.gmail.com","threadId":"65721","inReplyTo":"pull.2314.v2.git.git.1780610623006.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2026-06-19T08:00:28Z","receivedAt":"2026-06-19T08:01:06Z","isPatch":true,"body":"Hi!\n\nI think this would be quite nice to fix for all the macOS developers\n(I don't know how many we have who are active on this list), but when\nrunning repeated tests it does take up some space on the terminal:\n\n````\n❯ git rebase --keep-base -x 'make -s && cd t && prove -j8\nt345?-history*.sh && echo'\n\nExecuting: make -s && cd t && prove -j8 t345?-history*.sh && echo\nGIT_VERSION=2.55.0.rc1.20.g1e31474ef6\nld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\nld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\nt3450-history.sh ......... ok\nt3453-history-fixup.sh ... ok\nt3451-history-reword.sh .. ok\nt3452-history-split.sh ... ok\nAll tests successful.\nFiles=4, Tests=69,  7 wallclock secs ( 0.02 usr  0.01 sys +  4.14 cusr\n 5.39 csys =  9.56 CPU)\nResult: PASS\n\nExecuting: make -s && cd t && prove -j8 t345?-history*.sh && echo\nGIT_VERSION=2.55.0.rc1.21.g498da64046\nld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\nld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\nt3450-history.sh ......... ok\nt3453-history-fixup.sh ... ok\nt3451-history-reword.sh .. ok\nt3452-history-split.sh ... ok\nAll tests successful.\nFiles=4, Tests=69,  7 wallclock secs ( 0.02 usr  0.01 sys +  4.16 cusr\n 5.41 csys =  9.60 CPU)\nResult: PASS\n\nExecuting: make -s && cd t && prove -j8 t345?-history*.sh && echo\nGIT_VERSION=2.55.0.rc1.22.g0050368e96\nld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\nld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\nt3450-history.sh ......... ok\nt3455-history-squash.sh .. ok\nt3453-history-fixup.sh ... ok\nt3451-history-reword.sh .. ok\nt3452-history-split.sh ... ok\nAll tests successful.\nFiles=5, Tests=86,  7 wallclock secs ( 0.03 usr  0.01 sys +  4.89 cusr\n 6.36 csys = 11.29 CPU)\nResult: PASS\n\nExecuting: make -s && cd t && prove -j8 t345?-history*.sh && echo\nGIT_VERSION=2.55.0.rc1.23.gb86b93bda1\nld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\nld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\nt3450-history.sh ......... ok\nt3455-history-squash.sh .. ok\nt3453-history-fixup.sh ... ok\nt3451-history-reword.sh .. ok\nt3452-history-split.sh ... ok\nAll tests successful.\nFiles=5, Tests=88,  7 wallclock secs ( 0.03 usr  0.01 sys +  5.01 cusr\n 6.54 csys = 11.59 CPU)\nResult: PASS\n\nSuccessfully rebased and updated refs/heads/rebase-fixup-fold.\n```\n\n\nHarald\n\nOn Fri, Jun 5, 2026 at 12:03 AM Harald Nordgren via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> From: Harald Nordgren <haraldnordgren@gmail.com>\n>\n> A handful of link recipes listed archive files twice: once explicitly\n> via $(filter %.a,$^) and again implicitly through $(LIBS), which\n> expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the\n> linker warned about the duplicates:\n>\n>   ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'\n>\n> Redefine $(LIBS) to list archive prerequisites from $^ first, then\n> the rest of the library list with those archives filtered out so each\n> appears only once.\n>\n> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n> ---\n>     Makefile: drop duplicate %.a from test-helper link rule\n>\n>     Redefine $(LIBS) to list archive prerequisites from $^ first, then the\n>     rest of the library list to avoid brittleness in the future.\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v2\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v2\n> Pull-Request: https://github.com/git/git/pull/2314\n>\n> Range-diff vs v1:\n>\n>  1:  f6166450b0 ! 1:  0ef442ea05 Makefile: drop duplicate %.a from link recipes\n>      @@ Metadata\n>       Author: Harald Nordgren <haraldnordgren@gmail.com>\n>\n>        ## Commit message ##\n>      -    Makefile: drop duplicate %.a from link recipes\n>      +    Makefile: dedup archives in $(LIBS) so link recipes don't repeat them\n>\n>      -    Three link recipes list archive files twice on the link line: once\n>      -    via $(filter %.a,$^) and again through $(LIBS), which expands to\n>      -    $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the linker warns\n>      -    about the duplicates:\n>      +    A handful of link recipes listed archive files twice: once explicitly\n>      +    via $(filter %.a,$^) and again implicitly through $(LIBS), which\n>      +    expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the\n>      +    linker warned about the duplicates:\n>\n>             ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'\n>\n>      -    Drop the redundant filter from the test-helper, fuzz-program, and\n>      -    unit-test recipes so they match the pattern used by other link\n>      -    recipes in the file.\n>      +    Redefine $(LIBS) to list archive prerequisites from $^ first, then\n>      +    the rest of the library list with those archives filtered out so each\n>      +    appears only once.\n>\n>           Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n>\n>        ## Makefile ##\n>      +@@ Makefile: endif\n>      + #\n>      + # where we use it as a dependency. Since we also pull object files\n>      + # from the dependency list, that would make each entry appear twice.\n>      +-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)\n>      ++# Archives from $^ come first, then the rest with those archives\n>      ++# filtered out so each appears only once.\n>      ++LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))\n>      +\n>      + BASIC_CFLAGS += $(COMPAT_CFLAGS)\n>      + LIB_OBJS += $(COMPAT_OBJS)\n>       @@ Makefile: perf: all\n>        t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o\n>\n>\n>\n>  Makefile | 10 ++++++----\n>  1 file changed, 6 insertions(+), 4 deletions(-)\n>\n> diff --git a/Makefile b/Makefile\n> index b31ecb0756..a828a66f28 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -2503,7 +2503,9 @@ endif\n>  #\n>  # where we use it as a dependency. Since we also pull object files\n>  # from the dependency list, that would make each entry appear twice.\n> -LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)\n> +# Archives from $^ come first, then the rest with those archives\n> +# filtered out so each appears only once.\n> +LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))\n>\n>  BASIC_CFLAGS += $(COMPAT_CFLAGS)\n>  LIB_OBJS += $(COMPAT_OBJS)\n> @@ -3392,7 +3394,7 @@ perf: all\n>  t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o\n>\n>  t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)\n> -       $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n> +       $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n>\n>  check-sha1:: t/helper/test-tool$X\n>         t/helper/test-sha1.sh\n> @@ -4015,13 +4017,13 @@ fuzz-all: $(FUZZ_PROGRAMS)\n>  $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS\n>         $(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \\\n>                 -Wl,--allow-multiple-definition \\\n> -               $(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n> +               $(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)\n>\n>  $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_OBJS) \\\n>         $(GITLIBS) GIT-LDFLAGS\n>         $(call mkdir_p_parent_template)\n>         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \\\n> -               $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n> +               $(filter %.o,$^) $(LIBS)\n>\n>  GIT-TEST-SUITES: FORCE\n>         @FLAGS='$(CLAR_TEST_SUITES)'; \\\n>\n> base-commit: 9ac3f193c05c2237e2b14ebaa1149e9fc8a1abe0\n> --\n> gitgitgadget\n"},{"id":"545979","messageId":"xmqqldcamtat.fsf@gitster.g","threadId":"65721","inReplyTo":"CAHwyqnWBb65dC+qSYTw9SKdufjibUmTm065feM5D9906H5SQ4w@mail.gmail.com","subject":"Re: [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-06-19T15:41:30Z","receivedAt":"2026-06-19T15:41:33Z","isPatch":true,"body":"Harald Nordgren <haraldnordgren@gmail.com> writes:\n\n> I think this would be quite nice to fix for all the macOS developers\n> (I don't know how many we have who are active on this list), but when\n> running repeated tests it does take up some space on the terminal:\n>\n> ````\n> ❯ git rebase --keep-base -x 'make -s && cd t && prove -j8\n> t345?-history*.sh && echo'\n>\n> Executing: make -s && cd t && prove -j8 t345?-history*.sh && echo\n> GIT_VERSION=2.55.0.rc1.20.g1e31474ef6\n> ld: warning: ignoring duplicate libraries: 'libgit.a',\n> 'target/release/libgitcore.a'\n> ld: warning: ignoring duplicate libraries: 'libgit.a',\n> 'target/release/libgitcore.a'\n\nWhile I am very sympathetic that it may be annoying, I have to\nwonder if that is ultimately the linker's job to accept the same\nlibrary listed twice on the same command line, deside when it can\nignore the second one, and *silently* ignore it.\n\nImagine this situation.\n\n - There are two library archives, libA.a has a.o in it and libB.a\n   has b.o in it, respectively.\n\n - The object file a.o defines a symbol that b.o needs, and b.o\n   defines a symbol a.o needs (i.e., mutually dependent). libA.a and\n   libB.a have other symbols in them. There are valid reasons why we\n   do not want to combine them into a single libAB.a.\n\n - Now our program X uses both libraries and we build and try to link it this way:\n\n   $(CC) -c x.c\t\t\t\t# this builds x.o\n   $(CC) -o programX x.o libA.a libB.a  # unfortunately does not work as-is\n\n   which fails because x.o uses symbol from libA.a that is not in\n   a.o (so a.o is not linked), and then x.o also uses something in\n   b.o that is picked up from libB.a.  But b.o in turn needs a.o\n   that we already skipped.  One way to make it work is to tweak the\n   final link phase to read like this:\n\n   $(CC) -o programX x.o libA.a libB.a libA.a\n\nIf your linker complains because we list libA.a twice, it would be\nannoying.\n\nI guess if we can assume GNU ld (e.g., gcc/clang), we can use\n\n   $(CC) -o programX x.o -Wl,--start-group libA.a libB.a -Wl,end-group\n\nto tell the linker that they need to be processed for circular\ndependencies, but listing them twice is more portable and harmless\n(i.e., if all the symbols are resolved by the time the linker sees\nthe second libA.a, then it would not pick up anything extra from\nthere) way to achieve the same thing.  \n\nSo from future-proofing and portability perspective (which is\nanother way to say maintainability we care about), I would very much\nprefer to see this solved at the linker level, allowing the build\nprocedure to list the same library twice on the command line.\n\nIt seems that on the Internet various folks, including masonbuild\nand CMake, have heard complaints from users enough and fixed the\nlinker by using -no_warn_duplicate_libraries option.  Their approach\ntranslates to something like the following in our build environment.\n\n config.mak.uname | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git i/config.mak.uname w/config.mak.uname\nindex 8719e09f66..e29eaaf3fd 100644\n--- i/config.mak.uname\n+++ w/config.mak.uname\n@@ -149,6 +149,10 @@ ifeq ($(uname_S),Darwin)\n         ifeq ($(shell test \"`expr \"$(uname_R)\" : '\\([0-9][0-9]*\\)\\.'`\" -ge 20 && echo 1),1)\n \t\tOPEN_RETURNS_EINTR = UnfortunatelyYes\n         endif\n+\n+\t# NEEDSWORK: do this only for XCode 15 or later\n+\tBASIC_LDFLAGS += -Wl,-no_warn_duplicate_libraries\n+\n \tNO_MEMMEM = YesPlease\n \tUSE_ST_TIMESPEC = YesPlease\n \tHAVE_DEV_TTY = YesPlease\n"},{"id":"546005","messageId":"CAHwyqnVutjoe-0Qj=HBkbrRU7zq2o-gtoBt_iVyB2so-uB6_8A@mail.gmail.com","threadId":"65721","inReplyTo":"xmqqldcamtat.fsf@gitster.g","subject":"Re: [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2026-06-19T20:25:58Z","receivedAt":"2026-06-19T20:26:37Z","isPatch":true,"body":"Thanks for a good lesson about linkers!\n\nGood idea to fix it through the same LD_MAJOR_VERSION as we did for\nthe __DATA,__common alignment, makes it a lot cleaner.\n\n\nHarald\n"},{"id":"546006","messageId":"pull.2314.v3.git.git.1781901127385.gitgitgadget@gmail.com","threadId":"65721","inReplyTo":"pull.2314.v2.git.git.1780610623006.gitgitgadget@gmail.com","subject":"[PATCH v3] config.mak.uname: avoid macOS dup-library warning","fromName":"Harald Nordgren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-06-19T20:32:07Z","receivedAt":"2026-06-19T20:32:09Z","isPatch":true,"body":"From: Harald Nordgren <haraldnordgren@gmail.com>\n\nBuilding on macOS with Xcode 15 or newer emits:\n\n    ld: warning: ignoring duplicate libraries: 'libgit.a',\n    'target/release/libgitcore.a'\n\nSome link recipes list the same archive twice, which is harmless.\nQuiet the warning instead.\n\nPass -Wl,-no_warn_duplicate_libraries on Xcode 15 and newer, whose\nlinkers added both the warning and the suppression flag (ld64-907\nand dyld-1009). Earlier linkers reject the flag, so gate on the\nlinker version. Broaden the existing -fno-common version probe to\nalso match the \"ld64-NNN\" and \"dyld-NNN\" forms Xcode 15 reports.\n\nSigned-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n---\n    Makefile: drop duplicate %.a from test-helper link rule\n    \n    Fix warning of duplicate libraries on macOS.\n    \n    Changes in v3:\n    \n     * Suppress the warning at the linker rather than dedup the archive list\n     * Pass -Wl,-no_warn_duplicate_libraries in config.mak.uname, gated on\n       the linker version (reuses the probe added for -fno-common), and\n       broaden the regex to match all three PROJECT:{ld64,dyld,ld}-NNN forms\n     * Floor of 907 and the version forms (ld64-907, dyld-1009.5) per meson:\n       https://github.com/mesonbuild/meson/blob/master/mesonbuild/linkers/linkers.py\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v3\nPull-Request: https://github.com/git/git/pull/2314\n\nRange-diff vs v2:\n\n 1:  0ef442ea05 < -:  ---------- Makefile: dedup archives in $(LIBS) so link recipes don't repeat them\n -:  ---------- > 1:  5bf560c5ad config.mak.uname: avoid macOS dup-library warning\n\n\n config.mak.uname | 11 +++++++++--\n 1 file changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 8719e09f66..9ebd240378 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -173,8 +173,15 @@ ifeq ($(uname_S),Darwin)\n \t\tNEEDS_GOOD_LIBICONV = UnfortunatelyYes\n         endif\n \n-\t# Silence Xcode 16.3+ linker warning about __DATA,__common alignment.\n-\tLD_MAJOR_VERSION = $(shell ld -v 2>&1 | sed -n 's/.*PROJECT:ld-\\([0-9]*\\).*/\\1/p')\n+\t# ld reports \"PROJECT:{ld,ld64,dyld}-NNN\", match any of the three.\n+\tLD_MAJOR_VERSION = $(shell ld -v 2>&1 | sed -n 's/.*PROJECT:[^ ]*-\\([0-9][0-9]*\\).*/\\1/p')\n+\n+\t# Silence the Xcode 15+ warning about archives listed more than once.\n+        ifeq ($(shell test -n \"$(LD_MAJOR_VERSION)\" && test \"$(LD_MAJOR_VERSION)\" -ge 907 && echo 1),1)\n+\t\tBASIC_LDFLAGS += -Wl,-no_warn_duplicate_libraries\n+        endif\n+\n+\t# Silence the Xcode 16.3+ warning about __DATA,__common alignment.\n         ifeq ($(shell test -n \"$(LD_MAJOR_VERSION)\" && test \"$(LD_MAJOR_VERSION)\" -ge 1167 && echo 1),1)\n \t\tBASIC_CFLAGS += -fno-common\n         endif\n\nbase-commit: 95e20213faefeb95df29277c58ac1980ab68f701\n-- \ngitgitgadget\n"},{"id":"546007","messageId":"xmqqv7bei2tf.fsf@gitster.g","threadId":"65721","inReplyTo":"pull.2314.v3.git.git.1781901127385.gitgitgadget@gmail.com","subject":"Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-06-19T22:27:08Z","receivedAt":"2026-06-19T22:27:11Z","isPatch":true,"body":"\"Harald Nordgren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Harald Nordgren <haraldnordgren@gmail.com>\n>\n> Building on macOS with Xcode 15 or newer emits:\n>\n>     ld: warning: ignoring duplicate libraries: 'libgit.a',\n>     'target/release/libgitcore.a'\n>\n> Some link recipes list the same archive twice, which is harmless.\n> Quiet the warning instead.\n>\n> Pass -Wl,-no_warn_duplicate_libraries on Xcode 15 and newer, whose\n> linkers added both the warning and the suppression flag (ld64-907\n> and dyld-1009). Earlier linkers reject the flag, so gate on the\n> linker version. Broaden the existing -fno-common version probe to\n> also match the \"ld64-NNN\" and \"dyld-NNN\" forms Xcode 15 reports.\n>\n> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n> ---\n\nYeah, this looks like what I expected.\n\nA few things to note.\n\n * Can folks with different versions of Xcode (or is 15 sufficiently\n   old that practically nobody is expected to have anything older?)\n   test this patch?\n\n * We only patch Makefile here; can folks who use meson report how\n   well your build goes?\n\nThanks.\n\n>  config.mak.uname | 11 +++++++++--\n>  1 file changed, 9 insertions(+), 2 deletions(-)\n>\n> diff --git a/config.mak.uname b/config.mak.uname\n> index 8719e09f66..9ebd240378 100644\n> --- a/config.mak.uname\n> +++ b/config.mak.uname\n> @@ -173,8 +173,15 @@ ifeq ($(uname_S),Darwin)\n>  \t\tNEEDS_GOOD_LIBICONV = UnfortunatelyYes\n>          endif\n>  \n> -\t# Silence Xcode 16.3+ linker warning about __DATA,__common alignment.\n> -\tLD_MAJOR_VERSION = $(shell ld -v 2>&1 | sed -n 's/.*PROJECT:ld-\\([0-9]*\\).*/\\1/p')\n> +\t# ld reports \"PROJECT:{ld,ld64,dyld}-NNN\", match any of the three.\n> +\tLD_MAJOR_VERSION = $(shell ld -v 2>&1 | sed -n 's/.*PROJECT:[^ ]*-\\([0-9][0-9]*\\).*/\\1/p')\n> +\n> +\t# Silence the Xcode 15+ warning about archives listed more than once.\n> +        ifeq ($(shell test -n \"$(LD_MAJOR_VERSION)\" && test \"$(LD_MAJOR_VERSION)\" -ge 907 && echo 1),1)\n> +\t\tBASIC_LDFLAGS += -Wl,-no_warn_duplicate_libraries\n> +        endif\n> +\n> +\t# Silence the Xcode 16.3+ warning about __DATA,__common alignment.\n>          ifeq ($(shell test -n \"$(LD_MAJOR_VERSION)\" && test \"$(LD_MAJOR_VERSION)\" -ge 1167 && echo 1),1)\n>  \t\tBASIC_CFLAGS += -fno-common\n>          endif\n>\n> base-commit: 95e20213faefeb95df29277c58ac1980ab68f701\n"},{"id":"546043","messageId":"CALnO6CAgNdkg0PnN9Zy=zLurLUSb2hUXYAGe_qB0oceZNy_=gg@mail.gmail.com","threadId":"65721","inReplyTo":"xmqqv7bei2tf.fsf@gitster.g","subject":"Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-06-20T20:58:41Z","receivedAt":"2026-06-20T20:58:54Z","isPatch":true,"body":"On Fri, Jun 19, 2026 at 6:27 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Harald Nordgren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Harald Nordgren <haraldnordgren@gmail.com>\n> >\n> > Building on macOS with Xcode 15 or newer emits:\n> >\n> >     ld: warning: ignoring duplicate libraries: 'libgit.a',\n> >     'target/release/libgitcore.a'\n> >\n> > Some link recipes list the same archive twice, which is harmless.\n> > Quiet the warning instead.\n> >\n> > Pass -Wl,-no_warn_duplicate_libraries on Xcode 15 and newer, whose\n> > linkers added both the warning and the suppression flag (ld64-907\n> > and dyld-1009). Earlier linkers reject the flag, so gate on the\n> > linker version. Broaden the existing -fno-common version probe to\n> > also match the \"ld64-NNN\" and \"dyld-NNN\" forms Xcode 15 reports.\n> >\n> > Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n> > ---\n>\n> Yeah, this looks like what I expected.\n>\n> A few things to note.\n>\n>  * Can folks with different versions of Xcode (or is 15 sufficiently\n>    old that practically nobody is expected to have anything older?)\n>    test this patch?\n>\n>  * We only patch Makefile here; can folks who use meson report how\n>    well your build goes?\n>\n> Thanks.\n\nOn one (old) machine I have available:\n\n    $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables\n    [trimmed]\n    version: 14.2.0.0.1.1668646533\n\nOn said machine, I don't get the duplicate warnings on a Meson build.\nNo issues with the patch when running make.\n\nI think I have seen this on my other machine, which is much newer.\nWhen I get around to trying it there, I'll report back as well.\n"},{"id":"546118","messageId":"ajjspU7lJ01GgrBw@pks.im","threadId":"65721","inReplyTo":"xmqqv7bei2tf.fsf@gitster.g","subject":"Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-06-22T08:04:53Z","receivedAt":"2026-06-22T08:05:00Z","isPatch":true,"body":"On Fri, Jun 19, 2026 at 03:27:08PM -0700, Junio C Hamano wrote:\n> \"Harald Nordgren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> > From: Harald Nordgren <haraldnordgren@gmail.com>\n> >\n> > Building on macOS with Xcode 15 or newer emits:\n> >\n> >     ld: warning: ignoring duplicate libraries: 'libgit.a',\n> >     'target/release/libgitcore.a'\n> >\n> > Some link recipes list the same archive twice, which is harmless.\n> > Quiet the warning instead.\n> >\n> > Pass -Wl,-no_warn_duplicate_libraries on Xcode 15 and newer, whose\n> > linkers added both the warning and the suppression flag (ld64-907\n> > and dyld-1009). Earlier linkers reject the flag, so gate on the\n> > linker version. Broaden the existing -fno-common version probe to\n> > also match the \"ld64-NNN\" and \"dyld-NNN\" forms Xcode 15 reports.\n> >\n> > Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n> > ---\n> \n> Yeah, this looks like what I expected.\n> \n> A few things to note.\n> \n>  * Can folks with different versions of Xcode (or is 15 sufficiently\n>    old that practically nobody is expected to have anything older?)\n>    test this patch?\n> \n>  * We only patch Makefile here; can folks who use meson report how\n>    well your build goes?\n\nWhen using Meson we also see a warning. This got partially fixed in\nMeson itself though via [1], where it started to disable the warning\nwhen compiling with \"--fatal-warnings\" so that it doesn't cause builds\nto break. So starting with that commit it really only is a harmless\n(albeit annoying) warning.\n\nArguably, it might make sense to unconditionally disable this warning,\nas it doesn't seem to add anything of value. I've Cc'd Paolo, one of the\nMeson maintainers.\n\nThanks!\n\nPatrick\n\n[1]: https://github.com/mesonbuild/meson/commit/17d1cc60ed8246b8e7f0786421bf1cdf5cb19254\n"},{"id":"546177","messageId":"xmqqldc63f8g.fsf@gitster.g","threadId":"65721","inReplyTo":"ajjspU7lJ01GgrBw@pks.im","subject":"Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-06-22T12:57:03Z","receivedAt":"2026-06-22T12:57:05Z","isPatch":true,"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n>> Yeah, this looks like what I expected.\n>> \n>> A few things to note.\n>> \n>>  * Can folks with different versions of Xcode (or is 15 sufficiently\n>>    old that practically nobody is expected to have anything older?)\n>>    test this patch?\n>> \n>>  * We only patch Makefile here; can folks who use meson report how\n>>    well your build goes?\n>\n> When using Meson we also see a warning. This got partially fixed in\n> Meson itself though via [1], where it started to disable the warning\n> when compiling with \"--fatal-warnings\" so that it doesn't cause builds\n> to break. So starting with that commit it really only is a harmless\n> (albeit annoying) warning.\n>\n> Arguably, it might make sense to unconditionally disable this warning,\n> as it doesn't seem to add anything of value. I've Cc'd Paolo, one of the\n> Meson maintainers.\n>\n> Thanks!\n>\n> Patrick\n>\n> [1]: https://github.com/mesonbuild/meson/commit/17d1cc60ed8246b8e7f0786421bf1cdf5cb19254\n\nI took my inspiration for -Wl,-no-whatever from Paolo's other\nattempt, referenced in\n\n    https://github.com/mesonbuild/meson/issues/15553\n\nwhich is\n\n    https://github.com/mesonbuild/meson/commit/7c901d7a8af214e31788eb6d1a1edd5b75124e66\n\n"},{"id":"546180","messageId":"cdb16758-dd92-4b8c-8e82-8c607151449f@redhat.com","threadId":"65721","inReplyTo":"xmqqldc63f8g.fsf@gitster.g","subject":"Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning","fromName":"Paolo Bonzini","fromEmail":"pbonzini@redhat.com","sentAt":"2026-06-22T13:13:05Z","receivedAt":"2026-06-22T13:13:17Z","isPatch":true,"body":"On 6/22/26 14:57, Junio C Hamano wrote:\n>> [1]:https://github.com/mesonbuild/meson/ \n>> commit/17d1cc60ed8246b8e7f0786421bf1cdf5cb19254\n> I took my inspiration for -Wl,-no-whatever from Paolo's other\n> attempt, referenced in\n> \n>      https://github.com/mesonbuild/meson/issues/15553\n> \n> which is\n> \n>      https://github.com/mesonbuild/meson/ \n> commit/7c901d7a8af214e31788eb6d1a1edd5b75124e66\n\nYeah, it makes sense for Meson to disable it unconditionally.  I \nwouldn't bother adding a check in meson.build though, since as Patrick \nmentioned it's mostly a nuisance.\n\nPaolo\n\n"},{"id":"546182","messageId":"ajk6QGB8raf85CPo@pks.im","threadId":"65721","inReplyTo":"cdb16758-dd92-4b8c-8e82-8c607151449f@redhat.com","subject":"Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-06-22T13:36:00Z","receivedAt":"2026-06-22T13:36:07Z","isPatch":true,"body":"On Mon, Jun 22, 2026 at 03:13:05PM +0200, Paolo Bonzini wrote:\n> On 6/22/26 14:57, Junio C Hamano wrote:\n> > > [1]:https://github.com/mesonbuild/meson/\n> > > commit/17d1cc60ed8246b8e7f0786421bf1cdf5cb19254\n> > I took my inspiration for -Wl,-no-whatever from Paolo's other\n> > attempt, referenced in\n> > \n> >      https://github.com/mesonbuild/meson/issues/15553\n> > \n> > which is\n> > \n> >      https://github.com/mesonbuild/meson/\n> > commit/7c901d7a8af214e31788eb6d1a1edd5b75124e66\n> \n> Yeah, it makes sense for Meson to disable it unconditionally.  I wouldn't\n> bother adding a check in meson.build though, since as Patrick mentioned it's\n> mostly a nuisance.\n\nIs this something you want to implement in Meson yourself? Otherwise I'm\nhappy to create a pull request.\n\nPatrick\n"},{"id":"546186","messageId":"CABgObfZUKFgpxeKjVWpaBRCFGa1BSEh36-hkaRjZSUQb_n4=oQ@mail.gmail.com","threadId":"65721","inReplyTo":"ajk6QGB8raf85CPo@pks.im","subject":"Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning","fromName":"Paolo Bonzini","fromEmail":"pbonzini@redhat.com","sentAt":"2026-06-22T14:00:01Z","receivedAt":"2026-06-22T14:00:20Z","isPatch":true,"body":"On Mon, Jun 22, 2026 at 3:36 PM Patrick Steinhardt <ps@pks.im> wrote:\n> On Mon, Jun 22, 2026 at 03:13:05PM +0200, Paolo Bonzini wrote:\n> > On 6/22/26 14:57, Junio C Hamano wrote:\n> > > > [1]:https://github.com/mesonbuild/meson/\n> > > > commit/17d1cc60ed8246b8e7f0786421bf1cdf5cb19254\n> > > I took my inspiration for -Wl,-no-whatever from Paolo's other\n> > > attempt, referenced in\n> > >\n> > >      https://github.com/mesonbuild/meson/issues/15553\n> > >\n> > > which is\n> > >\n> > >      https://github.com/mesonbuild/meson/\n> > > commit/7c901d7a8af214e31788eb6d1a1edd5b75124e66\n> >\n> > Yeah, it makes sense for Meson to disable it unconditionally.  I wouldn't\n> > bother adding a check in meson.build though, since as Patrick mentioned it's\n> > mostly a nuisance.\n>\n> Is this something you want to implement in Meson yourself? Otherwise I'm\n> happy to create a pull request.\n\nSure, please go ahead!\n\nPaolo\n\n"},{"id":"546189","messageId":"CALnO6CCcBdmPniu3wOtktygZ4TFdz3Bp+CXNqJ9nx4_qw=to+A@mail.gmail.com","threadId":"65721","inReplyTo":"CALnO6CAgNdkg0PnN9Zy=zLurLUSb2hUXYAGe_qB0oceZNy_=gg@mail.gmail.com","subject":"Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-06-22T15:49:34Z","receivedAt":"2026-06-22T15:49:46Z","isPatch":true,"body":"On Sat, Jun 20, 2026 at 4:58 PM D. Ben Knoble <ben.knoble@gmail.com> wrote:\n>\n> On Fri, Jun 19, 2026 at 6:27 PM Junio C Hamano <gitster@pobox.com> wrote:\n> >\n> > \"Harald Nordgren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> >\n> > > From: Harald Nordgren <haraldnordgren@gmail.com>\n> > >\n> > > Building on macOS with Xcode 15 or newer emits:\n> > >\n> > >     ld: warning: ignoring duplicate libraries: 'libgit.a',\n> > >     'target/release/libgitcore.a'\n> > >\n> > > Some link recipes list the same archive twice, which is harmless.\n> > > Quiet the warning instead.\n> > >\n> > > Pass -Wl,-no_warn_duplicate_libraries on Xcode 15 and newer, whose\n> > > linkers added both the warning and the suppression flag (ld64-907\n> > > and dyld-1009). Earlier linkers reject the flag, so gate on the\n> > > linker version. Broaden the existing -fno-common version probe to\n> > > also match the \"ld64-NNN\" and \"dyld-NNN\" forms Xcode 15 reports.\n> > >\n> > > Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n> > > ---\n> >\n> > Yeah, this looks like what I expected.\n> >\n> > A few things to note.\n> >\n> >  * Can folks with different versions of Xcode (or is 15 sufficiently\n> >    old that practically nobody is expected to have anything older?)\n> >    test this patch?\n> >\n> >  * We only patch Makefile here; can folks who use meson report how\n> >    well your build goes?\n> >\n> > Thanks.\n>\n> On one (old) machine I have available:\n>\n>     $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables\n>     [trimmed]\n>     version: 14.2.0.0.1.1668646533\n>\n> On said machine, I don't get the duplicate warnings on a Meson build.\n> No issues with the patch when running make.\n\nThat old machine has \"ld -v\":\n\n    @(#)PROGRAM:ld  PROJECT:ld64-711\n    BUILD 21:57:11 Nov 17 2021\n    [trimmed]\n    LTO support using: LLVM version 13.0.0, (clang-1300.0.29.30)\n(static support for 27, runtime is 27)\n    TAPI support using: Apple TAPI version 13.0.0 (tapi-1300.0.6.5)\n\n> I think I have seen this on my other machine, which is much newer.\n> When I get around to trying it there, I'll report back as well.\n\nHere's those results:\n\n    $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables\n    [trimmed]\n    version: 26.1.0.0.1.1761104275\n\nsans patch:\n- Meson: duplicate warning\n- Make: duplicate warning\n\nw/ patch:\n- Meson: (unchanged, obviously)\n- Make: no duplicate warning\n\nUnder Meson + Ninja the warning I get is (status line may not be\nhelpful given parallelism)\n\n    [705/708] Linking target t/helper/test-tool\n    ld: warning: ignoring duplicate libraries: '-lexpat', '-liconv',\n'-lresolv', '-lz'\n\nThat's in addition to a dozen or so\n\n    ld: warning: reducing alignment of section __DATA,__common from\n0x8000 to 0x4000 because it exceeds segment maximum alignment\n\nUnder Make I get (surrounding info may not be helpful given parallelism)\n\n        LINK git\n    ld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\n        MKDIR -p t/unit-tests/bin\n        LINK git-sh-i18n--envsubst\n        LINK t/helper/test-tool\n        LINK git-remote-http\n    ld: warning: ignoring duplicate libraries: 'libgit.a',\n'target/release/libgitcore.a'\n\n(No alignment warnings this time.)\n\nLinker version (ld -v) on this machine:\n\n    @(#)PROGRAM:ld PROJECT:ld-1230.1\n    BUILD 16:18:08 Oct 17 2025\n    [trimmed]\n    LTO support using: LLVM version 17.0.0 (static support for 29,\nruntime is 29)\n    TAPI support using: Apple TAPI version 17.0.0 (tapi-1700.3.8)\n\n-- \nD. Ben Knoble\n"}]}