NetBSD Problem Report #55802
From gson@gson.org Wed Nov 11 12:30:49 2020
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 007361A923A
for <gnats-bugs@gnats.NetBSD.org>; Wed, 11 Nov 2020 12:30:48 +0000 (UTC)
Message-Id: <20201111123044.3370D253DC1@guava.gson.org>
Date: Wed, 11 Nov 2020 14:30:44 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: Reproducible builds aren't
X-Send-Pr-Version: 3.95
>Number: 55802
>Category: misc
>Synopsis: Reproducible builds aren't
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: misc-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 11 12:35:00 +0000 2020
>Closed-Date: Sat Jun 18 08:07:37 +0000 2022
>Last-Modified: Sat Jun 18 08:10:02 +0000 2022
>Originator: Andreas Gustafsson
>Release: NetBSD-current
>Organization:
>Environment:
System: NetBSD
Architecture: x86_64
Machine: amd64
>Description:
If I download, install, and boot a daily build, for example
http://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/202011092220Z/amd64/
including the debug and source sets, when I try to debug a userland
program using gdb, it fails to find the sources:
# gdb sync
(gdb) l main
47 /home/source/ab/HEAD/src/bin/sync/sync.c: No such file or directory.
According to /etc/release, this is a MKREPRO build, so it shouldn't
contain any references to paths on the build system such as the
/home/source/ab/HEAD path above.
>How-To-Repeat:
install misc/py-anita 2.8 and emulators/qemu from pkgsrc
anita --disk-size 10G --memory-size 256M --sets kern-GENERIC,modules,base,etc,comp,games,man,misc,tests,text,syssrc,src,sharesrc,gnusrc,debug interact http://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/202011092220Z/amd64/
login: root
gdb sync
l main
>Fix:
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55802 CVS commit: src/external/gpl3/gcc/dist/gcc
Date: Sat, 14 Nov 2020 16:24:03 -0500
Module Name: src
Committed By: christos
Date: Sat Nov 14 21:24:03 UTC 2020
Modified Files:
src/external/gpl3/gcc/dist/gcc: file-prefix-map.c
Log Message:
PR/55802: Andreas Gustafsson: Unbreak reproducible builds.
For reproducible builds to work we need to have a consistent command
line (because the command line gets recorded in dwarf). So we can't
do:
-ffile-prefix-map=/joe/random/src=/usr/src
because then /joe/random/src gets recorded. We do instead:
-ffile-prefix-map=\$NETBSDSRCDIR=/usr/src
The patch restores the environment variable parsing that got lost
in the last 2 gcc upgrades.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/gcc/dist/gcc/file-prefix-map.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Andreas Gustafsson <gson@gson.org>
To: "Christos Zoulas" <christos@netbsd.org>
Cc: gnats-bugs@netbsd.org
Subject: Re: PR/55802 CVS commit: src/external/gpl3/gcc/dist/gcc
Date: Mon, 16 Nov 2020 11:04:40 +0200
Christos Zoulas committed:
> cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/gcc/dist/gcc/file-prefix-map.c
Thanks, I can confirm that after this fix, gdb finds the sources.
I have not checked whether the entire release is now reproducible.
> For reproducible builds to work we need to have a consistent command
> line (because the command line gets recorded in dwarf). So we can't
> do:
>
> -ffile-prefix-map=/joe/random/src=/usr/src
>
> because then /joe/random/src gets recorded. We do instead:
>
> -ffile-prefix-map=\$NETBSDSRCDIR=/usr/src
>
> The patch restores the environment variable parsing that got lost
> in the last 2 gcc upgrades.
Is this really still necessary, though - hasn't gcc been fixed to not
store the original lefthand side of the file mapping options by now?
--
Andreas Gustafsson, gson@gson.org
State-Changed-From-To: open->feedback
State-Changed-By: kre@NetBSD.org
State-Changed-When: Fri, 17 Jun 2022 04:49:32 +0000
State-Changed-Why:
This looks to have been fixed by christos@ and confirmed fixed by
you after that.
Is there any reason to keep this PR open?
From: Andreas Gustafsson <gson@gson.org>
To: kre@NetBSD.org, christos@NetBSD.org
Cc: gnats-bugs@netbsd.org
Subject: Re: misc/55802 (Reproducible builds aren't)
Date: Fri, 17 Jun 2022 16:41:50 +0300
kre@NetBSD.org wrote:
> Is there any reason to keep this PR open?
It would be nice if Christos could answer the question I asked on
16 Nov 2020; it seems to me that there is an opportunity for an
alternative fix involving fewer local modifications to gcc. But the
present fix does work, and if you want to close the PR, I won't
object.
--
Andreas Gustafsson, gson@gson.org
From: Christos Zoulas <christos@zoulas.com>
To: gnats-bugs@netbsd.org
Cc: misc-bug-people@netbsd.org,
gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org,
Andreas Gustafsson <gson@gson.org>
Subject: Re: misc/55802 (Reproducible builds aren't)
Date: Fri, 17 Jun 2022 10:24:23 -0400
--Apple-Mail=_E65CE3DD-3CAA-4D26-ACA2-8A6285212928
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii
> On Jun 17, 2022, at 9:45 AM, Andreas Gustafsson <gson@gson.org> wrote:
>=20
> It would be nice if Christos could answer the question I asked on
> 16 Nov 2020; it seems to me that there is an opportunity for an
> alternative fix involving fewer local modifications to gcc. But the
> present fix does work, and if you want to close the PR, I won't
> object.
I don't know. I don't see the string $NETBSDSRCDIR using readelf =
--debug-dump
in the files in /usr/libdata/debug on gcc-10.3 and gcc-9.3 systems and I =
don't have
anything older than that. I guess one way to test is to break it on =
purpose
(i.e. change the .mk file to expand the variable instead of having gcc =
do it,
then check the reproducible builds website after a week :-)
This is not the only patch that we have for gcc though: =
--debug-regex-map is more
complicated and still needed to handle OBJDIRs...
cvs diff -r FSF in /usr/src/external/gpl3/gcc/dist
is instructive :-)
A lot of that should be upstreamed...
christos
--Apple-Mail=_E65CE3DD-3CAA-4D26-ACA2-8A6285212928
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=signature.asc
Content-Type: application/pgp-signature;
name=signature.asc
Content-Description: Message signed with OpenPGP
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCYqyOlwAKCRBxESqxbLM7
OpCEAKDlURZaG3s4YhpYKF4rw143Db6dvgCfeXGOeMpMuaegVjj5asPNitrbmo0=
=58LN
-----END PGP SIGNATURE-----
--Apple-Mail=_E65CE3DD-3CAA-4D26-ACA2-8A6285212928--
From: Andreas Gustafsson <gson@gson.org>
To: Christos Zoulas <christos@zoulas.com>
Cc: gnats-bugs@netbsd.org
Subject: Re: misc/55802 (Reproducible builds aren't)
Date: Fri, 17 Jun 2022 18:16:03 +0300
Christos,
You wrote:
> in the files in /usr/libdata/debug on gcc-10.3 and gcc-9.3 systems
> and I don't have anything older than that.
I think these options are omitted from the dwarf output by
this code in gen_producer_string() dwarf2out.c:
case OPT_fdebug_prefix_map_:
case OPT_fmacro_prefix_map_:
[...]
/* Ignore these. */
> I guess one way to test is to break it on purpose
> (i.e. change the .mk file to expand the variable instead of having gcc do it,
> then check the reproducible builds website after a week :-)
Yes, that should work.
> This is not the only patch that we have for gcc though: --debug-regex-map is more
> complicated and still needed to handle OBJDIRs...
Well, some styles of OBJDIR. If you use "build.sh -O", for example,
the object directory paths still get embedded.
--
Andreas Gustafsson, gson@gson.org
From: Christos Zoulas <christos@zoulas.com>
To: gnats-bugs@netbsd.org
Cc: misc-bug-people@netbsd.org,
gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org,
Andreas Gustafsson <gson@gson.org>
Subject: Re: misc/55802 (Reproducible builds aren't)
Date: Fri, 17 Jun 2022 12:33:16 -0400
--Apple-Mail=_891D9F14-861A-4BAB-AA71-0D6E6F95A970
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii
> On Jun 17, 2022, at 11:20 AM, Andreas Gustafsson <gson@gson.org> =
wrote:
>=20
> I think these options are omitted from the dwarf output by
> this code in gen_producer_string() dwarf2out.c:
>=20
> case OPT_fdebug_prefix_map_:
> case OPT_fmacro_prefix_map_:
> [...]
> /* Ignore these. */
>=20
Then it should be fine. OTOH it is ~10 lines of code to do the expansion =
so it is not a big
issue anyway; also others had come up with the same patch in the past to =
solve the same
issue. The approach above is "hand hurts, cut hand instead".
> Well, some styles of OBJDIR. If you use "build.sh -O", for example,
> the object directory paths still get embedded.
Yes, because only the "standard" objdir patterns are supported; any =
custom ones
will need to be added manually to the list. Perhaps there is a =
programmatic way
to do this, but it is complicated and probably not worth it :-)
christos
--Apple-Mail=_891D9F14-861A-4BAB-AA71-0D6E6F95A970
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=signature.asc
Content-Type: application/pgp-signature;
name=signature.asc
Content-Description: Message signed with OpenPGP
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCYqyszAAKCRBxESqxbLM7
OuTbAKC0STjIa84CSbG4j7F5XqwxZU5DHwCcDeRARj4HLyeYnV9kZ+IvyhSnK0A=
=lVVk
-----END PGP SIGNATURE-----
--Apple-Mail=_891D9F14-861A-4BAB-AA71-0D6E6F95A970--
From: Andreas Gustafsson <gson@gson.org>
To: Christos Zoulas <christos@zoulas.com>
Cc: gnats-bugs@NetBSD.org
Subject: Re: misc/55802 (Reproducible builds aren't)
Date: Fri, 17 Jun 2022 22:11:50 +0300
Christos Zoulas wrote:
> Yes, because only the "standard" objdir patterns are supported; any custom ones
> will need to be added manually to the list. Perhaps there is a programmatic way
> to do this, but it is complicated and probably not worth it :-)
What are these "objdir patterns" - are they documented somewhere?
The build.sh examples in https://www.netbsd.org/docs/guide/en/chap-build.html
all use -O; if that's not the correct way to specify the objdir, what is?
--
Andreas Gustafsson, gson@gson.org
From: Christos Zoulas <christos@zoulas.com>
To: Andreas Gustafsson <gson@gson.org>
Cc: "gnats-bugs@netbsd.org" <gnats-bugs@NetBSD.org>
Subject: Re: misc/55802 (Reproducible builds aren't)
Date: Fri, 17 Jun 2022 15:50:30 -0400
--Apple-Mail=_3CAAD5FD-625E-4271-876C-C50A43273E04
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii
In bsd.sys.mk:
....
# XXX: Cannot handle MAKEOBJDIR, yet.
REPROFLAGS+=3D -fdebug-regex-map=3D'/usr/src/(.*)/obj$$=3D/usr/obj/\1'
REPROFLAGS+=3D =
-fdebug-regex-map=3D'/usr/src/(.*)/obj/(.*)=3D/usr/obj/\1/\2'
REPROFLAGS+=3D -fdebug-regex-map=3D'/usr/src/(.*)/obj\..*=3D/usr/obj/\1=
'
REPROFLAGS+=3D =
-fdebug-regex-map=3D'/usr/src/(.*)/obj\..*/(.*)=3D/usr/obj/\1/\2'
...
So we only really handle objdirs that start with "obj." or are plain =
"obj" and this is what
OBJMACHINE=3D
OBJMACHINE_ARCH=3D
do.
Best,
christos
--Apple-Mail=_3CAAD5FD-625E-4271-876C-C50A43273E04
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=signature.asc
Content-Type: application/pgp-signature;
name=signature.asc
Content-Description: Message signed with OpenPGP
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCYqzbBgAKCRBxESqxbLM7
OvNKAJ9i9OLi1NEzTrVh/sbr4vS3l5lkUACg4G/+hgSw3M/h3895+sgvAMBnmpI=
=9qD5
-----END PGP SIGNATURE-----
--Apple-Mail=_3CAAD5FD-625E-4271-876C-C50A43273E04--
From: Andreas Gustafsson <gson@gson.org>
To: Christos Zoulas <christos@zoulas.com>
Cc: <gnats-bugs@NetBSD.org>
Subject: Re: misc/55802 (Reproducible builds aren't)
Date: Sat, 18 Jun 2022 09:55:01 +0300
Christos Zoulas wrote:
> In bsd.sys.mk:
> ....
> # XXX: Cannot handle MAKEOBJDIR, yet.
> REPROFLAGS+= -fdebug-regex-map='/usr/src/(.*)/obj$$=/usr/obj/\1'
> REPROFLAGS+= -fdebug-regex-map='/usr/src/(.*)/obj/(.*)=/usr/obj/\1/\2'
> REPROFLAGS+= -fdebug-regex-map='/usr/src/(.*)/obj\..*=/usr/obj/\1'
> REPROFLAGS+= -fdebug-regex-map='/usr/src/(.*)/obj\..*/(.*)=/usr/obj/\1/\2'
> ...
>
> So we only really handle objdirs that start with "obj." or are plain "obj" and this is what
>
> OBJMACHINE=
> OBJMACHINE_ARCH=
>
> do.
It's still not entirely clear to me how this is supposed to translate
to a build.sh command line - I'm guessing "use -M, not -O"?
In any case, this discussion has strayed from the bug the PR was
originally about, so we should probably take it elsewhere and
close the PR.
--
Andreas Gustafsson, gson@gson.org
State-Changed-From-To: feedback->closed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Sat, 18 Jun 2022 08:07:37 +0000
State-Changed-Why:
Reproducible builds are reproducible now, even if we don't
all know how to make them happen, nor understand the magic involved.
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: misc/55802 (Reproducible builds aren't)
Date: Sat, 18 Jun 2022 15:08:03 +0700
Date: Sat, 18 Jun 2022 07:00:03 +0000 (UTC)
From: Andreas Gustafsson <gson@gson.org>
Message-ID: <20220618070003.5CE841A923D@mollari.NetBSD.org>
| In any case, this discussion has strayed from the bug the PR was
| originally about, so we should probably take it elsewhere and
| close the PR.
Agreed. Done.
kre
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.