[Reproducible-builds] Minimising work needed for this build-path issue
infinity0 at debian.org
Tue Oct 25 12:29:00 UTC 2016
> [..] I was trying to come to agreement on the exact form the proposal should take.
> The behaviour is already settled:
> if path.startswith(R):
> newprefix = P or "."
> path = newprefix + path[len(R):]
> [..] What I'm asking is suggestions on how we should get R and P into the actual program. [..]
So, to give people an example of the possible different choices we have:
In all cases, we want to do:
path = newprefix + path[len(oldprefix):]
and the question is what concrete mechanism we want to set (oldprefix, newprefix) by.
oldprefix = getenv("SOURCE_ROOT_DIR")
newprefix = getenv("SOURCE_ROOT_PREFIX") or "."
Pros: Simple, easy to understand. Works almost exactly as debug-prefix-map which has already existed for ages in GCC.
Cons: Uses two environment variables.
oldprefix, newprefix = getenv("SOURCE_PREFIX_MAP").split("=", 1)
Pros: Works *exactly* as debug-prefix-map
Cons: Have to parse the thing. GCC splits on the first "=" but I found this out by looking at the source code (gcc/final.c:add_debug_prefix_map), it's not explicitly documented. Someone else could split at the last "=" for example.
oldprefix = getenv("ALLSOURCES_DIR")
newprefix = "."
Oh em gee what is going on here? Well this is a slight hack. Instead of setting SOURCE_ROOT_DIR=/build/blahblah we set ALLSOURCES_DIR=/build so that "blahblah" remains in the build output. This is analogous to the difference between "datadir = /usr/share/@PACKAGE@" vs "datarootdir = /usr/share" (in GNU installation directories naming conventions).
Pros: Simple for implementers, one environment variable that doesn't have to be parsed.
Cons: Requires reproducers to do the build in a directory called "blahblah". At least, everyone can do this - if you can't create directories with arbitrary names, you probably can't set environment variables either. However it does mix up two different mechanisms (env var + directory naming) to achieve reproducibility.
More information about the Reproducible-builds