From c68b447119af93c263bd846c364f5228a9acb218 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Tue, 17 Oct 2023 17:43:51 -0400 Subject: [PATCH] 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 Signed-off-by: Johannes Schindelin --- help.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/help.c b/help.c index 6d2ebfbd2a45f1..9f2ceaa81c24a8 100644 --- a/help.c +++ b/help.c @@ -730,6 +730,22 @@ const char *help_unknown_cmd(const char *cmd) exit(1); } +#if defined(__APPLE__) +static const char *git_host_cpu(void) { + if (!strcmp(GIT_HOST_CPU, "universal")) { +#if defined(__x86_64__) + return "x86_64"; +#elif defined(__aarch64__) + return "arm64"; +#endif + } + + return GIT_HOST_CPU; +} +#undef GIT_HOST_CPU +#define GIT_HOST_CPU git_host_cpu() +#endif + void get_version_info(struct strbuf *buf, int show_build_options) { /*