Skip to content

Commit

Permalink
Separate EDK2 into separate module and pin Linuxboot commit
Browse files Browse the repository at this point in the history
Making EDK2 into a module will aid in allowing it to be rebuilt (linuxboot#359)
and patched by the build system and to be reproducible (linuxboot#403). It also
provides somewhat of logical separation from Linuxboot.

Further, Linuxboot builds have not been working with HEADS for a
while because it hasn't been pinned to a commit, and therefore it changes
as the repository is updated. This commit pins Linuxboot to a commit
that has shown to work.

Linuxboot commit: f0ea0af8609e235631f1fcb65a4f7eb69f28ea26
EDK2 commit:      b7c299e4799012e8a20958a68693ab95b7626aa9
  • Loading branch information
synackd committed Oct 26, 2021
1 parent 21e5068 commit 9b84a31
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 9 deletions.
2 changes: 2 additions & 0 deletions boards/qemu-linuxboot/qemu-linuxboot.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions modules/edk2
Original file line number Diff line number Diff line change
@@ -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
16 changes: 7 additions & 9 deletions modules/linuxboot
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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 ; \
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9b84a31

Please sign in to comment.