[Reproducible-builds] Minimising work needed for this build-path issue
infinity0 at debian.org
Wed Aug 24 11:20:00 UTC 2016
I'm thinking of ways to minimise the work needed to fix the build path issues that we're having.
The present method is that dpkg-buildflags sets "-fdebug-prefix-map=$PWD=." into various *FLAGS envvars, and Make (or another build tool) will pass this to gcc. This works if and only if the package uses dpkg-buildflags, which granted is most of them.
However, I am not sure if this is the best approach. At present, the output of dpkg-buildflags is itself dependent on the build-path, and some packages *might* save this value somewhere in their output. (This is the case for perl, although in perl's specific case this seems fixable.)
However the question is, do we want to do this every time an upstream saves CFLAGS somewhere?
It is after all a part of the "reasonable" build input - i.e. it is reasonable that whatever is in CFLAGS will affect the build output, so saving it in arbitrary ways isn't an "unreasonable" thing for upstream packages to do. We will have to educate everyone "please filter out debug-prefix-map from CFLAGS before you save it somewhere" and this adds extra complexity to the whole ecosystem.
So, here are some other approaches:
1. Patch GCC to set debug-prefix-map to "$pwd=." by default (and the analogue for other languages / tools).
This behaviour is concretely different from the current situation: during recursive-make scenarios, the gcc in subdirectories will have different values for debug-prefix-map. Our current situtation OTOH is that dpkg-buildflags is called once at the top-level directory, and this value persists for all gcc subchildren for the whole build (unless the upstream buildscripts do something weird to CFLAGS).
If the behaviour were not different, I would strongly suggest "let's just do this". But it's different, and I'm not sure what consequences that would have. I'm looking for your comments on this.
Note that for languages that define "the path is the namespace" like golang or java, this does not really matter. So in these cases I strongly suggest patching the tool itself, instead of adding extra command-line flags.
2. Define another variable SOURCE_ROOT to be set to the top-level source dir, and patch GCC to use this as the default value for debug-prefix-map (and the analogue for other languages / tools).
This would have the same concrete behaviour as the current situation, but then we're defining yet another variable... but probably less tools will need to support this than SOURCE_DATE_EPOCH. And as with (1), this would not be necessary for the path-is-namespace languages.
More information about the Reproducible-builds