[rb-general] [PATCH] gcc: read -fdebug-prefix-map OLD from environment (improved reproducibility)

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Dec 11 20:14:03 CET 2015

On Fri 2015-12-11 12:03:28 -0500, Bernd Schmidt wrote:
> On 12/11/2015 05:49 PM, Daniel Kahn Gillmor wrote:
>> I've re-rolled the patch (attached below, here) to use the ENV: prefix
>> instead of the $.
> It might be irrelevant at this point, but the "ENV:" prefix is used in 
> AmigaOS and could be part of a filename.

As a full-path prefix?

>> +  if (0 == strncmp(ENV_PREFIX, arg, ENV_PREFIX_OFFSET))
>> +    {
>> +      env = xstrndup (arg+ENV_PREFIX_OFFSET, p - (arg+ENV_PREFIX_OFFSET));
> Spaces before ( and around operators like +. Please review our coding 
> guidelines and have a look at the surrounding code.

right, sorry about that.  Attached at the bottom of this mail is a patch
that i think should clean this up.  (i've also updated bugzilla
correctly after a couple tries -- sorry for the noise there)

> Wouldn't it be simpler just to special-case -fdebug-prefix-map in 
> gen_producer_string? The environment variable thing strikes me as 
> unnecessary.

I think you mean so that we would just ignore -fdebug-prefix-map
entirely when writing DW_AT_producer, so that you could build
reproducibly with (for example):

 gcc -fdebug-prefix-map=$(pwd)=/usr/src

We'd considered and discarded this approach in the past out of concern
for possible build systems that can easily vary the environment, but
work with a static list of CFLAGS to pass to the compiler.  On further
inspection, it's not clear that anyone has a concrete example of a build
system with this constraint.

Here's a one-liner patch for this approach (also at

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gcc-ignore-fdebug-prefix-map-in-DW_AT_producer-impro.patch
Type: text/x-diff
Size: 1836 bytes
Desc: not available
URL: <http://lists.reproducible-builds.org/pipermail/rb-general/attachments/20151211/dd882e6c/attachment.patch>
-------------- next part --------------

And here's the revised ENV:-prefixed approach with corrected coding
conventions (also at

-------------- next part --------------
A non-text attachment was scrubbed...
Name: v3-0001-gcc-read-fdebug-prefix-map-OLD-from-environment-i.patch
Type: text/x-diff
Size: 4442 bytes
Desc: not available
URL: <http://lists.reproducible-builds.org/pipermail/rb-general/attachments/20151211/dd882e6c/attachment-0001.patch>
-------------- next part --------------

I've tested both patches and they work for me, independently.

Thanks for your consideration,


More information about the rb-general mailing list