From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E67D03858D20; Fri, 21 Apr 2023 22:58:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E67D03858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682117904; bh=9YV0sRUJHQgJVt35KWuie+9D6+dfwHKvjuh5wphYl2c=; h=From:To:Subject:Date:From; b=x26Z3z3niOUQjRnXmsoXyzkrheI78fUqXzGyjGrOXlNa5dijjYMuCN7KNT3kET1O1 zoH9sjqHqbws0Rd5tPJvmxs+mVWkk+XtqYLdjrEsYCEWmjQzomKs+n8om32eqBYzOJ d4twHXH0Owb5BxEPdcf9EhfZAENY5PTHUSyg1jkI= From: "i at maskray dot me" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/109591] New: Multiple -fdebug-prefix-map= prefixes match, which one wins? Date: Fri, 21 Apr 2023 22:58:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i at maskray dot me X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109591 Bug ID: 109591 Summary: Multiple -fdebug-prefix-map=3D prefixes match, which one wins? Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: i at maskray dot me Target Milestone: --- mkdir -p a/b/c echo 'int main(){}' > a/b/c/d.c ~/Dev/gcc/out/release/gcc/xgcc -B ~/Dev/gcc/out/release/gcc -g -c -fdebug-prefix-map=3Da/b/c=3Dz -fdebug-prefix-map=3Da/b=3Dy -fdebug-prefix-= map=3Da=3Dx a/b/c/d.c objdump -Wi d.o | grep 'd\.c' # <12> DW_AT_name : (indirect line string, offset: 0): x/b/c/d.c ~/Dev/gcc/out/release/gcc/xgcc -B ~/Dev/gcc/out/release/gcc -g -c -fdebug-prefix-map=3Da=3Dx -fdebug-prefix-map=3Da/b=3Dy -fdebug-prefix-map= =3Da/b/c=3Dz a/b/c/d.c objdump -Wi d.o | grep 'd\.c' # <12> DW_AT_name : (indirect line string, offset: 0): z/d.c return When multiple -fdebug-prefix-map=3D options are applicable, it seems that t= he last wins. In Clang, after https://reviews.llvm.org/D49466 (landed in Nov 2019), the longest prefix wins. clang -g -c -fdebug-prefix-map=3Da=3Dx -fdebug-prefix-map=3Da/b=3Dy -fdebug-prefix-map=3Da/b/c=3Dz a/b/c/d.c # z/d.c clang -g -c -fdebug-prefix-map=3Da=3Dx -fdebug-prefix-map=3Da/b=3Dy -fdebug-prefix-map=3Da/b/c=3Dz a/b/c/d.c # z/d.c This issue is motivated by https://reviews.llvm.org/D148757 --- Related, there is a strange use case where the old prefix is empty. The new prefix may or may not end with a slash: '-fdebug-prefix-map=3D=3Dw' and '-fdebug-prefix-map=3D=3Dw/'. '-fdebug-prefix-map=3D=3Dw' changes the file name to wa/b/c/d.c . I am unsu= re whether it should be w/a/b/c/d.c instead. Clang has the same problem.=