version --build-options: also report host CPU

It can be helpful for bug reports to include information about the environment in which the bug occurs. "git version --build-options" can help to supplement this information. In addition to the size of 'long' already reported by --build-options, also report the host's CPU type. Example output: $ git version --build-options git version 2.9.3.windows.2.826.g06c0f2f cpu: x86_64 sizeof-long: 4 New Makefile variable HOST_CPU supports cross-compiling. Suggested-by: Adric Norris <landstander668@gmail.com> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Dec 15, 2017 at 00:34 UTC b22894049ffed57eb150ad156796e3eda86259c9
2 files changed +10
Makefile
+9
@@ -425,6 +425,9 @@ all::
425 #
426 # to say "export LESS=FRX (and LV=-c) if the environment variable
427 # LESS (and LV) is not set, respectively".
428 +#
429 +# When cross-compiling, define HOST_CPU as the canonical name of the CPU on
430 +# which the built Git will run (for instance "x86_64").
431
432 GIT-VERSION-FILE: FORCE
433 @$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1095,6 +1098,12 @@ else
1098 BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
1099 endif
1100
1101 +ifeq (,$(HOST_CPU))
1102 + BASIC_CFLAGS += -DGIT_HOST_CPU="\"$(firstword $(subst -, ,$(uname_M)))\""
1103 +else
1104 + BASIC_CFLAGS += -DGIT_HOST_CPU="\"$(HOST_CPU)\""
1105 +endif
1106 +
1107 ifneq (,$(INLINE))
1108 BASIC_CFLAGS += -Dinline=$(INLINE)
1109 endif
help.c
+1
@@ -412,6 +412,7 @@ int cmd_version(int argc, const char **argv, const char *prefix)
412 printf("git version %s\n", git_version_string);
413
414 if (build_options) {
415 + printf("cpu: %s\n", GIT_HOST_CPU);
416 printf("sizeof-long: %d\n", (int)sizeof(long));
417 /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
418 }