-
Notifications
You must be signed in to change notification settings - Fork 96
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
Conversation
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 <mh@glandium.org> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise the ^{tree} change.
There was a problem hiding this comment.
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 \ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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 \ |
There was a problem hiding this comment.
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 \
[...]
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)"' |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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 <vdye@github.com>
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 <vdye@github.com>
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 <vdye@github.com>
@@ -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 \ |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😁
…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
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Fixes for MacOS release build & build options
Depends on: derrickstolee/git_osx_installer#8
Changes
make dist
to archive theHEAD
commit, rather than theHEAD
tree (preserves commit hash in tar header)GIT_BUILT_FROM_COMMIT
(like e.g.GIT_USER_AGENT
)make dist
archive commit hash asGIT_BUILT_FROM_COMMIT
inbuild-git-installers.yml
hook-list.h
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 releaseTesting
git_osx_installer
Makefile): https://github.com/vdye/git_osx_installer/actions/runs/1531273864build-git-installers
execution: https://github.com/vdye/git/actions/runs/1532263438git version --build-options
, as it relies on the corresponding change ingit_osx_installer
to be merged