Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: support reproducible buildid when building with -trimpath #34186
When building with the new
#16860 implemented the -trimpath flag, stripping the paths successfully. But apparently the buildid still gets the path taken into account in its actionID parts.
Resulting in different non-reproducible builds when building the same source from different paths.
For source in folder
for source in folder
This is the only thing different in the resulting binary. Is that intentional? It would be nice for reproducible builds if the buildid could be the same no matter in what folder the source is actually built.
For the time being i use a small Python script to override the different parts in the resulting binary like this
buildid = subprocess.check_output([go, 'tool', 'buildid', fn]).strip() actionid = b'/'.join(buildid.split(b'/', 2)[:2]) with open(fn, 'r+b') as f: data = f.read() idx = data.find(actionid) if idx == -1: raise ValueError('actionid not found in file') f.seek(idx) f.write(b'0'*(len(actionid)-2)) f.write(b'/0')
but this might not be very reliable. Can this be improved?
Thanks for reporting this.
This is a dup of #33772.
It would be useful if you could confirm that the workaround mentioned at #33772 (comment) works for you.