Skip to content

Commit 8e968b6

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 34c1bab commit 8e968b6

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

help.c

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

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

0 commit comments

Comments
 (0)