Skip to content

Commit

Permalink
Keep full paths from leaking into the generated file
Browse files Browse the repository at this point in the history
  • Loading branch information
brandtbucher committed Oct 24, 2024
1 parent 34653bb commit a45a6f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Tools/jit/_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ async def _parse(self, path: pathlib.Path) -> _stencils.StencilGroup:
args = ["--disassemble", "--reloc", f"{path}"]
output = await _llvm.maybe_run("llvm-objdump", args, echo=self.verbose)
if output is not None:
# Make sure that full paths don't leak out (for reproducibility):
long, short = str(path), str(path.name)
group.code.disassembly.extend(
line.expandtabs().strip()
line.expandtabs().strip().replace(long, short)
for line in output.splitlines()
if not line.isspace()
)
args = [
"--elf-output-style=JSON",
Expand Down Expand Up @@ -130,6 +131,10 @@ async def _compile(
f"-I{CPYTHON / 'Python'}",
"-O3",
"-c",
# Shorten full absolute file paths in the generated code (like the
# __FILE__ macro and assert failure messages) for reproducibility:
f"-ffile-prefix-map={CPYTHON}=.",
f"-ffile-prefix-map={tempdir}=.",
# This debug info isn't necessary, and bloats out the JIT'ed code.
# We *may* be able to re-enable this, process it, and JIT it for a
# nicer debugging experience... but that needs a lot more research:
Expand Down
2 changes: 1 addition & 1 deletion Tools/jit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import _targets

if __name__ == "__main__":
comment = f"$ {shlex.join([sys.executable] + sys.argv)}"
comment = f"$ {shlex.join([pathlib.Path(sys.executable).name] + sys.argv)}"
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"target", type=_targets.get_target, help="a PEP 11 target triple to compile for"
Expand Down

0 comments on commit a45a6f6

Please sign in to comment.