[clang] [clang modules] Setting `DebugCompilationDir` when it is safe to ignore current working directory (PR #128446)
Cyndy Ishida via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 25 10:33:59 PST 2025
================
@@ -492,8 +492,23 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
auto &FSOpts = const_cast<FileSystemOptions &>(CI.getFileSystemOpts());
if (CWD && !IgnoreCWD)
HashBuilder.add(*CWD);
- else
+ else {
FSOpts.WorkingDir.clear();
+ auto &CGOpts = const_cast<CodeGenOptions &>(CI.getCodeGenOpts());
+ if (CGOpts.DwarfVersion && CWD) {
+ // It is necessary to explicitly set the DebugCompilationDir
+ // to a common directory (e.g. root) if IgnoreCWD is true.
+ // When IgnoreCWD is true, the module's content should not depend
+ // on the current working directory. However, if dwarf information
+ // is needed (when CGOpts.DwarfVersion is non-zero), and if
+ // CGOpts.DebugCompilationDir is not explicitly set,
+ // the current working directory will be automatically embedded
+ // in the dwarf information in the pcm, contradicting the assumption
+ // that it is safe to ignore the CWD. Thus in such cases,
----------------
cyndyishida wrote:
How does lldb use the CWD encoded in the PCM? Would it better/possible to avoid setting `CGOpts.DebugCompilationDir` when `IgnoreCWD == true` ?
https://github.com/llvm/llvm-project/pull/128446
More information about the cfe-commits
mailing list