Skip to content

Commit 4758384

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 <jeffhostetler@github.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 3a82d29 commit 4758384

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: help.c

+16
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,22 @@ char *help_unknown_cmd(const char *cmd)
745745
exit(1);
746746
}
747747

748+
#if defined(__APPLE__)
749+
static const char *git_host_cpu(void) {
750+
if (!strcmp(GIT_HOST_CPU, "universal")) {
751+
#if defined(__x86_64__)
752+
return "x86_64";
753+
#elif defined(__aarch64__)
754+
return "arm64";
755+
#endif
756+
}
757+
758+
return GIT_HOST_CPU;
759+
}
760+
#undef GIT_HOST_CPU
761+
#define GIT_HOST_CPU git_host_cpu()
762+
#endif
763+
748764
void get_version_info(struct strbuf *buf, int show_build_options)
749765
{
750766
/*

0 commit comments

Comments
 (0)