Skip to content

Commit 3568fe4

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 b5d633d commit 3568fe4

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
@@ -744,6 +744,22 @@ char *help_unknown_cmd(const char *cmd)
744744
exit(1);
745745
}
746746

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

0 commit comments

Comments
 (0)