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

Fixes for MacOS release build & build options #472

Merged
merged 4 commits into from
Dec 6, 2021
Merged

Fixes for MacOS release build & build options #472

merged 4 commits into from
Dec 6, 2021

Conversation

vdye
Copy link
Collaborator

@vdye vdye commented Dec 2, 2021

Depends on: derrickstolee/git_osx_installer#8

Changes

  • Update make dist to archive the HEAD commit, rather than the HEAD tree (preserves commit hash in tar header)
  • Allow manual specification of GIT_BUILT_FROM_COMMIT (like e.g. GIT_USER_AGENT)
  • Use make dist archive commit hash as GIT_BUILT_FROM_COMMIT in build-git-installers.yml
  • Fix dependency issue with hook-list.h
    • Pulled (early) from upstream
    • Dependency issue only seems to appear consistently on macos-latest - for some reason, macos-10.15 doesn't show the same issue. Regardless, this is a good fix to have in case of a mid-cycle release

Testing

Fix an issue in my cfe853e (hook-list.h: add a generated list of
hooks, like config-list.h, 2021-09-26), the builtin/help.c was
inadvertently made to depend on hook-list.h, but it's used by
builtin/bugreport.c.

The hook.c also does not depend on hook-list.h. It did in an earlier
version of the greater series cfe853e was extracted from, but not
anymore. We might end up needing that line again, but let's remove it
for now.

Reported-by: Mike Hommey <[email protected]>
Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
Copy link
Collaborator

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commits 2 & 3 seem like they are upstreamable, if you are interested.

@@ -2262,21 +2271,19 @@ git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
$(filter %.o,$^) $(LIBS)

help.sp help.s help.o: command-list.h
hook.sp hook.s hook.o: hook-list.h
builtin/bugreport.sp builtin/bugreport.s builtin/bugreport.o: hook-list.h

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what these hook vs bugreport changes are doing here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intentionally pulled in from an upstream commit because of a build error that was (for some reason) only manifesting in make dist on MacOS 11: https://github.com/vdye/git_osx_installer/runs/4387194585?check_suite_focus=true

