Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: fix dependency for $(UNIT_TEST_DIR)/clar/clar.o #1810

Closed

Conversation

phil-blain
Copy link

@phil-blain phil-blain commented Oct 7, 2024

v2:
Compared to v1, I just moved the new line one line up
to keep the dependencies of $(CLAR_TEST_OBJS) together.

Regarding what I wrote in [1], I took a closer look and
actually clar.suite is already added to GENERATED_H.
The issue really is that for generated headers, the dependency
must be specified manually. This is the case for other generated
headers (command-list.h, etc). So my initial approach is correct.

[1] https://lore.kernel.org/git/C05B01E0-5007-4FB9-94CD-CBE74E79F9B7@gmail.com/

v1:
Hi Patrick,

I tried building v2.47.0 and stumbled onto this small issue. It reproduces for me from a fresh clone on my old 2009 Mac with make -j -l 2.5, it's a little curious that no one ran into this yet.

I found it best to declare the dependency directly on clar.o, instead of adjusting the dependencies of CLAR_TEST_OBJS on the line above, since it is really only this clar.c that includes clar.suite

CC: Patrick Steinhardt ps@pks.im
cc: Philippe Blain levraiphilippeblain@gmail.com
cc: Taylor Blau me@ttaylorr.com

@phil-blain
Copy link
Author

/submit

Copy link

gitgitgadget bot commented Oct 7, 2024

Submitted as pull.1810.git.1728323033680.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1810/phil-blain/clar-build-dep-fix-v1

To fetch this version to local tag pr-1810/phil-blain/clar-build-dep-fix-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1810/phil-blain/clar-build-dep-fix-v1

Copy link

gitgitgadget bot commented Oct 8, 2024

On the Git mailing list, Junio C Hamano wrote (reply to this):

"Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Philippe Blain <levraiphilippeblain@gmail.com>
>
> The clar source file '$(UNIT_TEST_DIR)/clar/clar.c' includes the
> generated 'clar.suite', but this dependency is not taken into account by
> our Makefile, so that it is possible for a parallel build to fail if
> Make tries to build 'clar.o' before 'clar.suite' is generated.
>
> Correctly specify the dependency.
>
> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
> ---
>     Makefile: fix dependency for $(UNIT_TEST_DIR)/clar/clar.o
>     
>     Hi Patrick,
>     
>     I tried building v2.47.0 and stumbled onto this small issue. It
>     reproduces for me from a fresh clone on my old 2009 Mac with make -j -l
>     2.5, it's a little curious that no one ran into this yet.

I suspect that nobody tells make to build clar.o (and nothing else).

Instead, the t/unit-tests/bin/unit-tests target is what is typically
built, which is part of $(CLAR_TEST_PROG) that has clar.suite as one
of its dependencies.

    $ make
    $ rm -f t/unit-tests/clar.suite t/unit-tests/clar/clar.o
    $ make -j1 t/unit-tests/bin/unit-tests
    GEN t/unit-tests/clar.suite
    CC t/unit-tests/clar/clar.o
    LINK t/unit-tests/bin/unit-tests

What is possible to happen from the broken dependencies is when I
did not remove clar.o in the above experiment.  We may rebuild
clar.suite and then link clar.o that is outdated without realizing.

