build: always reset ARCH after getting it

When building with `ARCH=x86_64`, the previous `Makefile` will use it
without checking and cause:

Makefile:319: *** "ERROR: No hypervisors known for architecture x86_64 (looked for: acrn firecracker qemu cloud-hypervisor)".  Stop.

This commit fix the above issue by checking `ARCH` no matter where it
is assigned.

Fixes: #3444

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
This commit is contained in:
Yu Li 2022-01-20 10:53:22 +08:00
parent a3b3274121
commit 37df1678ae

View File

@ -8,20 +8,19 @@ SKIP_GO_VERSION_CHECK=
include golang.mk
#Get ARCH.
ifneq (,$(golang_version_raw))
GOARCH=$(shell go env GOARCH)
ifeq ($(ARCH),)
ARCH = $(GOARCH)
endif
else
ARCH = $(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH = amd64
endif
ifeq ($(ARCH),aarch64)
ARCH = arm64
ifeq ($(ARCH),)
ifneq (,$(golang_version_raw))
override ARCH = $(shell go env GOARCH)
else
override ARCH = $(shell uname -m)
endif
endif
ifeq ($(ARCH),x86_64)
override ARCH = amd64
endif
ifeq ($(ARCH),aarch64)
override ARCH = arm64
endif
ARCH_DIR = arch
ARCH_FILE_SUFFIX = -options.mk
@ -29,8 +28,12 @@ ARCH_FILE = $(ARCH_DIR)/$(ARCH)$(ARCH_FILE_SUFFIX)
ARCH_FILES = $(wildcard arch/*$(ARCH_FILE_SUFFIX))
ALL_ARCHES = $(patsubst $(ARCH_DIR)/%$(ARCH_FILE_SUFFIX),%,$(ARCH_FILES))
# Load architecture-dependent settings
include $(ARCH_FILE)
ifeq (,$(realpath $(ARCH_FILE)))
$(error "ERROR: invalid architecture: '$(ARCH)'")
else
# Load architecture-dependent settings
include $(ARCH_FILE)
endif
PROJECT_TYPE = kata
PROJECT_NAME = Kata Containers