summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/ovmf/ovmf
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-12 22:28:45 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-13 11:34:14 +0100
commit944de7ea5f653eeed7439df7141c65f64745e4a8 (patch)
tree255f5934c924af02198bc9fbdeb1cb8a50c683c0 /meta/recipes-core/ovmf/ovmf
parent8e19e48f1b7d406268893fee5bde3b8012308e91 (diff)
downloadpoky-944de7ea5f653eeed7439df7141c65f64745e4a8.tar.gz
ovmf: Fix other reproducibility issues
When building in longer paths, the ovmf build changes in many ways. This adds a patch addressing various causes of problems. Full details are in the patch header. (From OE-Core rev: 9113a5815f3c682ef99fd777e35e892b2e08237f) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/ovmf/ovmf')
-rw-r--r--meta/recipes-core/ovmf/ovmf/reproducible.patch165
1 files changed, 165 insertions, 0 deletions
diff --git a/meta/recipes-core/ovmf/ovmf/reproducible.patch b/meta/recipes-core/ovmf/ovmf/reproducible.patch
new file mode 100644
index 0000000000..5d2aeaacfe
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/reproducible.patch
@@ -0,0 +1,165 @@
1This patch fixes various things which make the build more reproducible. Some changes
2here only change intermediate artefacts but that means when you have two build trees
3giving differing results, the differences can be isolated more easily. The issues here
4usually become apparent with longer paths.
5
6This was all debugged with:
7TMPDIR = "${TOPDIR}/tmp"
8vs.
9TMPDIR = "${TOPDIR}/tmp-inital-mylongpath-mylongpath-mylongpath-mylongpath-mylongpath-mylongpath-mylongpath-mylongpath-mylongpath"
10
11The patch specifically:
12
13 * Sorts output in GNUmakefile
14 * Always generates indirect flags files used to avoid pathlength issues else the
15 compile commands suddenly change when using longer paths
16 * Sorts the AutoGenTimeStamp file contents
17 * Makes the TargetDescBlock objects from BuildEngine sortable to allow the makefile fix
18 * Fix ElfConvert within GenFw so that only the basename of the binary being converted
19 is used, else the output from "GenFw XXX.bin" differs from "GenFw /long/path/XXX.bin"
20 with sufficiently long paths
21
22Upstream-Status: Pending [At least some of this might be interesting to upstream]
23Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
24
25Index: git/BaseTools/Source/Python/AutoGen/GenMake.py
26===================================================================
27--- git.orig/BaseTools/Source/Python/AutoGen/GenMake.py
28+++ git/BaseTools/Source/Python/AutoGen/GenMake.py
29@@ -571,7 +571,7 @@ cleanlib:
30 os.remove(RespFileList)
31
32 # convert source files and binary files to build targets
33- self.ResultFileList = [str(T.Target) for T in MyAgo.CodaTargetList]
34+ self.ResultFileList = sorted([str(T.Target) for T in MyAgo.CodaTargetList])
35 if len(self.ResultFileList) == 0 and len(MyAgo.SourceFileList) != 0:
36 EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build",
37 ExtraData="[%s]" % str(MyAgo))
38@@ -722,7 +722,7 @@ cleanlib:
39 OutputFile = ''
40 DepsFileList = []
41
42- for Cmd in self.GenFfsList:
43+ for Cmd in sorted(self.GenFfsList):
44 if Cmd[2]:
45 for CopyCmd in Cmd[2]:
46 Src, Dst = CopyCmd
47@@ -755,7 +755,7 @@ cleanlib:
48 self.BuildTargetList.append('\t%s' % CmdString)
49
50 self.ParseSecCmd(DepsFileList, Cmd[1])
51- for SecOutputFile, SecDepsFile, SecCmd in self.FfsOutputFileList :
52+ for SecOutputFile, SecDepsFile, SecCmd in sorted(self.FfsOutputFileList):
53 self.BuildTargetList.append('%s : %s' % (self.ReplaceMacro(SecOutputFile), self.ReplaceMacro(SecDepsFile)))
54 self.BuildTargetList.append('\t%s' % self.ReplaceMacro(SecCmd))
55 self.FfsOutputFileList = []
56@@ -794,13 +794,13 @@ cleanlib:
57
58 def CommandExceedLimit(self):
59 FlagDict = {
60- 'CC' : { 'Macro' : '$(CC_FLAGS)', 'Value' : False},
61- 'PP' : { 'Macro' : '$(PP_FLAGS)', 'Value' : False},
62- 'APP' : { 'Macro' : '$(APP_FLAGS)', 'Value' : False},
63- 'ASLPP' : { 'Macro' : '$(ASLPP_FLAGS)', 'Value' : False},
64- 'VFRPP' : { 'Macro' : '$(VFRPP_FLAGS)', 'Value' : False},
65- 'ASM' : { 'Macro' : '$(ASM_FLAGS)', 'Value' : False},
66- 'ASLCC' : { 'Macro' : '$(ASLCC_FLAGS)', 'Value' : False},
67+ 'CC' : { 'Macro' : '$(CC_FLAGS)', 'Value' : True},
68+ 'PP' : { 'Macro' : '$(PP_FLAGS)', 'Value' : True},
69+ 'APP' : { 'Macro' : '$(APP_FLAGS)', 'Value' : True},
70+ 'ASLPP' : { 'Macro' : '$(ASLPP_FLAGS)', 'Value' : True},
71+ 'VFRPP' : { 'Macro' : '$(VFRPP_FLAGS)', 'Value' : True},
72+ 'ASM' : { 'Macro' : '$(ASM_FLAGS)', 'Value' : True},
73+ 'ASLCC' : { 'Macro' : '$(ASLCC_FLAGS)', 'Value' : True},
74 }
75
76 RespDict = {}
77@@ -1003,9 +1003,9 @@ cleanlib:
78 if not self.ObjTargetDict.get(T.Target.SubDir):
79 self.ObjTargetDict[T.Target.SubDir] = set()
80 self.ObjTargetDict[T.Target.SubDir].add(NewFile)
81- for Type in self._AutoGenObject.Targets:
82+ for Type in sorted(self._AutoGenObject.Targets):
83 resp_file_number = 0
84- for T in self._AutoGenObject.Targets[Type]:
85+ for T in sorted(self._AutoGenObject.Targets[Type]):
86 # Generate related macros if needed
87 if T.GenFileListMacro and T.FileListMacro not in self.FileListMacros:
88 self.FileListMacros[T.FileListMacro] = []
89Index: git/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
90===================================================================
91--- git.orig/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
92+++ git/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
93@@ -1484,6 +1484,9 @@ class ModuleAutoGen(AutoGen):
94 for File in Files:
95 if File.lower().endswith('.pdb'):
96 AsBuiltInfDict['binary_item'].append('DISPOSABLE|' + File)
97+
98+ AsBuiltInfDict['binary_item'] = sorted(AsBuiltInfDict['binary_item'])
99+
100 HeaderComments = self.Module.HeaderComments
101 StartPos = 0
102 for Index in range(len(HeaderComments)):
103@@ -1759,7 +1762,7 @@ class ModuleAutoGen(AutoGen):
104 if os.path.exists (self.TimeStampPath):
105 os.remove (self.TimeStampPath)
106
107- SaveFileOnChange(self.TimeStampPath, "\n".join(FileSet), False)
108+ SaveFileOnChange(self.TimeStampPath, "\n".join(sorted(FileSet)), False)
109
110 # Ignore generating makefile when it is a binary module
111 if self.IsBinaryModule:
112Index: git/BaseTools/Source/Python/AutoGen/BuildEngine.py
113===================================================================
114--- git.orig/BaseTools/Source/Python/AutoGen/BuildEngine.py
115+++ git/BaseTools/Source/Python/AutoGen/BuildEngine.py
116@@ -70,6 +70,9 @@ class TargetDescBlock(object):
117 else:
118 return str(Other) == self.Target.Path
119
120+ def __lt__(self, other):
121+ return str(self) < str(other)
122+
123 def AddInput(self, Input):
124 if Input not in self.Inputs:
125 self.Inputs.append(Input)
126Index: git/BaseTools/Source/C/GenFw/Elf64Convert.c
127===================================================================
128--- git.orig/BaseTools/Source/C/GenFw/Elf64Convert.c
129+++ git/BaseTools/Source/C/GenFw/Elf64Convert.c
130@@ -14,6 +14,8 @@ SPDX-License-Identifier: BSD-2-Clause-Pa
131 #ifndef __GNUC__
132 #include <windows.h>
133 #include <io.h>
134+#else
135+#define _GNU_SOURCE
136 #endif
137 #include <assert.h>
138 #include <stdio.h>
139@@ -770,7 +772,7 @@ ScanSections64 (
140 }
141 mCoffOffset = mDebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY) +
142 sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) +
143- strlen(mInImageName) + 1;
144+ strlen(basename(mInImageName)) + 1;
145
146 mCoffOffset = CoffAlign(mCoffOffset);
147 if (SectionCount == 0) {
148@@ -1609,7 +1611,7 @@ WriteDebug64 (
149 EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *Dir;
150 EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY *Nb10;
151
152- Len = strlen(mInImageName) + 1;
153+ Len = strlen(basename(mInImageName)) + 1;
154
155 Dir = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY*)(mCoffFile + mDebugOffset);
156 Dir->Type = EFI_IMAGE_DEBUG_TYPE_CODEVIEW;
157@@ -1619,7 +1621,7 @@ WriteDebug64 (
158
159 Nb10 = (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY*)(Dir + 1);
160 Nb10->Signature = CODEVIEW_SIGNATURE_NB10;
161- strcpy ((char *)(Nb10 + 1), mInImageName);
162+ strcpy ((char *)(Nb10 + 1), basename(mInImageName));
163
164
165 NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset);