@@ -61,10 +61,11 @@ async def _parse(self, path: pathlib.Path) -> _stencils.StencilGroup:
6161 args = ["--disassemble" , "--reloc" , f"{ path } " ]
6262 output = await _llvm .maybe_run ("llvm-objdump" , args , echo = self .verbose )
6363 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 )
6466 group .code .disassembly .extend (
65- line .expandtabs ().strip ()
67+ line .expandtabs ().strip (). replace ( long , short )
6668 for line in output .splitlines ()
67- if not line .isspace ()
6869 )
6970 args = [
7071 "--elf-output-style=JSON" ,
@@ -90,9 +91,6 @@ async def _parse(self, path: pathlib.Path) -> _stencils.StencilGroup:
9091 if group .data .body :
9192 line = f"0: { str (bytes (group .data .body )).removeprefix ('b' )} "
9293 group .data .disassembly .append (line )
93- group .process_relocations (
94- known_symbols = self .known_symbols , alignment = self .alignment
95- )
9694 return group
9795
9896 def _handle_section (self , section : _S , group : _stencils .StencilGroup ) -> None :
@@ -122,6 +120,10 @@ async def _compile(
122120 f"-I{ CPYTHON / 'Tools' / 'jit' } " ,
123121 "-O3" ,
124122 "-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 } =." ,
125127 # This debug info isn't necessary, and bloats out the JIT'ed code.
126128 # We *may* be able to re-enable this, process it, and JIT it for a
127129 # nicer debugging experience... but that needs a lot more research:
@@ -167,7 +169,12 @@ async def _build_stencils(self) -> dict[str, _stencils.StencilGroup]:
167169 c .write_text (template .replace ("CASE" , case ))
168170 coro = self ._compile (opname , c , work )
169171 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
171178
172179 def build (
173180 self , out : pathlib .Path , * , comment : str = "" , force : bool = False
0 commit comments