summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2017-03-21 09:56:50 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-22 11:35:22 +0000
commit11aa39028867d356d37291c2d9ca492f7cdf0795 (patch)
treed2d0feefb1afee80224948d7306ebea9a8f78cb9 /meta
parent853a1548507dd8bfc3362052cfee8e89e6b51b33 (diff)
downloadpoky-11aa39028867d356d37291c2d9ca492f7cdf0795.tar.gz
ovmf: fix toolchain selection
For the native tools, a static patch inserted gcc/g++/ld/ar while later adding BUILD_LDFLAGS and BUILD_CFLAGS with sed. Now it's all done with sed, which has the advantage that it uses the actual compile variables. However, in practice those are the same. More importantly, picking the build tools for the target was broken. ovmf-native tried to insert TARGET_PREFIX into the tools definition file, but that variable is empty in a native recipe. As a result, "gcc" was used instead of "${HOST_PREFIX}gcc", leading to an undesirable dependency on the host compiler and potentially (probably?!) causing some of the build issues that were seen for ovmf. The new approach is to override the tool selection in ovmf-native so that the HOST_PREFIX env variable is used, which then gets exported during do_compile for the target. While at it, Python code that gets appened to do_patch only to call shell functions gets replaced with the do_patch[postfuncs] mechanism. Incremental builds now always use the tools definition from the current ovmf-native; previously, only the initial build copied the template file. Probably the entire split into ovmf-native and ovmf could be removed. This merely hasn't been attempted yet. (From OE-Core rev: 23a12d87a6e82f80f4ccc1a01c707faa89ff7abd) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/ovmf/ovmf/0001-BaseTools-Force-tools-variables-to-host-toolchain.patch48
-rw-r--r--meta/recipes-core/ovmf/ovmf_git.bb68
2 files changed, 50 insertions, 66 deletions
diff --git a/meta/recipes-core/ovmf/ovmf/0001-BaseTools-Force-tools-variables-to-host-toolchain.patch b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-Force-tools-variables-to-host-toolchain.patch
deleted file mode 100644
index 644b99d8bc..0000000000
--- a/meta/recipes-core/ovmf/ovmf/0001-BaseTools-Force-tools-variables-to-host-toolchain.patch
+++ /dev/null
@@ -1,48 +0,0 @@
1From 6e24bde1979c2d7149b37d142fb882dfde0e9770 Mon Sep 17 00:00:00 2001
2From: Matt Fleming <matt.fleming@intel.com>
3Date: Fri, 27 Jun 2014 11:12:18 +0100
4Subject: [PATCH] BaseTools: Force tools variables to host toolchain
5
6Signed-off-by: Matt Fleming <matt.fleming@intel.com>
7---
8 BaseTools/Source/C/Makefiles/app.makefile | 7 +++++++
9 BaseTools/Source/C/VfrCompile/GNUmakefile | 5 +++++
10 2 files changed, 12 insertions(+)
11
12diff --git a/BaseTools/Source/C/Makefiles/app.makefile b/BaseTools/Source/C/Makefiles/app.makefile
13index 19269a1..62aad0f 100644
14--- a/BaseTools/Source/C/Makefiles/app.makefile
15+++ b/BaseTools/Source/C/Makefiles/app.makefile
16@@ -16,6 +16,13 @@ include $(MAKEROOT)/Makefiles/header.makefile
17
18 APPLICATION = $(MAKEROOT)/bin/$(APPNAME)
19
20+CC = gcc
21+CXX = g++
22+AS = gcc
23+AR = ar
24+LD = ld
25+LINKER = $(CC)
26+
27 .PHONY:all
28 all: $(MAKEROOT)/bin $(APPLICATION)
29
30diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C/VfrCompile/GNUmakefile
31index 82005e1..5ac5f7e 100644
32--- a/BaseTools/Source/C/VfrCompile/GNUmakefile
33+++ b/BaseTools/Source/C/VfrCompile/GNUmakefile
34@@ -26,6 +26,11 @@ OBJECTS = AParser.o DLexerBase.o ATokenBuffer.o EfiVfrParser.o VfrLexer.o VfrSyn
35
36 VFR_CPPFLAGS = -DPCCTS_USE_NAMESPACE_STD $(CPPFLAGS)
37
38+CC = gcc
39+CXX = g++
40+AS = gcc
41+AR = ar
42+LD = ld
43 LINKER = $(BUILD_CXX)
44
45 EXTRA_CLEAN_OBJECTS = EfiVfrParser.cpp EfiVfrParser.h VfrParser.dlg VfrTokens.h VfrLexer.cpp VfrLexer.h VfrSyntax.cpp tokens.h
46--
471.9.0
48
diff --git a/meta/recipes-core/ovmf/ovmf_git.bb b/meta/recipes-core/ovmf/ovmf_git.bb
index a658c9d115..898c5b76af 100644
--- a/meta/recipes-core/ovmf/ovmf_git.bb
+++ b/meta/recipes-core/ovmf/ovmf_git.bb
@@ -11,7 +11,6 @@ PACKAGECONFIG ??= ""
11PACKAGECONFIG[secureboot] = ",,," 11PACKAGECONFIG[secureboot] = ",,,"
12 12
13SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \ 13SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \
14 file://0001-BaseTools-Force-tools-variables-to-host-toolchain.patch \
15 file://0002-ovmf-update-path-to-native-BaseTools.patch \ 14 file://0002-ovmf-update-path-to-native-BaseTools.patch \
16 file://0003-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \ 15 file://0003-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \
17 file://VfrCompile-increase-path-length-limit.patch \ 16 file://VfrCompile-increase-path-length-limit.patch \
@@ -51,31 +50,54 @@ COMPATIBLE_HOST='(i.86|x86_64).*'
51OVMF_SECURE_BOOT_EXTRA_FLAGS ??= "" 50OVMF_SECURE_BOOT_EXTRA_FLAGS ??= ""
52OVMF_SECURE_BOOT_FLAGS = "-DSECURE_BOOT_ENABLE=TRUE ${OVMF_SECURE_BOOT_EXTRA_FLAGS}" 51OVMF_SECURE_BOOT_FLAGS = "-DSECURE_BOOT_ENABLE=TRUE ${OVMF_SECURE_BOOT_EXTRA_FLAGS}"
53 52
54do_patch_append_class-native() { 53do_patch[postfuncs] += "fix_basetools_location"
55 bb.build.exec_func('do_fix_iasl', d) 54fix_basetools_location () {
56 bb.build.exec_func('do_fix_toolchain', d)
57} 55}
58 56fix_basetools_location_class-target() {
59do_fix_basetools_location() { 57 # Replaces the fake path inserted by 0002-ovmf-update-path-to-native-BaseTools.patch.
58 # Necessary for finding the actual BaseTools from ovmf-native.
60 sed -i -e 's#BBAKE_EDK_TOOLS_PATH#${STAGING_BINDIR_NATIVE}/${EDK_TOOLS_DIR}#' ${S}/OvmfPkg/build.sh 59 sed -i -e 's#BBAKE_EDK_TOOLS_PATH#${STAGING_BINDIR_NATIVE}/${EDK_TOOLS_DIR}#' ${S}/OvmfPkg/build.sh
61} 60}
62 61
63do_patch_append_class-target() { 62do_patch[postfuncs] += "fix_iasl"
64 bb.build.exec_func('do_fix_basetools_location', d) 63fix_iasl() {
65} 64}
66 65fix_iasl_class-native() {
67 66 # iasl is not installed under /usr/bin when building with OE.
68do_fix_iasl() {
69 sed -i -e 's#/usr/bin/iasl#${STAGING_BINDIR_NATIVE}/iasl#' ${S}/BaseTools/Conf/tools_def.template 67 sed -i -e 's#/usr/bin/iasl#${STAGING_BINDIR_NATIVE}/iasl#' ${S}/BaseTools/Conf/tools_def.template
70} 68}
71 69
72do_fix_toolchain(){ 70# Inject CC and friends into the build. LINKER already is in GNUmakefile.
73 sed -i -e 's#DEF(ELFGCC_BIN)/#${TARGET_PREFIX}#' ${S}/BaseTools/Conf/tools_def.template 71# Must be idempotent and thus remove old assignments that were inserted
74 sed -i -e 's#DEF(GCC.*PREFIX)#${TARGET_PREFIX}#' ${S}/BaseTools/Conf/tools_def.template 72# earlier.
75 sed -i -e "s#^LINKER\(.*\)#LINKER\1\nLFLAGS += ${BUILD_LDFLAGS}#" ${S}/BaseTools/Source/C/Makefiles/app.makefile 73do_patch[postfuncs] += "fix_toolchain"
76 sed -i -e "s#^LINKER\(.*\)#LINKER\1\nCFLAGS += ${BUILD_CFLAGS}#" ${S}/BaseTools/Source/C/Makefiles/app.makefile 74fix_toolchain() {
77 sed -i -e "s#^LINKER\(.*\)#LINKER\1\nLFLAGS += ${BUILD_LDFLAGS}#" ${S}/BaseTools/Source/C/VfrCompile/GNUmakefile 75 sed -i \
78 sed -i -e "s#^LINKER\(.*\)#LINKER\1\nCFLAGS += ${BUILD_CFLAGS}#" ${S}/BaseTools/Source/C/VfrCompile/GNUmakefile 76 -e '/^\(CC\|CXX\|AS\|AR\|LD\|LINKER\) =/d' \
77 -e '/^APPLICATION/a CC = ${CC}\nCXX = ${CXX}\nAS = ${AS}\nAR = ${AR}\nLD = ${LD}\nLINKER = $(CC)' \
78 ${S}/BaseTools/Source/C/Makefiles/app.makefile
79 sed -i \
80 -e '/^\(CC\|CXX\|AS\|AR\|LD\)/d' \
81 -e '/^VFR_CPPFLAGS/a CC = ${CC}\nCXX = ${CXX}\nAS = ${AS}\nAR = ${AR}\nLD = ${LD}' \
82 ${S}/BaseTools/Source/C/VfrCompile/GNUmakefile
83}
84fix_toolchain_append_class-native() {
85 # This tools_def.template is going to be used by the target ovmf and
86 # defines which compilers to use. For the GCC toolchain definitions,
87 # that will be ${HOST_PREFIX}gcc. However, "make" doesn't need that
88 # prefix.
89 #
90 # Injecting ENV(HOST_PREFIX) matches exporting that value as env
91 # variable in do_compile_class-target.
92 sed -i \
93 -e 's#\(ENV\|DEF\)(GCC.*_PREFIX)#ENV(HOST_PREFIX)#' \
94 -e 's#ENV(HOST_PREFIX)make#make#' \
95 ${S}/BaseTools/Conf/tools_def.template
96 sed -i \
97 -e '/^\(LFLAGS\|CFLAGS\) +=/d' \
98 -e '/^LINKER/a LFLAGS += ${BUILD_LDFLAGS}\nCFLAGS += ${BUILD_CFLAGS}' \
99 ${S}/BaseTools/Source/C/Makefiles/app.makefile \
100 ${S}/BaseTools/Source/C/VfrCompile/GNUmakefile
79} 101}
80 102
81GCC_VER="$(${CC} -v 2>&1 | tail -n1 | awk '{print $3}')" 103GCC_VER="$(${CC} -v 2>&1 | tail -n1 | awk '{print $3}')"
@@ -119,6 +141,16 @@ do_compile_class-target() {
119 OVMF_ARCH="IA32" 141 OVMF_ARCH="IA32"
120 fi 142 fi
121 143
144 # The build for the target uses BaseTools/Conf/tools_def.template
145 # from ovmf-native to find the compiler, which depends on
146 # exporting HOST_PREFIX.
147 export HOST_PREFIX="${HOST_PREFIX}"
148
149 # BaseTools/Conf gets copied to Conf, but only if that does not
150 # exist yet. To ensure that an updated template gets used during
151 # incremental builds, we need to remove the copy before we start.
152 rm -f `ls ${S}/Conf/*.txt | grep -v ReadMe.txt`
153
122 # ${WORKDIR}/ovmf is a well-known location where do_install and 154 # ${WORKDIR}/ovmf is a well-known location where do_install and
123 # do_deploy will be able to find the files. 155 # do_deploy will be able to find the files.
124 rm -rf ${WORKDIR}/ovmf 156 rm -rf ${WORKDIR}/ovmf