@@ -72,7 +72,7 @@ INITRAMFS_BUILD_DIR := $(PLATFORM_BUILD_DIR)/initramfs
7272INITRAMFS_DEPS_FLAG := $(PLATFORM_BUILD_DIR ) /.initramfs-deps
7373INITRAMFS_PATCH_FLAG := $(PLATFORM_BUILD_DIR ) /.initramfs-patch
7474ifndef INITRAMFS_OUT
75- INITRAMFS_OUT := $(INITRAMFS_BUILD_DIR ) /initramfs_linuxboot.$(ARCH ) .cpio
75+ INITRAMFS_OUT := $(INITRAMFS_BUILD_DIR ) /initramfs_linuxboot.$(GOARCH ) .cpio
7676endif
7777# By default, build initramfs but a prebuilt one can be provided via INITRAMFS_IN.
7878INITRAMFS_IN ?= $(INITRAMFS_OUT )
@@ -102,6 +102,31 @@ ifdef COREBOOT_BLOBS_DIR
102102COREBOOT_BLOBS_DIR := $(realpath $(COREBOOT_BLOBS_DIR ) )
103103endif
104104
105+ # FIXME: Go needs to be run on the host architecture (GOARCH is used for cross-
106+ # compiling Go programs). However, the target platform's config will likely want
107+ # to use a Go tarball for that target architecture. For now, override this with
108+ # whatever the host has installed. THIS IS A GROSS HACK.
109+ #
110+ # We might change the json schema to specify only Go version, but not point at
111+ # a particular tarball (which includes architecture in the name). This would
112+ # also require changing the download verification scheme to something like GPG
113+ # signature instead of sha255sum, since the hash will obviously be different
114+ # among tarballs for different architectures.
115+ #
116+ # FIXME #2: It's not clear if we want to always use the coreboot toolchain when
117+ # cross compiling Linux. It's certainly an easy approach, though.
118+ #
119+ # FIXME #3: Some distros add the version number of the tool as a suffix, for
120+ # example "x86_64-linux-gnu-gcc-10".
121+ ifeq ($(CROSS_COMPILING ) , 1)
122+ INITRAMFS_BUILD_GOROOT ?= /usr/local/go
123+ else
124+ # FIXME: Also need to fix behavior when we're not cross-compilng, but system's
125+ # go version doesn't match the version we're using to build the initramfs...
126+ # INITRAMFS_BUILD_GOROOT ?= $(INITRAMFS_BUILD_DIR)/go
127+ INITRAMFS_BUILD_GOROOT ?= /usr/local/go
128+ endif
129+
105130UROOT_BOOT_CMDS := fbnetboot localboot systemboot
106131UROOT_EXP_CMDS := cbmem dmidecode modprobe ipmidump
107132UROOT_BASE_CMDS ?= \
@@ -256,10 +281,11 @@ initramfs: $(INITRAMFS_OUT)
256281# Initramfs build target.
257282$(INITRAMFS_OUT ) : $(INITRAMFS_DEPS_FLAG ) $(INITRAMFS_PATCH_FLAG )
258283 GO111MODULE=off \
259- GOROOT=$(INITRAMFS_BUILD_DIR ) /go \
284+ GOARCH=$(GOARCH ) \
285+ GOROOT=$(INITRAMFS_BUILD_GOROOT ) \
260286 GOCACHE=$(INITRAMFS_BUILD_DIR ) /go/.cache \
261287 GOPATH=$(INITRAMFS_BUILD_DIR ) /gopath:$(UROOT_ADDITIONAL_GOPATH ) \
262- $(INITRAMFS_BUILD_DIR ) /go /bin/go run github.com/u-root/u-root \
288+ $(GOROOT ) /bin/go run github.com/u-root/u-root \
263289 -build=bb -o $@ -uinitcmd=$(UINIT_CMD ) \
264290 $(addprefix -files=,$(BASE_FILES ) $(UROOT_ADDITIONAL_FILES ) ) \
265291 $(UROOT_ADDITIONAL_CMDS ) \
0 commit comments