payloads/LinuxBoot: Build x86_64 with host toolchain

Currently our coreboot toolchain cannot build the Linux kernel in case
of x86_64. It spits out the following error during build:
```
make -C build/kernel-6_3 \
CROSS_COMPILE=/home/max/coreboot-amd/util/crossgcc/xgcc/bin/x86_64-elf- \
ARCH=x86_64 KBUILD_BUILD_USER=coreboot KBUILD_BUILD_HOST=reproducible \
KBUILD_BUILD_TIMESTAMP=Tue Aug 20 13:36:03 2024 KBUILD_BUILD_VERSION=0 bzImage
arch/x86/lib/clear_page_64.S: Assembler messages:
arch/x86/lib/clear_page_64.S:18: Error: number of operands mismatch for `mov'
arch/x86/lib/clear_page_64.S:27: Error: number of operands mismatch for `mov'
make[4]: *** [scripts/Makefile.build:374: arch/x86/lib/clear_page_64.o] Error 1
make[3]: *** [scripts/Makefile.build:494: arch/x86/lib] Error 2
make[3]: *** Waiting for unfinished jobs....
arch/x86/entry/entry_64.S: Assembler messages:
arch/x86/entry/entry_64.S:437: Error: unbalanced parenthesis in operand 1.
arch/x86/entry/entry_64.S:262:  Info: macro invoked from here
arch/x86/entry/entry_64.S:265:   Info: macro invoked from here
arch/x86/entry/entry_64.S:439: Error: unbalanced parenthesis in operand 1.
arch/x86/entry/entry_64.S:262:  Info: macro invoked from here
arch/x86/entry/entry_64.S:265:   Info: macro invoked from here
make[5]: *** [scripts/Makefile.build:374: arch/x86/entry/entry_64.o] Error 1
make[4]: *** [scripts/Makefile.build:494: arch/x86/entry] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:494: arch/x86] Error 2
make[2]: *** [Makefile:2025: .] Error 2
make[1]: *** [targets/linux.mk:60: build/kernel-6_3/arch/x86/boot/bzImage] Error 2
make: *** [payloads/external/Makefile.mk:401: payloads/external/LinuxBoot/build/Image] Error 2
```

In order to fix it, we will default to the host toolchain in order to
build x86_64 Linux. For that we add another Kconfig that decides,
whether or not a cross toolchain is used to build Linux.

Change-Id: Icaf56d6991d79f629e9ba8c901b441d81921d594
Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83990
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Frans Hendriks <fhendriks@eltan.com>
This commit is contained in:
Maximilian Brune 2024-08-20 15:36:03 +02:00 committed by Felix Singer
commit 7bcec7a2ef
3 changed files with 24 additions and 8 deletions

View file

@ -66,12 +66,23 @@ config LINUXBOOT_KERNEL_PATH
if LINUXBOOT_COMPILE_KERNEL
config LINUXBOOT_CROSS_COMPILE
bool "cross compiler"
default n if LINUXBOOT_X86_64 # currently coreboots cross toolchain cannot build Linux
default y
help
Enable this option if you want to compile Linux using a cross compiler.
The coreboot toolchain also counts as a cross toolchain.
config LINUXBOOT_CROSS_COMPILE_PATH
string "cross compiler"
depends on LINUXBOOT_CROSS_COMPILE
default "" # e.g. "aarch64-linux-gnu-"
help
Choose a custom cross compiler toolchain to use.
It can be useful if you don't want to use the coreboot toolchain
or experience problems using it.
The cross toolchain of coreboot will be used if this option is left empty.
If not left empty, it should contain a path to a cross toolchain that is
capable of compiling Linux. It can be useful if you don't want to use the
coreboot toolchain or experience problems using it for building Linux.
config LINUXBOOT_KERNEL_VERSION
string "kernel version"

View file

@ -2,9 +2,9 @@
SHELL := /bin/sh
OBJCOPY:=$(CONFIG_LINUXBOOT_CROSS_COMPILE)objcopy
OBJCOPY:=$(CONFIG_LINUXBOOT_CROSS_COMPILE_PATH)objcopy
KERNEL_MAKE_FLAGS = \
CROSS_COMPILE=$(CONFIG_LINUXBOOT_CROSS_COMPILE) \
CROSS_COMPILE=$(CONFIG_LINUXBOOT_CROSS_COMPILE_PATH) \
ARCH=$(LINUX_ARCH-y) \
KBUILD_BUILD_USER="coreboot" \
KBUILD_BUILD_HOST="reproducible" \

View file

@ -390,9 +390,14 @@ LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_ARM) = arm
LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_ARM64) = arm64
LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV32) = riscv
LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV64) = riscv
ifeq ($(CONFIG_LINUXBOOT_CROSS_COMPILE),"")
CONFIG_LINUXBOOT_CROSS_COMPILE=$(CROSS_COMPILE_$(LINUXBOOT_CROSS_COMPILE_ARCH-y))
endif
ifeq ($(CONFIG_LINUXBOOT_CROSS_COMPILE),y)
ifeq ($(CONFIG_LINUXBOOT_CROSS_COMPILE_PATH),"")
# use coreboots cross toolchain
CONFIG_LINUXBOOT_CROSS_COMPILE_PATH=$(CROSS_COMPILE_$(LINUXBOOT_CROSS_COMPILE_ARCH-y))
endif # CONFIG_LINUXBOOT_CROSS_COMPILE_PATH
else # CONFIG_LINUXBOOT_CROSS_COMPILE
$(warning "Using host toolchain to build Linuxboot")
endif # CONFIG_LINUXBOOT_CROSS_COMPILE
.PHONY: linuxboot
payloads/external/LinuxBoot/build/Image linuxboot:
$(MAKE) -C payloads/external/LinuxBoot \
@ -403,7 +408,7 @@ payloads/external/LinuxBoot/build/Image linuxboot:
CONFIG_LINUXBOOT_ARM64=$(CONFIG_LINUXBOOT_ARM64) \
CONFIG_LINUXBOOT_RISCV_RV32=$(CONFIG_LINUXBOOT_RISCV_RV32) \
CONFIG_LINUXBOOT_RISCV_RV64=$(CONFIG_LINUXBOOT_RISCV_RV64) \
CONFIG_LINUXBOOT_CROSS_COMPILE=$(CONFIG_LINUXBOOT_CROSS_COMPILE) \
CONFIG_LINUXBOOT_CROSS_COMPILE_PATH=$(CONFIG_LINUXBOOT_CROSS_COMPILE_PATH) \
CONFIG_LINUXBOOT_BUILD_INITRAMFS=$(CONFIG_LINUXBOOT_BUILD_INITRAMFS) \
CONFIG_LINUXBOOT_INITRAMFS_PATH=$(CONFIG_LINUXBOOT_INITRAMFS_PATH) \
CONFIG_LINUXBOOT_INITRAMFS_SUFFIX=$(CONFIG_LINUXBOOT_INITRAMFS_SUFFIX) \