Skip to content

Commit 4e97b24

Browse files
committed
build: fall back to gcc or clang when the host has no cc
HOST_ARCH came from `cc -dumpmachine`. On a host with gcc or clang but no cc symlink that command fails, HOST_ARCH is empty, and it no longer equals the target triple, so a native build is misread as a cross build: it links -static and prints `cc: not found` on every make. Try cc, then gcc, then clang for the host triple. The fallback stays a native compiler rather than $(CC), which may itself be a cross compiler, so cross detection is unaffected.
1 parent d6625f5 commit 4e97b24

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,13 @@ endif
155155

156156
VERSION := $(shell cat VERSION 2>/dev/null || echo unknown)
157157

158-
# Target triple ($(CC)) vs. the host's native triple (always plain `cc`). When
159-
# they differ we are cross-compiling, so link static — the target loader/libs
160-
# are not on this host. $(_ARCH) also names the per-arch build subdirectory.
161-
HOST_ARCH := $(shell cc -dumpmachine)
158+
# Target triple ($(CC)) vs. the host's native triple. When they differ the build
159+
# is a cross-compile, so link static — the target loader/libs are not on this host.
160+
# $(_ARCH) also names the per-arch build subdirectory. The native triple comes
161+
# from a native compiler, not from $(CC) (which may itself be a cross compiler):
162+
# try `cc`, then gcc/clang, so a host with no `cc` symlink does not misread a
163+
# native build as cross (and add a spurious -static) or print `cc: not found`.
164+
HOST_ARCH := $(shell cc -dumpmachine 2>/dev/null || gcc -dumpmachine 2>/dev/null || clang -dumpmachine 2>/dev/null)
162165
_ARCH := $(shell $(CC) -dumpmachine)
163166

164167
ifneq ($(_ARCH),$(HOST_ARCH))

0 commit comments

Comments
 (0)