I included it "early" (rather than letting it naturally show up as part of next release's rebase) because the error caused by incorrect dependencies is blocking to any mid-cycle releases we may want to do. It does have some things not explicitly needed (e.g., the removal of hook-list.h as a dependency of help), but including the full commit seemed clearer.


builtin/help.sp builtin/help.s builtin/help.o: config-list.h hook-list.h GIT-PREFIX
builtin/help.sp builtin/help.s builtin/help.o: config-list.h GIT-PREFIX

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the hook-list change is curious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came with the other hook-list.h in the upstream patch - it's not directly related to the dependency bugfix I wanted out of this commit, but I also didn't want to split the commit (especially because I imagine it'll make its way into git/git master by next release, at which point this should disappear in the rebase).

@@ -3263,7 +3270,7 @@ dist: git-archive$(X) configure
@$(MAKE) -C git-gui TARDIR=../.dist-tmp-dir/git-gui dist-version
./git-archive --format=tar \
$(GIT_ARCHIVE_EXTRA_FILES) \
--prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
--prefix=$(GIT_TARNAME)/ HEAD > $(GIT_TARNAME).tar

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise the ^{tree} change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the ^{tree} makes git archive evaluate with a commit object rather than a tree, which ultimately lets it set the commit hash as a header in the generated .tar file (see the second paragraph here). That header can then be used to set GIT_BUILT_FROM_COMMIT when building from an extracted archive (e.g., in the MacOS build).

Makefile Outdated
@@ -2147,6 +2147,15 @@ GIT-USER-AGENT: FORCE
echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \
fi

GIT_BUILT_FROM_COMMIT = $(shell \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor nit: using := rather than plain = would avoid multiple evals of the sub-shell expression.
not sure it is worth the bother though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't := force the evaluation, even if the variable is not even used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both of you are right. In this case, maybe a deferred single expansion would work (won't evaluate until needed, and only evaluates once)?

GIT_BUILT_FROM_COMMIT = $(eval GIT_BUILT_FROM_COMMIT := $$(shell \
	GIT_CEILING_DIRECTORIES="$$(CURDIR)/.." \
	git rev-parse -q --verify HEAD 2>/dev/null))$(GIT_BUILT_FROM_COMMIT)

CURL_LDFLAGS and CURL_CFLAGS do something similar (context).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But a ?= would only evaluate unless set, right? So if you specify via the command-line, it won't be evaluated. And once evaluated, it is set, and won't evaluate again either.

GIT_CEILING_DIRECTORIES="$(CURDIR)/.." \
git rev-parse -q --verify HEAD 2>/dev/null)
GIT-BUILT-FROM-COMMIT: FORCE
@if test x'$(GIT_BUILT_FROM_COMMIT)' != x"`cat GIT-BUILT-FROM-COMMIT 2>/dev/null`" ; then \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we already have a shell script snippet here, how about moving the assignment of GIT_BUILT_FROM_COMMIT into the GIT-BUILT-FROM-COMMIT rule? Something like:

@GIT_BUILT_FROM_COMMIT="$(GIT_CEILING_DIRECTORIES="$(CURDIR)/.." \
    git rev-parse -q --verify HEAD 2>/dev/null)" && \
if test x"$GIT_BUILT_FROM_COMMIT" != x"`cat GIT-BUILT-FROM-COMMIT 2>/dev/null`" ; then \
[...]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this set GIT_BUILT_FROM_COMMIT as a Makefile variable, or would it only exist local to that target?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a shell variable, local to this target.

'-DGIT_BUILT_FROM_COMMIT="$(shell \
GIT_CEILING_DIRECTORIES="$(CURDIR)/.." \
git rev-parse -q --verify HEAD 2>/dev/null)"'
'-DGIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)"'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we take pains to write that file, the value should probably be read from the file instead of relying on the variable, right?

-DGIT_BUILT_FROM_COMMIT="$(cat GIT-BUILT-FROM-COMMIT)"

But if we do that, we need to change patch 4 to write that file instead of specifying the value in the make invocation.

But maybe the idea was to make GIT_BUILT_FROM_COMMIT overrideable from the command-line? In that case, I would suggest not to write GIT-BUILT-FROM-COMMIT at all, but instead use ?= when defining the variable (which should avoid multiple evaluations, just like the := idea Jeff pointed out).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the file to be written when the OID changes as she in the Makefile to cause Make to later detect that the dependencies are stale and cause version.o to be recompiled, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, but of course! The file is there only to force recompilation if GIT_BUILT_FROM_COMMIT changed...

Copy link
Collaborator Author

@vdye vdye Dec 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was, as you suggested, to make GIT_BUILT_FROM_COMMIT overrideable on the command line. It mimics some of the other overrideable variables (GIT_USER_AGENT, PERL_DEFINES, etc.) in the Makefile, which also a) write to a file, and b) do not read from that file when using the value. My interpretation was that the file is used identify whether the value changed on subsequent builds (the "new built-from commit"), and that the Makefile variable is what's actually used.

Also, this reminded me that I missed something (documentation at the top of the file indicating that GIT_BUILT_FROM_COMMIT is overrideable via the command line).

EDIT: whoops! submitted this without refreshing my page first

Allow specification of a custom `GIT_BUILT_FROM_COMMIT` string to replace
the output of `git rev-parse HEAD`. This allows a build of `git` from
somewhere other than an active clone of `git` (e.g. from the archive created
with `make dist`) to include commit information in
`git version --build-options`.

Signed-off-by: Victoria Dye <[email protected]>
Update `git archive` tree-ish argument from `HEAD^{tree}` to `HEAD`. By
using a commit (rather than tree) reference, the commit hash will be stored
as an extended pax header, extractable git `git get-tar-commit-id`.

