Git development
 help / color / mirror / Atom feed
* [PATCH] Makefile: drop duplicate %.a from link recipes
@ 2026-05-31 23:16 Harald Nordgren via GitGitGadget
  2026-06-04  0:33 ` Junio C Hamano
  2026-06-04 22:03 ` [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them Harald Nordgren via GitGitGadget
  0 siblings, 2 replies; 12+ messages in thread
From: Harald Nordgren via GitGitGadget @ 2026-05-31 23:16 UTC (permalink / raw)
  To: git; +Cc: Harald Nordgren, Harald Nordgren

From: Harald Nordgren <haraldnordgren@gmail.com>

Three link recipes list archive files twice on the link line: once
via $(filter %.a,$^) and again through $(LIBS), which expands to
$(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the linker warns
about the duplicates:

  ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'

Drop the redundant filter from the test-helper, fuzz-program, and
unit-test recipes so they match the pattern used by other link
recipes in the file.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
---
    Makefile: drop duplicate %.a from test-helper link rule

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v1
Pull-Request: https://github.com/git/git/pull/2314

 Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index b31ecb0756..309d1d1e74 100644
--- a/Makefile
+++ b/Makefile
@@ -3392,7 +3392,7 @@ perf: all
 t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o
 
 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)
 
 check-sha1:: t/helper/test-tool$X
 	t/helper/test-sha1.sh
@@ -4015,13 +4015,13 @@ fuzz-all: $(FUZZ_PROGRAMS)
 $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS
 	$(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \
 		-Wl,--allow-multiple-definition \
-		$(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
+		$(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
 
 $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_OBJS) \
 	$(GITLIBS) GIT-LDFLAGS
 	$(call mkdir_p_parent_template)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
-		$(filter %.o,$^) $(filter %.a,$^) $(LIBS)
+		$(filter %.o,$^) $(LIBS)
 
 GIT-TEST-SUITES: FORCE
 	@FLAGS='$(CLAR_TEST_SUITES)'; \

base-commit: 1666c1265231b0bc5f613fbbf3f0a9896cdef76e
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] Makefile: drop duplicate %.a from link recipes
  2026-05-31 23:16 [PATCH] Makefile: drop duplicate %.a from link recipes Harald Nordgren via GitGitGadget
@ 2026-06-04  0:33 ` Junio C Hamano
  2026-06-04  7:06   ` Harald Nordgren
  2026-06-04 22:03 ` [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them Harald Nordgren via GitGitGadget
  1 sibling, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2026-06-04  0:33 UTC (permalink / raw)
  To: Harald Nordgren via GitGitGadget; +Cc: git, Harald Nordgren

"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> 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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Makefile: drop duplicate %.a from link recipes
  2026-06-04  0:33 ` Junio C Hamano
@ 2026-06-04  7:06   ` Harald Nordgren
  2026-06-04  7:15     ` Harald Nordgren
  0 siblings, 1 reply; 12+ messages in thread
From: Harald Nordgren @ 2026-06-04  7:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Harald Nordgren via GitGitGadget, git

On Thu, Jun 4, 2026 at 2:33 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Makefile: drop duplicate %.a from link recipes
  2026-06-04  7:06   ` Harald Nordgren
@ 2026-06-04  7:15     ` Harald Nordgren
  0 siblings, 0 replies; 12+ messages in thread
From: Harald Nordgren @ 2026-06-04  7:15 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Harald Nordgren via GitGitGadget, git

Maybe we can do this to get around the brittleness for all ~10 places:

```
-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
+LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out
%.o,$(GITLIBS)) $(EXTLIBS))

 BASIC_CFLAGS += $(COMPAT_CFLAGS)
 LIB_OBJS += $(COMPAT_OBJS)
@@ -3392,7 +3395,7 @@ perf: all
 t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
$(UNIT_TEST_DIR)/test-lib.o

 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)

 check-sha1:: t/helper/test-tool$X
  t/helper/test-sha1.sh
@@ -4015,13 +4018,13 @@ fuzz-all: $(FUZZ_PROGRAMS)
 $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS
  $(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \
  -Wl,--allow-multiple-definition \
- $(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
+ $(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)

 $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o
$(UNIT_TEST_OBJS) \
  $(GITLIBS) GIT-LDFLAGS
  $(call mkdir_p_parent_template)
  $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
- $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
+ $(filter %.o,$^) $(LIBS)

 GIT-TEST-SUITES: FORCE
  @FLAGS='$(CLAR_TEST_SUITES)'; \
```


Harald

On Thu, Jun 4, 2026 at 9:06 AM Harald Nordgren <haraldnordgren@gmail.com> wrote:
>
> On Thu, Jun 4, 2026 at 2:33 AM Junio C Hamano <gitster@pobox.com> wrote:
> >
> > "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them
  2026-05-31 23:16 [PATCH] Makefile: drop duplicate %.a from link recipes Harald Nordgren via GitGitGadget
  2026-06-04  0:33 ` Junio C Hamano
@ 2026-06-04 22:03 ` Harald Nordgren via GitGitGadget
  2026-06-10 13:24   ` Harald Nordgren
                     ` (2 more replies)
  1 sibling, 3 replies; 12+ messages in thread
From: Harald Nordgren via GitGitGadget @ 2026-06-04 22:03 UTC (permalink / raw)
  To: git; +Cc: Harald Nordgren, Harald Nordgren

From: Harald Nordgren <haraldnordgren@gmail.com>

A handful of link recipes listed archive files twice: once explicitly
via $(filter %.a,$^) and again implicitly through $(LIBS), which
expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the
linker warned about the duplicates:

  ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'

Redefine $(LIBS) to list archive prerequisites from $^ first, then
the rest of the library list with those archives filtered out so each
appears only once.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
---
    Makefile: drop duplicate %.a from test-helper link rule
    
    Redefine $(LIBS) to list archive prerequisites from $^ first, then the
    rest of the library list to avoid brittleness in the future.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v2
Pull-Request: https://github.com/git/git/pull/2314

Range-diff vs v1:

 1:  f6166450b0 ! 1:  0ef442ea05 Makefile: drop duplicate %.a from link recipes
     @@ Metadata
      Author: Harald Nordgren <haraldnordgren@gmail.com>
      
       ## Commit message ##
     -    Makefile: drop duplicate %.a from link recipes
     +    Makefile: dedup archives in $(LIBS) so link recipes don't repeat them
      
     -    Three link recipes list archive files twice on the link line: once
     -    via $(filter %.a,$^) and again through $(LIBS), which expands to
     -    $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the linker warns
     -    about the duplicates:
     +    A handful of link recipes listed archive files twice: once explicitly
     +    via $(filter %.a,$^) and again implicitly through $(LIBS), which
     +    expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the
     +    linker warned about the duplicates:
      
            ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'
      
     -    Drop the redundant filter from the test-helper, fuzz-program, and
     -    unit-test recipes so they match the pattern used by other link
     -    recipes in the file.
     +    Redefine $(LIBS) to list archive prerequisites from $^ first, then
     +    the rest of the library list with those archives filtered out so each
     +    appears only once.
      
          Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
      
       ## Makefile ##
     +@@ Makefile: endif
     + #
     + # where we use it as a dependency. Since we also pull object files
     + # from the dependency list, that would make each entry appear twice.
     +-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
     ++# Archives from $^ come first, then the rest with those archives
     ++# filtered out so each appears only once.
     ++LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))
     + 
     + BASIC_CFLAGS += $(COMPAT_CFLAGS)
     + LIB_OBJS += $(COMPAT_OBJS)
      @@ Makefile: perf: all
       t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o
       


 Makefile | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index b31ecb0756..a828a66f28 100644
