From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id A7666385840F for ; Mon, 15 Aug 2022 19:56:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A7666385840F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (unknown [178.226.219.83]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 3D149300070C; Mon, 15 Aug 2022 21:55:55 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id 694422E801C9; Mon, 15 Aug 2022 21:55:52 +0200 (CEST) Date: Mon, 15 Aug 2022 21:55:52 +0200 From: Mark Wielaard To: Richard Purdie Cc: gcc@gcc.gnu.org, Khem Raj , Sergio Durigan Junior Subject: Re: Reproducible builds - supporting relative paths in *-prefix-map Message-ID: References: <1c0ab23fd0cc1bc34a229287529963526141327a.camel@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1c0ab23fd0cc1bc34a229287529963526141327a.camel@linuxfoundation.org> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Aug 2022 19:56:03 -0000 Hi Richard, I added Sergio to the CC since he was looking at debuginfo/DWARF relative paths created by -fdebug-prefix-map in Debian and having trouble making them work correctly. Maybe he has some feedback how to make this work. On Mon, Aug 15, 2022 at 12:13:28PM +0100, Richard Purdie via Gcc wrote: > I'm wondering if we'd be able to improve path handling in the -f*- > prefix-map compiler options to cover relative paths? > [...] > In case it helps, my background on what I'm working on and why we'd > find this useful follows:  > > I work on Yocto Project which cross compiles complete software stacks, > we use gcc heavily and the resulting builds are all around us. We care > deeply about build reproducibility. > > With autotools, we long ago realised that we were best off separating > the source and the build output where we could and to do it we used > relative paths, which removed a lot of problematic hardcoded paths in > our output. > > More recently we've been using -fdebug-prefix-map and -fmacro-prefix- > map (we need both since some of binutils doesn't seem to support the > combined version yet). We use the debug information (split separately) > to support on target debugging but where relative paths were used, we > miss information as the remapping either doesn't happen correctly or is > mangled. We'd like to fix our debug output but we're finding that hard > without relative path support for *prefix-map. I might be misinterpreting the issue you are seeing. But one problem with debuginfo/DWARF is that relative source paths aren't clearly defined. If you move or install the executable or (split) debug file out of the build directory a DWARF reader has no way to know what the paths are relative to. So for DWARF the paths always have to be absolute (they can still be relative to the compilation dir (DW_AT_comp_dir), but at least that has to be absolute (and the compiler should turn any relative path into an absolute one or make sure they are relative to an absolute compilation directory path). The problem with that is a) it makes the binary (debuginfo) output dependent on the build srcdir and builddir and b) to support debugging/tracing/profiling tools the user has to install the (debug) sources under those exact same directories on their local machine. One way around this is to use -fdebug-prefix-map with an absolute paths under which you will also install any source files. Or to use debugedit [*] after the build to rewrite the build dir path to something like /usr/debug/src/ which is what some distros do. e.g. Fedora has (one or more) binary package, a debuginfo package for the .debug files (optionally installed under /usr/lib/debug) and debugsource package for the debug source files (optionally installed under /usr/debug/src). These packages can then also be used to dynamically find any debug or source file when indexed by debuginfod [**]. Using known absolute paths generated with debugedit or -fdebug-prefix-map makes sure the paths used in the debuginfo/DWARF are always the same independent from the current srcdir or builddir to make them reproducible. And the user/tools don't have to guess what the relative paths are relative to. And it makes it so you can install the (debug) source files of all packages/versions/arches in parallel without file conflicts. Cheers, Mark [*] https://sourceware.org/debugedit/ [**] http://debuginfod.elfutils.org/