The intended use-case for this change is building `git` from the output of
`make dist` - in combination with the ability to specify a fallback
`GIT_BUILT_FROM_COMMIT`, a user can extract the commit ID used to build the
archive and set it as `GIT_BUILT_FROM_COMMIT`. The result is fully-populated
information for the commit hash in `git version --build-options`.

Signed-off-by: Victoria Dye <[email protected]>
Set the `GIT_BUILT_FROM_COMMIT` based on the version specified in the `make
dist` output archive header. This ensures the commit hash is shown in
`git version --build-options`.

Signed-off-by: Victoria Dye <[email protected]>
@@ -2147,6 +2151,15 @@ GIT-USER-AGENT: FORCE
echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \
fi

GIT_BUILT_FROM_COMMIT = $(eval GIT_BUILT_FROM_COMMIT := $$(shell \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a ?= here, to avoid this eval from happening in case the user specified it on the command-line? I.e. like this:

GIT_BUILT_FROM_COMMIT ?= $(shell GIT_CEILING_DIRECTORIES="$(CURDIR)/.." \
    git rev-parse -q --verify HEAD 2>/dev/null)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command line-specified variable will override any = or := assignment for that variable (documentation). I can't infer any "rule" or pattern for when ?= vs. = is used in this Makefile, but the variables most similar to GIT_BUILT_FROM_COMMIT (e.g. GIT_USER_AGENT) use non-conditional assignments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thank you! I thought ?= was the thing to use if one wanted to define some variable that had not yet been defined, but that was not based on reading the documentation 😁

derrickstolee added a commit to derrickstolee/git_osx_installer that referenced this pull request Dec 6, 2021
…tion for installer

Related: microsoft/git#472 

## Changes
- Allow specification of `GIT_BUILT_FROM_COMMIT` as `make` variable when building the MacOS installer package
- Add commit hash to installer build & test step for printing `git version --build-options`

## Testing
- Test installer build (including corresponding changes to `git` Makefile): https://github.com/vdye/git_osx_installer/actions/runs/1531273864
@vdye vdye merged commit f8f08d5 into microsoft:vfs-2.34.0 Dec 6, 2021
@vdye vdye deleted the ms/macos-build-options branch December 6, 2021 16:05
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 12, 2022
Fixes for MacOS release build & build options
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 19, 2022
Fixes for MacOS release build & build options
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 19, 2022
Fixes for MacOS release build & build options
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Fixes for MacOS release build & build options
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Fixes for MacOS release build & build options
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Fixes for MacOS release build & build options
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Fixes for MacOS release build & build options
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Fixes for MacOS release build & build options
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Fixes for MacOS release build & build options
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Aug 8, 2023
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Aug 8, 2023
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Aug 11, 2023
Fixes for MacOS release build & build options
jeffhostetler pushed a commit that referenced this pull request Aug 23, 2023
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Nov 3, 2023
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Nov 3, 2023
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Nov 3, 2023
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Nov 8, 2023
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Nov 14, 2023
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Nov 20, 2023
Fixes for MacOS release build & build options
vdye added a commit that referenced this pull request Feb 27, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Apr 23, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Apr 23, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Apr 23, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Apr 24, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Apr 29, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request May 14, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request May 14, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request May 14, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Jun 3, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Jul 17, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Jul 17, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Jul 17, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Jul 18, 2024
Fixes for MacOS release build & build options
mjcheetham pushed a commit that referenced this pull request Jul 23, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Jul 25, 2024
Fixes for MacOS release build & build options
mjcheetham pushed a commit that referenced this pull request Jul 29, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Sep 18, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Sep 24, 2024
Fixes for MacOS release build & build options
dscho pushed a commit that referenced this pull request Oct 8, 2024
Fixes for MacOS release build & build options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants