Skip to content

[6.2][clang][DebugInfo] Handle empty comp_dir in CodeGen #11125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: swift/release/6.2
Choose a base branch
from

Conversation

cachemeifyoucan
Copy link

@cachemeifyoucan cachemeifyoucan commented Aug 5, 2025

  • Explanation: Fix a logic mistake in DebugInfo CodeGen that if the compilation directory is empty, the leading separator is dropped with emitting path. This code path is usually not possible in current state unless the compilation is done from a file system that do not have current working directory and compilation caching include tree file system is such a file system.
  • Scope: This is affecting all swift caching compilation, and can cause dsymutil warning, loss of debug info that can lead to variable view missing items, debugging inline functions when using swift caching.
  • Issues: rdar://156759645
  • Original PRs: [clang][CodeGen] Remove CWD fallback in compilation directory llvm/llvm-project#150130 (only a subset from upstream is taken)
  • Risk: Low. This code path should affect only caching compilation and the logic is quite simple.
  • Testing: Unit test (tests are in swift repo [TEST-ONLY] Check swift generated PCM has correct dwo path swift#83549).
  • Reviewers: @adrian-prantl

Fix a logic mistake in DebugInfo CodeGen that if the compilation
directory is empty, the leading separator is dropped with emitting path.
This code path is usually not possible in current state unless the
compilation is done from a file system that do not have current working
directory and compilation caching include tree file system is such a
file system. This causes PCMs are encoded with wrong path in the
gmodule compilation, causing lost of debug info.

Note this is a reduced and safer version from upstream fix:
llvm#150130

The test is in swift repo since the only trigger in current branch is to
trigger from swift caching builds.

rdar://156759645
@cachemeifyoucan cachemeifyoucan requested a review from a team as a code owner August 5, 2025 20:56
@cachemeifyoucan cachemeifyoucan changed the title [clang][DebugInfo] Handle empty comp_dir in CodeGen [6.2][clang][DebugInfo] Handle empty comp_dir in CodeGen Aug 5, 2025
@cachemeifyoucan
Copy link
Author

Please test with following PR:
swiftlang/swift#83549

@swift-ci please test

@cachemeifyoucan
Copy link
Author

Please test with following PR:
swiftlang/swift#83549

@swift-ci please test

Copy link

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on that all non-caching compilations have a non-empty CompDir, this looks safe to me.

@cachemeifyoucan
Copy link
Author

Please test with following PR:
swiftlang/swift#83549

@swift-ci please test windows platform

@cachemeifyoucan
Copy link
Author

All tests passed. The test in swift repo also passed. Please merge them together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants