Skip to content

Commit b04e8b5

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 cf0fc79 commit b04e8b5

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
@@ -768,6 +768,22 @@ char *help_unknown_cmd(const char *cmd)
768768
exit(1);
769769
}
770770

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

0 commit comments

Comments
 (0)