Skip to content

Commit b228940

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 52015aa commit b228940

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ all::
425425
#
426426
# to say "export LESS=FRX (and LV=-c) if the environment variable
427427
# 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").
428431

429432
GIT-VERSION-FILE: FORCE
430433
@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1095,6 +1098,12 @@ else
10951098
BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
10961099
endif
10971100

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+
10981107
ifneq (,$(INLINE))
10991108
BASIC_CFLAGS += -Dinline=$(INLINE)
11001109
endif

help.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ int cmd_version(int argc, const char **argv, const char *prefix)
412412
printf("git version %s\n", git_version_string);
413413

414414
if (build_options) {
415+
printf("cpu: %s\n", GIT_HOST_CPU);
415416
printf("sizeof-long: %d\n", (int)sizeof(long));
416417
/* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
417418
}

0 commit comments

Comments
 (0)