>     I found it best to declare the dependency directly on clar.o, instead of
>     adjusting the dependencies of CLAR_TEST_OBJS on the line above, since it
>     is really only this clar.c that includes clar.suite
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1810%2Fphil-blain%2Fclar-build-dep-fix-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1810/phil-blain/clar-build-dep-fix-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1810
>
>  Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/Makefile b/Makefile
> index 2dde1fd2b8b..b615de74811 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -3911,6 +3911,7 @@ $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUI
>  $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h
>  	$(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite
>  $(CLAR_TEST_OBJS): $(UNIT_TEST_DIR)/clar-decls.h
> +$(UNIT_TEST_DIR)/clar/clar.o: $(UNIT_TEST_DIR)/clar.suite
>  $(CLAR_TEST_OBJS): EXTRA_CPPFLAGS = -I$(UNIT_TEST_DIR)
>  $(CLAR_TEST_PROG): $(UNIT_TEST_DIR)/clar.suite $(CLAR_TEST_OBJS) $(GITLIBS) GIT-LDFLAGS
>  	$(call mkdir_p_parent_template)
>
> base-commit: 777489f9e09c8d0dd6b12f9d90de6376330577a2

Copy link

gitgitgadget bot commented Oct 8, 2024

On the Git mailing list, Patrick Steinhardt wrote (reply to this):

On Mon, Oct 07, 2024 at 05:53:41PM -0700, Junio C Hamano wrote:
> "Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> > From: Philippe Blain <levraiphilippeblain@gmail.com>
> >
> > The clar source file '$(UNIT_TEST_DIR)/clar/clar.c' includes the
> > generated 'clar.suite', but this dependency is not taken into account by
> > our Makefile, so that it is possible for a parallel build to fail if
> > Make tries to build 'clar.o' before 'clar.suite' is generated.
> >
> > Correctly specify the dependency.
> >
> > Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
> > ---
> >     Makefile: fix dependency for $(UNIT_TEST_DIR)/clar/clar.o
> >     
> >     Hi Patrick,
> >     
> >     I tried building v2.47.0 and stumbled onto this small issue. It
> >     reproduces for me from a fresh clone on my old 2009 Mac with make -j -l
> >     2.5, it's a little curious that no one ran into this yet.
> 
> I suspect that nobody tells make to build clar.o (and nothing else).
> 
> Instead, the t/unit-tests/bin/unit-tests target is what is typically
> built, which is part of $(CLAR_TEST_PROG) that has clar.suite as one
> of its dependencies.
> 
>     $ make
>     $ rm -f t/unit-tests/clar.suite t/unit-tests/clar/clar.o
>     $ make -j1 t/unit-tests/bin/unit-tests
>     GEN t/unit-tests/clar.suite
>     CC t/unit-tests/clar/clar.o
>     LINK t/unit-tests/bin/unit-tests
> 
> What is possible to happen from the broken dependencies is when I
> did not remove clar.o in the above experiment.  We may rebuild
> clar.suite and then link clar.o that is outdated without realizing.

Makes sense. In any case, the fix looks good to me, thanks!

Patrick

Copy link

gitgitgadget bot commented Oct 8, 2024

This patch series was integrated into seen via git@0ba0f9d.

@gitgitgadget gitgitgadget bot added the seen label Oct 8, 2024
Copy link

gitgitgadget bot commented Oct 9, 2024

This branch is now known as pb/clar-build-fix.

Copy link

gitgitgadget bot commented Oct 9, 2024

This patch series was integrated into seen via git@9decb09.

Copy link

gitgitgadget bot commented Oct 9, 2024

This patch series was integrated into seen via git@fac0be3.

Copy link

gitgitgadget bot commented Oct 10, 2024

On the Git mailing list, Philippe Blain wrote (reply to this):

Hi,

I had a closer look at how the header dependencies are handled in the Makefile and I think a cleaner and more idiomatic way to fix the problem would be to add clar.suite to GENERATED_H. 

I’ll try to send a v2 tomorrow so maybe hold on to merging it to next for the moment, Junio. 

Thanks
Philippe. 

> Le 7 oct. 2024 à 23:58, Patrick Steinhardt <ps@pks.im> a écrit :
> 
> On Mon, Oct 07, 2024 at 05:53:41PM -0700, Junio C Hamano wrote:
>> "Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:
>> 
>>> From: Philippe Blain <levraiphilippeblain@gmail.com>
>>> 
>>> The clar source file '$(UNIT_TEST_DIR)/clar/clar.c' includes the
>>> generated 'clar.suite', but this dependency is not taken into account by
>>> our Makefile, so that it is possible for a parallel build to fail if
>>> Make tries to build 'clar.o' before 'clar.suite' is generated.
>>> 
>>> Correctly specify the dependency.
>>> 
>>> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
>>> ---
>>>    Makefile: fix dependency for $(UNIT_TEST_DIR)/clar/clar.o
>>> 
>>>    Hi Patrick,
>>> 
>>>    I tried building v2.47.0 and stumbled onto this small issue. It
>>>    reproduces for me from a fresh clone on my old 2009 Mac with make -j -l
>>>    2.5, it's a little curious that no one ran into this yet.
>> 
>> I suspect that nobody tells make to build clar.o (and nothing else).
>> 
>> Instead, the t/unit-tests/bin/unit-tests target is what is typically
>> built, which is part of $(CLAR_TEST_PROG) that has clar.suite as one
>> of its dependencies.
>> 
>>    $ make
>>    $ rm -f t/unit-tests/clar.suite t/unit-tests/clar/clar.o
>>    $ make -j1 t/unit-tests/bin/unit-tests
>>    GEN t/unit-tests/clar.suite
>>    CC t/unit-tests/clar/clar.o
>>    LINK t/unit-tests/bin/unit-tests
>> 
>> What is possible to happen from the broken dependencies is when I
>> did not remove clar.o in the above experiment.  We may rebuild
>> clar.suite and then link clar.o that is outdated without realizing.
> 
> Makes sense. In any case, the fix looks good to me, thanks!
> 
> Patrick

Copy link

gitgitgadget bot commented Oct 10, 2024

User Philippe Blain <levraiphilippeblain@gmail.com> has been added to the cc: list.

Copy link

gitgitgadget bot commented Oct 10, 2024

On the Git mailing list, Junio C Hamano wrote (reply to this):

Philippe Blain <levraiphilippeblain@gmail.com> writes:

> I had a closer look at how the header dependencies are handled in
> the Makefile and I think a cleaner and more idiomatic way to fix
> the problem would be to add clar.suite to GENERATED_H.

If it is a header file (e.g. we could run "make hdr-check" on it to
make sure it is self-contained, if we wanted to check it), that
sounds like a very appropriate thing to do.

> I’ll try to send a v2 tomorrow so maybe hold on to merging it to
> next for the moment, Junio.

Thanks.

Copy link

gitgitgadget bot commented Oct 10, 2024

This patch series was integrated into seen via git@4a9f863.

Copy link

gitgitgadget bot commented Oct 10, 2024

There was a status update in the "Cooking" section about the branch pb/clar-build-fix on the Git mailing list:

Build fix.

Expecting a reroll.
cf. <C05B01E0-5007-4FB9-94CD-CBE74E79F9B7@gmail.com>
source: <pull.1810.git.1728323033680.gitgitgadget@gmail.com>

The clar source file '$(UNIT_TEST_DIR)/clar/clar.c' includes the
generated 'clar.suite', but this dependency is not taken into account by
our Makefile, so that it is possible for a parallel build to fail if
Make tries to build 'clar.o' before 'clar.suite' is generated.

Correctly specify the dependency.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
@phil-blain
Copy link
Author

/submit

Copy link

gitgitgadget bot commented Oct 11, 2024

Submitted as pull.1810.v2.git.1728667787227.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1810/phil-blain/clar-build-dep-fix-v2

To fetch this version to local tag pr-1810/phil-blain/clar-build-dep-fix-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1810/phil-blain/clar-build-dep-fix-v2

Copy link

gitgitgadget bot commented Oct 11, 2024

This patch series was integrated into seen via git@712f36a.

Copy link

gitgitgadget bot commented Oct 11, 2024

This patch series was integrated into seen via git@6f8ee0e.

Copy link

gitgitgadget bot commented Oct 12, 2024

There was a status update in the "Cooking" section about the branch pb/clar-build-fix on the Git mailing list:

Build fix.

Will merge to 'next'.
source: <pull.1810.v2.git.1728667787227.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Oct 14, 2024

On the Git mailing list, Patrick Steinhardt wrote (reply to this):

On Fri, Oct 11, 2024 at 05:29:47PM +0000, Philippe Blain via GitGitGadget wrote:
> From: Philippe Blain <levraiphilippeblain@gmail.com>
> 
> The clar source file '$(UNIT_TEST_DIR)/clar/clar.c' includes the
> generated 'clar.suite', but this dependency is not taken into account by
> our Makefile, so that it is possible for a parallel build to fail if
> Make tries to build 'clar.o' before 'clar.suite' is generated.
> 
> Correctly specify the dependency.
> 
> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>

Thanks, this version looks good to me.

Patrick

Copy link

gitgitgadget bot commented Oct 14, 2024

This patch series was integrated into seen via git@e4d0535.

Copy link

gitgitgadget bot commented Oct 14, 2024

This patch series was integrated into seen via git@bba4f9d.

Copy link

gitgitgadget bot commented Oct 15, 2024

On the Git mailing list, Taylor Blau wrote (reply to this):

On Mon, Oct 14, 2024 at 01:59:25PM +0200, Patrick Steinhardt wrote:
> On Fri, Oct 11, 2024 at 05:29:47PM +0000, Philippe Blain via GitGitGadget wrote:
> > From: Philippe Blain <levraiphilippeblain@gmail.com>
> >
> > The clar source file '$(UNIT_TEST_DIR)/clar/clar.c' includes the
> > generated 'clar.suite', but this dependency is not taken into account by
> > our Makefile, so that it is possible for a parallel build to fail if
> > Make tries to build 'clar.o' before 'clar.suite' is generated.
> >
> > Correctly specify the dependency.
> >
> > Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
>
> Thanks, this version looks good to me.

Thanks, both. Junio had already marked this one to merge to 'next', so I
will go ahead and merge it down in the next integration cycle (which
should be tomorrow, assuming I remember how to do it correctly).

Thanks,
Taylor

Copy link

gitgitgadget bot commented Oct 15, 2024

User Taylor Blau <me@ttaylorr.com> has been added to the cc: list.

Copy link

gitgitgadget bot commented Oct 16, 2024

This patch series was integrated into seen via git@9029bc8.

Copy link

gitgitgadget bot commented Oct 18, 2024

This patch series was integrated into seen via git@8a17d45.

Copy link

gitgitgadget bot commented Oct 18, 2024

This patch series was integrated into next via git@ae6e80b.

@gitgitgadget gitgitgadget bot added the next label Oct 18, 2024
Copy link

gitgitgadget bot commented Oct 18, 2024

This patch series was integrated into seen via git@36bbd9f.

Copy link

gitgitgadget bot commented Oct 21, 2024

This patch series was integrated into seen via git@8a8efad.

Copy link

gitgitgadget bot commented Oct 22, 2024

This patch series was integrated into seen via git@d954ba7.

@satmandu
Copy link

Any chance you could use this to fix the cmake buildsystem as well in contrib/buildsystems? The claro changes broke it... when using cmake and a builddir...

@satmandu
Copy link

FYI the claro changes in 2.47.0 causing an out of tree/builddir based cmake build to break can be fixed with this:

--- a/contrib/buildsystems/CMakeLists.txt	2024-10-23 14:51:53.474906768 -0400
+++ b/contrib/buildsystems/CMakeLists.txt	2024-10-23 14:52:24.263046592 -0400
@@ -1036,8 +1036,8 @@ string(APPEND clar_suites
 	"};\n"
 	"static const size_t _clar_suite_count = ${clar_suites_count};\n"
 	"static const size_t _clar_callback_count = ${clar_cbs_count};\n")
-file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h" "${clar_decls}")
-file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite" "${clar_decls}" "${clar_cbs}" "${clar_suites}")
+file(WRITE "${CMAKE_SOURCE_DIR}/t/unit-tests/clar-decls.h" "${clar_decls}")
+file(WRITE "${CMAKE_SOURCE_DIR}/t/unit-tests/clar.suite" "${clar_decls}" "${clar_cbs}" "${clar_suites}")
 
 list(TRANSFORM clar_test_SUITES PREPEND "${CMAKE_SOURCE_DIR}/t/unit-tests/")
 list(TRANSFORM clar_test_SUITES APPEND ".c")

Copy link

gitgitgadget bot commented Oct 23, 2024

This patch series was integrated into seen via git@49c22e3.

@dscho
Copy link
Member

dscho commented Oct 24, 2024

Any chance you could use this to fix the cmake buildsystem as well in contrib/buildsystems? The claro changes broke it... when using cmake and a builddir...

@satmandu Thank you for reporting a bug. However, this is not the place the Git projects expects bug reports: please send it instead to the Git mailing list. See https://git-scm.com/community for more details.

@phil-blain
Copy link
Author

In fact, what you report is already fixed by this patch, from what I understand: https://lore.kernel.org/git/bb005979e7eb335b0178094251b5c37682d7d47b.1729506329.git.ps@pks.im/

@satmandu
Copy link

In fact, what you report is already fixed by this patch, from what I understand: https://lore.kernel.org/git/bb005979e7eb335b0178094251b5c37682d7d47b.1729506329.git.ps@pks.im/

Thank you!

I look forward to that being in an upcoming release!

This was our prior bug report, which did get a response. I should have responded to that directly.

https://lore.kernel.org/git/CAGjHeYfyH+cOMYYYHnFR+Vu9T+RbmzO1SpB_-kbmBSf1DitJhA@mail.gmail.com/

Copy link

gitgitgadget bot commented Oct 25, 2024

This patch series was integrated into seen via git@dca32b8.

Copy link

gitgitgadget bot commented Oct 25, 2024

This patch series was integrated into master via git@dca32b8.

Copy link

gitgitgadget bot commented Oct 25, 2024

This patch series was integrated into next via git@dca32b8.

@gitgitgadget gitgitgadget bot added the master label Oct 25, 2024
@gitgitgadget gitgitgadget bot closed this Oct 25, 2024
Copy link

gitgitgadget bot commented Oct 25, 2024

Closed via dca32b8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants