https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101473

--- Comment #17 from tonyb at cybernetics dot com ---
(In reply to Richard Biener from comment #16)
> I'm interested if remaining differences are due to the same underlying issue
> or not

I tested your updated patch with gcc 10.2 (I had to make a small change due to
the definition of struct dwarf_file_data being in dwarf2out.c rather than
dwarf2out.h in gcc 10.2).  I got the same results as before, with the same list
of files being non-reproducible.  I decided to debug the problem with pciutils.
 For pciutils, the problem was caused by the following:

Yocto CFLAGS contains -ffile-prefix-map but LDFLAGS doesn't.
The pciutils Makefile compiles *.c files to *.o files with CFLAGS and links
them with LDFLAGS but not CFLAGS.
With LTO disabled, this results in a reproducible binary, but with LTO enabled,
this results in a non-reproducible binary.

So I can workaround by adding -ffile-prefix-map to LDFLAGS.

So is this considered a bug?  If the prefix map translation can be handled
completely before generating the *.o file, then it could be fixed in gcc, but I
am not sure how it all works.  One solution that is apparently off the table is
embedding the prefix map in the *.o file, since that would make the *.o file
non-reproducible (see e.g. bug 68848; apparently the prefix map used to be
present in the *.o file but was removed in some recent version of gcc).

If this issue is not considered a bug, then I will pass on to the Yocto people
that they should use -ffile-prefix-map in LDFLAGS in addition to CFLAGS, and
you can close this PR.

I haven't looked into the other packages that were not reproducible, but I
suspect the same issue.

I will attach a test script that shows the issue if you want to debug it
further.

Reply via email to