Skip to content

Commit d918259

Browse files
jeffhostetlerdscho
authored andcommitted
help: special-case HOST_CPU universal
When building Git as a universal binary on macOS, the binary supports more than one target architecture. This is a bit of a problem for the `HOST_CPU` setting that is woefully unprepared for such a situation, as it wants to show architecture hard-coded at build time. In preparation for releasing universal builds, work around this by special-casing `universal` and replacing it at run-time with the known values `x86_64` or `arm64`. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 1def6ad commit d918259

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

help.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,22 @@ char *help_unknown_cmd(const char *cmd)
769769
exit(1);
770770
}
771771

772+
#if defined(__APPLE__)
773+
static const char *git_host_cpu(void) {
774+
if (!strcmp(GIT_HOST_CPU, "universal")) {
775+
#if defined(__x86_64__)
776+
return "x86_64";
777+
#elif defined(__aarch64__)
778+
return "arm64";
779+
#endif
780+
}
781+
782+
return GIT_HOST_CPU;
783+
}
784+
#undef GIT_HOST_CPU
785+
#define GIT_HOST_CPU git_host_cpu()
786+
#endif
787+
772788
void get_version_info(struct strbuf *buf, int show_build_options)
773789
{
774790
/*

0 commit comments

Comments
 (0)