On Mon, 27 Feb 2023 08:45:24 +0100 Gioele Barabucci <[email protected]> wrote:
`dtrace -G` creates temporary files with random filenames. The name of these temporary files gets embedded in the ELF `.symtab` of the final object files, making them always slightly different.

The root cause of this issue is that, although the name of the temporary file is created in a deterministic way (from the SHA256 of the source file), the name of the source file is overwritten with a random name then the `-C` option (`use_cpp`) is used:

```
if s_filename != "" and use_cpp:
    (ignore, fname) = mkstemp(suffix=".d")
    cpp = os.environ.get("CPP", "cpp")
    retcode = call(split(cpp) + [...] + [s_filename, '-o', fname])
    if retcode != 0:
        print("\"cpp includes s_filename\" failed")
        usage()
        return 1
    s_filename = fname

[...]

# for reproducible-builds purposes, use a predictable tmpfile path
sha = hashlib.sha256()
sha.update(s_filename.encode('utf-8'))
sha.update(filename.encode('utf-8'))
fname = ".dtrace-temp." + sha.hexdigest()[:8] + ".c"
```

Could you please replace the use of `mkstemp` with something similar to what is used to determine the final temporary filename?

--
Gioele Barabucci

Reply via email to