Felix Singer has submitted this change. ( https://review.coreboot.org/c/coreboot/+/83990?usp=email )
Change subject: payloads/LinuxBoot: Build x86_64 with host toolchain ......................................................................
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 --- M payloads/external/LinuxBoot/Kconfig M payloads/external/LinuxBoot/targets/linux.mk M payloads/external/Makefile.mk 3 files changed, 24 insertions(+), 8 deletions(-)
Approvals: Frans Hendriks: Looks good to me, approved Lean Sheng Tan: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/payloads/external/LinuxBoot/Kconfig b/payloads/external/LinuxBoot/Kconfig index 24bfe3f..454b7c5 100644 --- a/payloads/external/LinuxBoot/Kconfig +++ b/payloads/external/LinuxBoot/Kconfig @@ -66,12 +66,23 @@ 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" diff --git a/payloads/external/LinuxBoot/targets/linux.mk b/payloads/external/LinuxBoot/targets/linux.mk index 1a882f1..5cd3c54 100644 --- a/payloads/external/LinuxBoot/targets/linux.mk +++ b/payloads/external/LinuxBoot/targets/linux.mk @@ -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" \ diff --git a/payloads/external/Makefile.mk b/payloads/external/Makefile.mk index 53693f5..52fc07d 100644 --- a/payloads/external/Makefile.mk +++ b/payloads/external/Makefile.mk @@ -390,9 +390,14 @@ 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 @@ 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) \