This is an archive of the discontinued LLVM Phabricator instance.

re-land: [clang] Fix absolute file paths with -fdebug-prefix-map
AbandonedPublic

Authored by keith on Oct 11 2021, 5:01 PM.

Details

Reviewers
probinson
Summary

Previously if you passed an absolute path to clang, where only part of
the path to the file was remapped, it would result in the file's DIFile
being stored with a duplicate path, for example:

!DIFile(filename: "./ios/Sources/bar.c", directory: "./ios/Sources")

This change handles absolute paths, specifically in the case they are
remapped to something relative, and uses the dirname for the directory,
and basename for the filename.

This also adds a test verifying this behavior for more standard uses as
well.

This reverts commit 68e49aea9ac4dca550df70706cc845de04939c03.

Diff Detail

Event Timeline

keith requested review of this revision.Oct 11 2021, 5:01 PM
keith created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 11 2021, 5:01 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
keith added a comment.Oct 11 2021, 5:02 PM

This broke tests on windows (see the new parent revisions in the stack) otherwise the actual change's behavior, outside of the tests, is unchanged

keith updated this revision to Diff 411576.Feb 25 2022, 9:26 PM

Update test with new specifiers

keith updated this revision to Diff 411923.Feb 28 2022, 4:11 PM

Update test with new variable names

keith updated this revision to Diff 411926.Feb 28 2022, 4:20 PM

Fix parent revisions

keith updated this revision to Diff 415292.Mar 14 2022, 6:11 PM

Update subsitutions with slashes

Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 6:11 PM
keith updated this revision to Diff 415307.Mar 14 2022, 8:42 PM

Fix tests with dwarf 6

Fix tests with dwarf 6

Do you mean dwarf 5 here? There is no v6 yet.

clang/test/Modules/module-debuginfo-prefix.m
24

Does this want to be
"%{fs-src-root}OVERRIDE%{fs-sep}DebugObjC.h" ?

keith added a comment.Mar 15 2022, 9:18 AM

I actually mean dwarf 6, which appears to be partially implemented according to https://lists.llvm.org/pipermail/llvm-dev/2020-April/141055.html

I discovered the issue from the failed tests on https://reviews.llvm.org/D113718 where you can see the test output contains a checksum that otherwise doesn't appear. Passing -dwarf-version=6 reproduces the issue.

clang/test/Modules/module-debuginfo-prefix.m
24

That can only be used in the RUN invocations, but unfortunately regardless it could be used here because of the escaped backslashes, so it requires a regex like this instead

I actually mean dwarf 6, which appears to be partially implemented according to https://lists.llvm.org/pipermail/llvm-dev/2020-April/141055.html

I discovered the issue from the failed tests on https://reviews.llvm.org/D113718 where you can see the test output contains a checksum that otherwise doesn't appear. Passing -dwarf-version=6 reproduces the issue.

That link describes extensions that might or might not become part of dwarf 6 in the future. But there is no "dwarf 6" today. I did a quick grep and don't see any places that check for v6. File checksums are part of dwarf 5, so presumably the failure reproduces with -dwarf-version=5 as well? That would make more sense.

If you really do need -dwarf-version=6 to reproduce the problem, then somebody has done something very wrong. Sorry to hold up your review but I very much want to get this clarified.

clang/test/Modules/module-debuginfo-prefix.m
24

Ah, got it.

keith added a comment.Mar 15 2022, 1:37 PM

You're right it's version 5 not 4, maybe the issue is that some platforms (like macOS) are defaulting to 4 intentionally for now? I guess I thought 6 because passing 6 also reproduces, but I didn't also try 5.

keith abandoned this revision.Mar 15 2022, 1:43 PM

There were 2 competing revisions for this bug fix, I landed https://reviews.llvm.org/D121663 instead since it sounds like having an empty directory is more correct in this case

You're right it's version 5 not 4, maybe the issue is that some platforms (like macOS) are defaulting to 4 intentionally for now? I guess I thought 6 because passing 6 also reproduces, but I didn't also try 5.

Yes, some platforms default to 4. Thanks for verifying!