--- a/Makefile
+++ b/Makefile
@@ -2503,7 +2503,9 @@ endif
 #
 # where we use it as a dependency. Since we also pull object files
 # from the dependency list, that would make each entry appear twice.
-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
+# Archives from $^ come first, then the rest with those archives
+# filtered out so each appears only once.
+LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))
 
 BASIC_CFLAGS += $(COMPAT_CFLAGS)
 LIB_OBJS += $(COMPAT_OBJS)
@@ -3392,7 +3394,7 @@ perf: all
 t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o
 
 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)
 
 check-sha1:: t/helper/test-tool$X
 	t/helper/test-sha1.sh
@@ -4015,13 +4017,13 @@ fuzz-all: $(FUZZ_PROGRAMS)
 $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS
 	$(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \
 		-Wl,--allow-multiple-definition \
-		$(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
+		$(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
 
 $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_OBJS) \
 	$(GITLIBS) GIT-LDFLAGS
 	$(call mkdir_p_parent_template)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
-		$(filter %.o,$^) $(filter %.a,$^) $(LIBS)
+		$(filter %.o,$^) $(LIBS)
 
 GIT-TEST-SUITES: FORCE
 	@FLAGS='$(CLAR_TEST_SUITES)'; \

base-commit: 9ac3f193c05c2237e2b14ebaa1149e9fc8a1abe0
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them
  2026-06-04 22:03 ` [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them Harald Nordgren via GitGitGadget
@ 2026-06-10 13:24   ` Harald Nordgren
  2026-06-19  8:00   ` Harald Nordgren
  2026-06-19 20:32   ` [PATCH v3] config.mak.uname: avoid macOS dup-library warning Harald Nordgren via GitGitGadget
  2 siblings, 0 replies; 12+ messages in thread
From: Harald Nordgren @ 2026-06-10 13:24 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Harald Nordgren via GitGitGadget

Hi Johannes!

Maybe this could be interesting for you to look at too.



Harald

On Fri, Jun 5, 2026 at 12:03 AM Harald Nordgren via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> A handful of link recipes listed archive files twice: once explicitly
> via $(filter %.a,$^) and again implicitly through $(LIBS), which
> expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the
> linker warned about the duplicates:
>
>   ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'
>
> Redefine $(LIBS) to list archive prerequisites from $^ first, then
> the rest of the library list with those archives filtered out so each
> appears only once.
>
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---
>     Makefile: drop duplicate %.a from test-helper link rule
>
>     Redefine $(LIBS) to list archive prerequisites from $^ first, then the
>     rest of the library list to avoid brittleness in the future.
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v2
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v2
> Pull-Request: https://github.com/git/git/pull/2314
>
> Range-diff vs v1:
>
>  1:  f6166450b0 ! 1:  0ef442ea05 Makefile: drop duplicate %.a from link recipes
>      @@ Metadata
>       Author: Harald Nordgren <haraldnordgren@gmail.com>
>
>        ## Commit message ##
>      -    Makefile: drop duplicate %.a from link recipes
>      +    Makefile: dedup archives in $(LIBS) so link recipes don't repeat them
>
>      -    Three link recipes list archive files twice on the link line: once
>      -    via $(filter %.a,$^) and again through $(LIBS), which expands to
>      -    $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the linker warns
>      -    about the duplicates:
>      +    A handful of link recipes listed archive files twice: once explicitly
>      +    via $(filter %.a,$^) and again implicitly through $(LIBS), which
>      +    expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the
>      +    linker warned about the duplicates:
>
>             ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'
>
>      -    Drop the redundant filter from the test-helper, fuzz-program, and
>      -    unit-test recipes so they match the pattern used by other link
>      -    recipes in the file.
>      +    Redefine $(LIBS) to list archive prerequisites from $^ first, then
>      +    the rest of the library list with those archives filtered out so each
>      +    appears only once.
>
>           Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
>
>        ## Makefile ##
>      +@@ Makefile: endif
>      + #
>      + # where we use it as a dependency. Since we also pull object files
>      + # from the dependency list, that would make each entry appear twice.
>      +-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
>      ++# Archives from $^ come first, then the rest with those archives
>      ++# filtered out so each appears only once.
>      ++LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))
>      +
>      + BASIC_CFLAGS += $(COMPAT_CFLAGS)
>      + LIB_OBJS += $(COMPAT_OBJS)
>       @@ Makefile: perf: all
>        t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o
>
>
>
>  Makefile | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index b31ecb0756..a828a66f28 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2503,7 +2503,9 @@ endif
>  #
>  # where we use it as a dependency. Since we also pull object files
>  # from the dependency list, that would make each entry appear twice.
> -LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
> +# Archives from $^ come first, then the rest with those archives
> +# filtered out so each appears only once.
> +LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))
>
>  BASIC_CFLAGS += $(COMPAT_CFLAGS)
>  LIB_OBJS += $(COMPAT_OBJS)
> @@ -3392,7 +3394,7 @@ perf: all
>  t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o
>
>  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)
>
>  check-sha1:: t/helper/test-tool$X
>         t/helper/test-sha1.sh
> @@ -4015,13 +4017,13 @@ fuzz-all: $(FUZZ_PROGRAMS)
>  $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS
>         $(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \
>                 -Wl,--allow-multiple-definition \
> -               $(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
> +               $(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
>
>  $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_OBJS) \
>         $(GITLIBS) GIT-LDFLAGS
>         $(call mkdir_p_parent_template)
>         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
> -               $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
> +               $(filter %.o,$^) $(LIBS)
>
>  GIT-TEST-SUITES: FORCE
>         @FLAGS='$(CLAR_TEST_SUITES)'; \
>
> base-commit: 9ac3f193c05c2237e2b14ebaa1149e9fc8a1abe0
> --
> gitgitgadget

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them
  2026-06-04 22:03 ` [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them Harald Nordgren via GitGitGadget
  2026-06-10 13:24   ` Harald Nordgren
@ 2026-06-19  8:00   ` Harald Nordgren
  2026-06-19 15:41     ` Junio C Hamano
  2026-06-19 20:32   ` [PATCH v3] config.mak.uname: avoid macOS dup-library warning Harald Nordgren via GitGitGadget
  2 siblings, 1 reply; 12+ messages in thread
From: Harald Nordgren @ 2026-06-19  8:00 UTC (permalink / raw)
  To: Harald Nordgren via GitGitGadget; +Cc: git

Hi!

I think this would be quite nice to fix for all the macOS developers
(I don't know how many we have who are active on this list), but when
running repeated tests it does take up some space on the terminal:

````
❯ git rebase --keep-base -x 'make -s && cd t && prove -j8
t345?-history*.sh && echo'

Executing: make -s && cd t && prove -j8 t345?-history*.sh && echo
GIT_VERSION=2.55.0.rc1.20.g1e31474ef6
ld: warning: ignoring duplicate libraries: 'libgit.a',
'target/release/libgitcore.a'
ld: warning: ignoring duplicate libraries: 'libgit.a',
'target/release/libgitcore.a'
t3450-history.sh ......... ok
t3453-history-fixup.sh ... ok
t3451-history-reword.sh .. ok
t3452-history-split.sh ... ok
All tests successful.
Files=4, Tests=69,  7 wallclock secs ( 0.02 usr  0.01 sys +  4.14 cusr
 5.39 csys =  9.56 CPU)
Result: PASS

Executing: make -s && cd t && prove -j8 t345?-history*.sh && echo
GIT_VERSION=2.55.0.rc1.21.g498da64046
ld: warning: ignoring duplicate libraries: 'libgit.a',
'target/release/libgitcore.a'
ld: warning: ignoring duplicate libraries: 'libgit.a',
'target/release/libgitcore.a'
t3450-history.sh ......... ok
t3453-history-fixup.sh ... ok
t3451-history-reword.sh .. ok
t3452-history-split.sh ... ok
All tests successful.
Files=4, Tests=69,  7 wallclock secs ( 0.02 usr  0.01 sys +  4.16 cusr
 5.41 csys =  9.60 CPU)
Result: PASS

Executing: make -s && cd t && prove -j8 t345?-history*.sh && echo
GIT_VERSION=2.55.0.rc1.22.g0050368e96
ld: warning: ignoring duplicate libraries: 'libgit.a',
'target/release/libgitcore.a'
ld: warning: ignoring duplicate libraries: 'libgit.a',
'target/release/libgitcore.a'
t3450-history.sh ......... ok
t3455-history-squash.sh .. ok
t3453-history-fixup.sh ... ok
t3451-history-reword.sh .. ok
t3452-history-split.sh ... ok
All tests successful.
Files=5, Tests=86,  7 wallclock secs ( 0.03 usr  0.01 sys +  4.89 cusr
 6.36 csys = 11.29 CPU)
Result: PASS

Executing: make -s && cd t && prove -j8 t345?-history*.sh && echo
GIT_VERSION=2.55.0.rc1.23.gb86b93bda1
ld: warning: ignoring duplicate libraries: 'libgit.a',
'target/release/libgitcore.a'
ld: warning: ignoring duplicate libraries: 'libgit.a',
'target/release/libgitcore.a'
t3450-history.sh ......... ok
t3455-history-squash.sh .. ok
t3453-history-fixup.sh ... ok
t3451-history-reword.sh .. ok
t3452-history-split.sh ... ok
All tests successful.
Files=5, Tests=88,  7 wallclock secs ( 0.03 usr  0.01 sys +  5.01 cusr
 6.54 csys = 11.59 CPU)
Result: PASS

Successfully rebased and updated refs/heads/rebase-fixup-fold.
```


Harald

On Fri, Jun 5, 2026 at 12:03 AM Harald Nordgren via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> A handful of link recipes listed archive files twice: once explicitly
> via $(filter %.a,$^) and again implicitly through $(LIBS), which
> expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the
> linker warned about the duplicates:
>
>   ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'
>
> Redefine $(LIBS) to list archive prerequisites from $^ first, then
> the rest of the library list with those archives filtered out so each
> appears only once.
>
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---
>     Makefile: drop duplicate %.a from test-helper link rule
>
>     Redefine $(LIBS) to list archive prerequisites from $^ first, then the
>     rest of the library list to avoid brittleness in the future.
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v2
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v2
> Pull-Request: https://github.com/git/git/pull/2314
>
> Range-diff vs v1:
>
>  1:  f6166450b0 ! 1:  0ef442ea05 Makefile: drop duplicate %.a from link recipes
>      @@ Metadata
>       Author: Harald Nordgren <haraldnordgren@gmail.com>
>
>        ## Commit message ##
>      -    Makefile: drop duplicate %.a from link recipes
>      +    Makefile: dedup archives in $(LIBS) so link recipes don't repeat them
>
>      -    Three link recipes list archive files twice on the link line: once
>      -    via $(filter %.a,$^) and again through $(LIBS), which expands to
>      -    $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the linker warns
>      -    about the duplicates:
>      +    A handful of link recipes listed archive files twice: once explicitly
>      +    via $(filter %.a,$^) and again implicitly through $(LIBS), which
>      +    expanded to $(filter-out %.o,$(GITLIBS)) $(EXTLIBS). On macOS the
>      +    linker warned about the duplicates:
>
>             ld: warning: ignoring duplicate libraries: 'libgit.a', 'target/release/libgitcore.a'
>
>      -    Drop the redundant filter from the test-helper, fuzz-program, and
>      -    unit-test recipes so they match the pattern used by other link
>      -    recipes in the file.
>      +    Redefine $(LIBS) to list archive prerequisites from $^ first, then
>      +    the rest of the library list with those archives filtered out so each
>      +    appears only once.
>
>           Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
>
>        ## Makefile ##
>      +@@ Makefile: endif
>      + #
>      + # where we use it as a dependency. Since we also pull object files
>      + # from the dependency list, that would make each entry appear twice.
>      +-LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
>      ++# Archives from $^ come first, then the rest with those archives
>      ++# filtered out so each appears only once.
>      ++LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))
>      +
>      + BASIC_CFLAGS += $(COMPAT_CFLAGS)
>      + LIB_OBJS += $(COMPAT_OBJS)
>       @@ Makefile: perf: all
>        t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o
>
>
>
>  Makefile | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index b31ecb0756..a828a66f28 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2503,7 +2503,9 @@ endif
>  #
>  # where we use it as a dependency. Since we also pull object files
>  # from the dependency list, that would make each entry appear twice.
> -LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
> +# Archives from $^ come first, then the rest with those archives
> +# filtered out so each appears only once.
> +LIBS = $(filter %.a,$^) $(filter-out $(filter %.a,$^),$(filter-out %.o,$(GITLIBS)) $(EXTLIBS))
>
>  BASIC_CFLAGS += $(COMPAT_CFLAGS)
>  LIB_OBJS += $(COMPAT_OBJS)
> @@ -3392,7 +3394,7 @@ perf: all
>  t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o
>
>  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)
>
>  check-sha1:: t/helper/test-tool$X
>         t/helper/test-sha1.sh
> @@ -4015,13 +4017,13 @@ fuzz-all: $(FUZZ_PROGRAMS)
>  $(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS
>         $(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \
>                 -Wl,--allow-multiple-definition \
> -               $(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
> +               $(filter %.o,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
>
>  $(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_OBJS) \
>         $(GITLIBS) GIT-LDFLAGS
>         $(call mkdir_p_parent_template)
>         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
> -               $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
> +               $(filter %.o,$^) $(LIBS)
>
>  GIT-TEST-SUITES: FORCE
>         @FLAGS='$(CLAR_TEST_SUITES)'; \
>
> base-commit: 9ac3f193c05c2237e2b14ebaa1149e9fc8a1abe0
> --
> gitgitgadget

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them
  2026-06-19  8:00   ` Harald Nordgren
@ 2026-06-19 15:41     ` Junio C Hamano
  2026-06-19 20:25       ` Harald Nordgren
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2026-06-19 15:41 UTC (permalink / raw)
  To: Harald Nordgren; +Cc: Harald Nordgren via GitGitGadget, git

Harald Nordgren <haraldnordgren@gmail.com> writes:

> I think this would be quite nice to fix for all the macOS developers
> (I don't know how many we have who are active on this list), but when
> running repeated tests it does take up some space on the terminal:
>
> ````
> ❯ git rebase --keep-base -x 'make -s && cd t && prove -j8
> t345?-history*.sh && echo'
>
> Executing: make -s && cd t && prove -j8 t345?-history*.sh && echo
> GIT_VERSION=2.55.0.rc1.20.g1e31474ef6
> ld: warning: ignoring duplicate libraries: 'libgit.a',
> 'target/release/libgitcore.a'
> ld: warning: ignoring duplicate libraries: 'libgit.a',
> 'target/release/libgitcore.a'

While I am very sympathetic that it may be annoying, I have to
wonder if that is ultimately the linker's job to accept the same
library listed twice on the same command line, deside when it can
ignore the second one, and *silently* ignore it.

Imagine this situation.

 - There are two library archives, libA.a has a.o in it and libB.a
   has b.o in it, respectively.

 - The object file a.o defines a symbol that b.o needs, and b.o
   defines a symbol a.o needs (i.e., mutually dependent). libA.a and
   libB.a have other symbols in them. There are valid reasons why we
   do not want to combine them into a single libAB.a.

 - Now our program X uses both libraries and we build and try to link it this way:

   $(CC) -c x.c				# this builds x.o
   $(CC) -o programX x.o libA.a libB.a  # unfortunately does not work as-is

   which fails because x.o uses symbol from libA.a that is not in
   a.o (so a.o is not linked), and then x.o also uses something in
   b.o that is picked up from libB.a.  But b.o in turn needs a.o
   that we already skipped.  One way to make it work is to tweak the
   final link phase to read like this:

   $(CC) -o programX x.o libA.a libB.a libA.a

If your linker complains because we list libA.a twice, it would be
annoying.

I guess if we can assume GNU ld (e.g., gcc/clang), we can use

   $(CC) -o programX x.o -Wl,--start-group libA.a libB.a -Wl,end-group

to tell the linker that they need to be processed for circular
dependencies, but listing them twice is more portable and harmless
(i.e., if all the symbols are resolved by the time the linker sees
the second libA.a, then it would not pick up anything extra from
there) way to achieve the same thing.  

So from future-proofing and portability perspective (which is
another way to say maintainability we care about), I would very much
prefer to see this solved at the linker level, allowing the build
procedure to list the same library twice on the command line.

It seems that on the Internet various folks, including masonbuild
and CMake, have heard complaints from users enough and fixed the
linker by using -no_warn_duplicate_libraries option.  Their approach
translates to something like the following in our build environment.

 config.mak.uname | 4 ++++
 1 file changed, 4 insertions(+)

diff --git i/config.mak.uname w/config.mak.uname
index 8719e09f66..e29eaaf3fd 100644
--- i/config.mak.uname
+++ w/config.mak.uname
@@ -149,6 +149,10 @@ ifeq ($(uname_S),Darwin)
         ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 20 && echo 1),1)
 		OPEN_RETURNS_EINTR = UnfortunatelyYes
         endif
+
+	# NEEDSWORK: do this only for XCode 15 or later
+	BASIC_LDFLAGS += -Wl,-no_warn_duplicate_libraries
+
 	NO_MEMMEM = YesPlease
 	USE_ST_TIMESPEC = YesPlease
 	HAVE_DEV_TTY = YesPlease

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them
  2026-06-19 15:41     ` Junio C Hamano
@ 2026-06-19 20:25       ` Harald Nordgren
  0 siblings, 0 replies; 12+ messages in thread
From: Harald Nordgren @ 2026-06-19 20:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Harald Nordgren via GitGitGadget, git

Thanks for a good lesson about linkers!

Good idea to fix it through the same LD_MAJOR_VERSION as we did for
the __DATA,__common alignment, makes it a lot cleaner.


Harald

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] config.mak.uname: avoid macOS dup-library warning
  2026-06-04 22:03 ` [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them Harald Nordgren via GitGitGadget
  2026-06-10 13:24   ` Harald Nordgren
  2026-06-19  8:00   ` Harald Nordgren
@ 2026-06-19 20:32   ` Harald Nordgren via GitGitGadget
  2026-06-19 22:27     ` Junio C Hamano
  2 siblings, 1 reply; 12+ messages in thread
From: Harald Nordgren via GitGitGadget @ 2026-06-19 20:32 UTC (permalink / raw)
  To: git; +Cc: Harald Nordgren, Harald Nordgren

From: Harald Nordgren <haraldnordgren@gmail.com>

Building on macOS with Xcode 15 or newer emits:

    ld: warning: ignoring duplicate libraries: 'libgit.a',
    'target/release/libgitcore.a'

Some link recipes list the same archive twice, which is harmless.
Quiet the warning instead.

Pass -Wl,-no_warn_duplicate_libraries on Xcode 15 and newer, whose
linkers added both the warning and the suppression flag (ld64-907
and dyld-1009). Earlier linkers reject the flag, so gate on the
linker version. Broaden the existing -fno-common version probe to
also match the "ld64-NNN" and "dyld-NNN" forms Xcode 15 reports.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
---
    Makefile: drop duplicate %.a from test-helper link rule
    
    Fix warning of duplicate libraries on macOS.
    
    Changes in v3:
    
     * Suppress the warning at the linker rather than dedup the archive list
     * Pass -Wl,-no_warn_duplicate_libraries in config.mak.uname, gated on
       the linker version (reuses the probe added for -fno-common), and
       broaden the regex to match all three PROJECT:{ld64,dyld,ld}-NNN forms
     * Floor of 907 and the version forms (ld64-907, dyld-1009.5) per meson:
       https://github.com/mesonbuild/meson/blob/master/mesonbuild/linkers/linkers.py

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2314%2FHaraldNordgren%2Fmakefile-test-helper-dedup-libs-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2314/HaraldNordgren/makefile-test-helper-dedup-libs-v3
Pull-Request: https://github.com/git/git/pull/2314

Range-diff vs v2:

 1:  0ef442ea05 < -:  ---------- Makefile: dedup archives in $(LIBS) so link recipes don't repeat them
 -:  ---------- > 1:  5bf560c5ad config.mak.uname: avoid macOS dup-library warning


 config.mak.uname | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index 8719e09f66..9ebd240378 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -173,8 +173,15 @@ ifeq ($(uname_S),Darwin)
 		NEEDS_GOOD_LIBICONV = UnfortunatelyYes
         endif
 
-	# Silence Xcode 16.3+ linker warning about __DATA,__common alignment.
-	LD_MAJOR_VERSION = $(shell ld -v 2>&1 | sed -n 's/.*PROJECT:ld-\([0-9]*\).*/\1/p')
+	# ld reports "PROJECT:{ld,ld64,dyld}-NNN", match any of the three.
+	LD_MAJOR_VERSION = $(shell ld -v 2>&1 | sed -n 's/.*PROJECT:[^ ]*-\([0-9][0-9]*\).*/\1/p')
+
+	# Silence the Xcode 15+ warning about archives listed more than once.
+        ifeq ($(shell test -n "$(LD_MAJOR_VERSION)" && test "$(LD_MAJOR_VERSION)" -ge 907 && echo 1),1)
+		BASIC_LDFLAGS += -Wl,-no_warn_duplicate_libraries
+        endif
+
+	# Silence the Xcode 16.3+ warning about __DATA,__common alignment.
         ifeq ($(shell test -n "$(LD_MAJOR_VERSION)" && test "$(LD_MAJOR_VERSION)" -ge 1167 && echo 1),1)
 		BASIC_CFLAGS += -fno-common
         endif

base-commit: 95e20213faefeb95df29277c58ac1980ab68f701
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning
  2026-06-19 20:32   ` [PATCH v3] config.mak.uname: avoid macOS dup-library warning Harald Nordgren via GitGitGadget
@ 2026-06-19 22:27     ` Junio C Hamano
  2026-06-20 20:58       ` D. Ben Knoble
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2026-06-19 22:27 UTC (permalink / raw)
  To: Harald Nordgren via GitGitGadget; +Cc: git, Harald Nordgren

"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> Building on macOS with Xcode 15 or newer emits:
>
>     ld: warning: ignoring duplicate libraries: 'libgit.a',
>     'target/release/libgitcore.a'
>
> Some link recipes list the same archive twice, which is harmless.
> Quiet the warning instead.
>
> Pass -Wl,-no_warn_duplicate_libraries on Xcode 15 and newer, whose
> linkers added both the warning and the suppression flag (ld64-907
> and dyld-1009). Earlier linkers reject the flag, so gate on the
> linker version. Broaden the existing -fno-common version probe to
> also match the "ld64-NNN" and "dyld-NNN" forms Xcode 15 reports.
>
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---

Yeah, this looks like what I expected.

A few things to note.

 * Can folks with different versions of Xcode (or is 15 sufficiently
   old that practically nobody is expected to have anything older?)
   test this patch?

 * We only patch Makefile here; can folks who use meson report how
   well your build goes?

Thanks.

>  config.mak.uname | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/config.mak.uname b/config.mak.uname
> index 8719e09f66..9ebd240378 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -173,8 +173,15 @@ ifeq ($(uname_S),Darwin)
>  		NEEDS_GOOD_LIBICONV = UnfortunatelyYes
>          endif
>  
> -	# Silence Xcode 16.3+ linker warning about __DATA,__common alignment.
> -	LD_MAJOR_VERSION = $(shell ld -v 2>&1 | sed -n 's/.*PROJECT:ld-\([0-9]*\).*/\1/p')
> +	# ld reports "PROJECT:{ld,ld64,dyld}-NNN", match any of the three.
> +	LD_MAJOR_VERSION = $(shell ld -v 2>&1 | sed -n 's/.*PROJECT:[^ ]*-\([0-9][0-9]*\).*/\1/p')
> +
> +	# Silence the Xcode 15+ warning about archives listed more than once.
> +        ifeq ($(shell test -n "$(LD_MAJOR_VERSION)" && test "$(LD_MAJOR_VERSION)" -ge 907 && echo 1),1)
> +		BASIC_LDFLAGS += -Wl,-no_warn_duplicate_libraries
> +        endif
> +
> +	# Silence the Xcode 16.3+ warning about __DATA,__common alignment.
>          ifeq ($(shell test -n "$(LD_MAJOR_VERSION)" && test "$(LD_MAJOR_VERSION)" -ge 1167 && echo 1),1)
>  		BASIC_CFLAGS += -fno-common
>          endif
>
> base-commit: 95e20213faefeb95df29277c58ac1980ab68f701

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] config.mak.uname: avoid macOS dup-library warning
  2026-06-19 22:27     ` Junio C Hamano
@ 2026-06-20 20:58       ` D. Ben Knoble
  0 siblings, 0 replies; 12+ messages in thread
From: D. Ben Knoble @ 2026-06-20 20:58 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Harald Nordgren via GitGitGadget, git, Harald Nordgren

On Fri, Jun 19, 2026 at 6:27 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Harald Nordgren <haraldnordgren@gmail.com>
> >
> > Building on macOS with Xcode 15 or newer emits:
> >
> >     ld: warning: ignoring duplicate libraries: 'libgit.a',
> >     'target/release/libgitcore.a'
> >
> > Some link recipes list the same archive twice, which is harmless.
> > Quiet the warning instead.
> >
> > Pass -Wl,-no_warn_duplicate_libraries on Xcode 15 and newer, whose
> > linkers added both the warning and the suppression flag (ld64-907
> > and dyld-1009). Earlier linkers reject the flag, so gate on the
> > linker version. Broaden the existing -fno-common version probe to
> > also match the "ld64-NNN" and "dyld-NNN" forms Xcode 15 reports.
> >
> > Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> > ---
>
> Yeah, this looks like what I expected.
>
> A few things to note.
>
>  * Can folks with different versions of Xcode (or is 15 sufficiently
>    old that practically nobody is expected to have anything older?)
>    test this patch?
>
>  * We only patch Makefile here; can folks who use meson report how
>    well your build goes?
>
> Thanks.

On one (old) machine I have available:

    $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
    [trimmed]
    version: 14.2.0.0.1.1668646533

On said machine, I don't get the duplicate warnings on a Meson build.
No issues with the patch when running make.

I think I have seen this on my other machine, which is much newer.
When I get around to trying it there, I'll report back as well.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-06-20 20:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-31 23:16 [PATCH] Makefile: drop duplicate %.a from link recipes Harald Nordgren via GitGitGadget
2026-06-04  0:33 ` Junio C Hamano
2026-06-04  7:06   ` Harald Nordgren
2026-06-04  7:15     ` Harald Nordgren
2026-06-04 22:03 ` [PATCH v2] Makefile: dedup archives in $(LIBS) so link recipes don't repeat them Harald Nordgren via GitGitGadget
2026-06-10 13:24   ` Harald Nordgren
2026-06-19  8:00   ` Harald Nordgren
2026-06-19 15:41     ` Junio C Hamano
2026-06-19 20:25       ` Harald Nordgren
2026-06-19 20:32   ` [PATCH v3] config.mak.uname: avoid macOS dup-library warning Harald Nordgren via GitGitGadget
2026-06-19 22:27     ` Junio C Hamano
2026-06-20 20:58       ` D. Ben Knoble

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox