[clang modules] Setting DebugCompilationDir when it is safe to ignore current working directory (#128446)
#10124
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR explicitly sets
DebugCompilationDirto the system's root directory if it is safe to ignore the current working directory.This fixes a problem where a PCM file's embedded debug information can lead to compilation failure. The compiler may have decided it is indeed safe to ignore the current working directory. In this case, the PCM file's content is functionally correct regardless of the current working directory because no inputs use relative paths (see llvm#124786). However, a PCM may contain debug info. If debug info is requested, the compiler uses the current working directory value to set
DW_AT_comp_dir. This may lead to the following situation:DW_AT_comp_dir, which is embedded in the debug info.This PR resets the
DebugCompilationDirif it is functionally safe to ignore the working directory so the above situation is avoided, since all debug information will share the same working directory.rdar://145249881
(cherry picked from commit 7f482aa)
Conflicts:
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp