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