diff --git a/boards/qemu-linuxboot/qemu-linuxboot.config b/boards/qemu-linuxboot/qemu-linuxboot.config index 645457897..2a467028b 100644 --- a/boards/qemu-linuxboot/qemu-linuxboot.config +++ b/boards/qemu-linuxboot/qemu-linuxboot.config @@ -6,6 +6,8 @@ export CONFIG_LINUX_VERSION=4.14.62 CONFIG_LINUXBOOT_BOARD=qemu CONFIG_LINUX_CONFIG=config/linux-linuxboot.config +CONFIG_EDK2_PLATFORM=X64 + ifeq "$(CONFIG_UROOT)" "y" CONFIG_BUSYBOX=n else diff --git a/modules/edk2 b/modules/edk2 new file mode 100644 index 000000000..69acdb639 --- /dev/null +++ b/modules/edk2 @@ -0,0 +1,22 @@ +# EDK2 is required by Linuxboot. +modules-$(CONFIG_LINUXBOOT) += edk2 + +edk2_version := b7c299e4799012e8a20958a68693ab95b7626aa9 +edk2_hash := 78f48f46414b019b5fcd2d7049fd79e955d25f2965123d0bbdf7226564db33e5 +edk2_tar := edk2-$(edk2_version).tar.gz +edk2_dir := edk2-$(edk2_version) +edk2_url := https://github.com/linuxboot/edk2/archive/$(edk2_version).tar.gz +edk2_depends := $(musl_dep) + +# Use musl for compilation to avoid errors with GCC and create a dummy +# .git file so Linuxboot doesn't try to clone EDK2 again. +edk2_configure := \ + cd $(build)/$(edk2_dir) \ + && source edksetup.sh \ + && sed -i \ + 's|DEFINE GCC5_$(CONFIG_EDK2_PLATFORM)_PREFIX = ENV(GCC5_BIN)|DEFINE GCC5_$(CONFIG_EDK2_PLATFORM)_PREFIX = $(CROSS)|' \ + Conf/tools_def.txt \ + && touch .git + +# EDK2 will be built via the Linuxboot module, so no build target here. +edk2_target := nothing || true diff --git a/modules/linuxboot b/modules/linuxboot index b95dad672..83ba7bc39 100644 --- a/modules/linuxboot +++ b/modules/linuxboot @@ -1,8 +1,11 @@ modules-$(CONFIG_LINUXBOOT) += linuxboot -linuxboot_version := git -linuxboot_repo := https://github.com/osresearch/linuxboot +linuxboot_version := f0ea0af8609e235631f1fcb65a4f7eb69f28ea26 +linuxboot_hash := a814a12272718af74fead5dbf6f24491f30c259f56c074775e86f1572b2e2990 +linuxboot_tar := linuxboot-$(linuxboot_version).tar.gz +linuxboot_url := https://github.com/osresearch/linuxboot/archive/$(linuxboot_version).tar.gz linuxboot_base_dir := linuxboot-$(linuxboot_version) +linuxboot_depends := edk2 # linuxboot builds are specialized on a per-target basis. # They can be specialized by defining $(CONFIG_LINUXBOOT_BOARD) @@ -11,13 +14,8 @@ linuxboot_base_dir := linuxboot-$(linuxboot_version) linuxboot_board := $(or $(CONFIG_LINUXBOOT_BOARD),$(BOARD)) linuxboot_dir := linuxboot-$(linuxboot_version)/build/$(linuxboot_board) -linuxboot_configure := \ - echo >&2 "Pre-building edk2" ; \ - $(MAKE) \ - -C $(build)/$(linuxboot_base_dir) \ - BOARD=$(linuxboot_board) \ - edk2.force \ - || exit 1 ; \ +linuxboot_configure = \ + ln -sf ../edk2-$(edk2_version) $(build)/$(linuxboot_base_dir)/edk2 ; \ if [ "$(linuxboot_board)" = "qemu" ]; then \ echo >&2 "Pre-building edk2 OVMF" ; \ ( cd $(build)/$(linuxboot_base_dir)/edk2/OvmfPkg ; \ diff --git a/patches/edk2-b7c299e4799012e8a20958a68693ab95b7626aa9/0000-no-var-length-arrays-warnings.patch b/patches/edk2-b7c299e4799012e8a20958a68693ab95b7626aa9/0000-no-var-length-arrays-warnings.patch new file mode 100644 index 000000000..cf6e3a16f --- /dev/null +++ b/patches/edk2-b7c299e4799012e8a20958a68693ab95b7626aa9/0000-no-var-length-arrays-warnings.patch @@ -0,0 +1,13 @@ +diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile +index 27aa28b2fa..8a0633977b 100644 +--- a/BaseTools/Source/C/Makefiles/header.makefile ++++ b/BaseTools/Source/C/Makefiles/header.makefile +@@ -49,7 +49,7 @@ ifeq ($(DARWIN),Darwin) + # assume clang or clang compatible flags on OS X + BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g + else +-BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g ++BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-vla-parameter -Wno-stringop-truncation -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g + endif + BUILD_LFLAGS = + BUILD_CXXFLAGS = -Wno-unused-result diff --git a/patches/edk2-b7c299e4799012e8a20958a68693ab95b7626aa9/0001-no-misleading-indentation.patch b/patches/edk2-b7c299e4799012e8a20958a68693ab95b7626aa9/0001-no-misleading-indentation.patch new file mode 100644 index 000000000..17273111e --- /dev/null +++ b/patches/edk2-b7c299e4799012e8a20958a68693ab95b7626aa9/0001-no-misleading-indentation.patch @@ -0,0 +1,13 @@ +diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template +index d8fde02ea3..bb5ee93703 100755 +--- a/BaseTools/Conf/tools_def.template ++++ b/BaseTools/Conf/tools_def.template +@@ -4503,7 +4503,7 @@ DEFINE GCC_IPF_RC_FLAGS = -I binary -O elf64-ia64-little -B ia64 + DEFINE GCC_ARM_RC_FLAGS = -I binary -O elf32-littlearm -B arm --rename-section .data=.hii + DEFINE GCC_AARCH64_RC_FLAGS = -I binary -O elf64-littleaarch64 -B aarch64 --rename-section .data=.hii + +-DEFINE GCC44_ALL_CC_FLAGS = -g -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings ++DEFINE GCC44_ALL_CC_FLAGS = -g -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -Wno-misleading-indentation -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings + DEFINE GCC44_IA32_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables + DEFINE GCC44_X64_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) -m64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables + DEFINE GCC44_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x20