@@ -61,10 +61,11 @@ async def _parse(self, path: pathlib.Path) -> _stencils.StencilGroup:
61
61
args = ["--disassemble" , "--reloc" , f"{ path } " ]
62
62
output = await _llvm .maybe_run ("llvm-objdump" , args , echo = self .verbose )
63
63
if output is not None :
64
+ # Make sure that full paths don't leak out (for reproducibility):
65
+ long , short = str (path ), str (path .name )
64
66
group .code .disassembly .extend (
65
- line .expandtabs ().strip ()
67
+ line .expandtabs ().strip (). replace ( long , short )
66
68
for line in output .splitlines ()
67
- if not line .isspace ()
68
69
)
69
70
args = [
70
71
"--elf-output-style=JSON" ,
@@ -90,9 +91,6 @@ async def _parse(self, path: pathlib.Path) -> _stencils.StencilGroup:
90
91
if group .data .body :
91
92
line = f"0: { str (bytes (group .data .body )).removeprefix ('b' )} "
92
93
group .data .disassembly .append (line )
93
- group .process_relocations (
94
- known_symbols = self .known_symbols , alignment = self .alignment
95
- )
96
94
return group
97
95
98
96
def _handle_section (self , section : _S , group : _stencils .StencilGroup ) -> None :
@@ -122,6 +120,10 @@ async def _compile(
122
120
f"-I{ CPYTHON / 'Tools' / 'jit' } " ,
123
121
"-O3" ,
124
122
"-c" ,
123
+ # Shorten full absolute file paths in the generated code (like the
124
+ # __FILE__ macro and assert failure messages) for reproducibility:
125
+ f"-ffile-prefix-map={ CPYTHON } =." ,
126
+ f"-ffile-prefix-map={ tempdir } =." ,
125
127
# This debug info isn't necessary, and bloats out the JIT'ed code.
126
128
# We *may* be able to re-enable this, process it, and JIT it for a
127
129
# nicer debugging experience... but that needs a lot more research:
@@ -167,7 +169,12 @@ async def _build_stencils(self) -> dict[str, _stencils.StencilGroup]:
167
169
c .write_text (template .replace ("CASE" , case ))
168
170
coro = self ._compile (opname , c , work )
169
171
tasks .append (group .create_task (coro , name = opname ))
170
- return {task .get_name (): task .result () for task in tasks }
172
+ stencil_groups = {task .get_name (): task .result () for task in tasks }
173
+ for stencil_group in stencil_groups .values ():
174
+ stencil_group .process_relocations (
175
+ known_symbols = self .known_symbols , alignment = self .alignment
176
+ )
177
+ return stencil_groups
171
178
172
179
def build (
173
180
self , out : pathlib .Path , * , comment : str = "" , force : bool = False
0 commit comments