@@ -847,6 +847,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
847
847
848
848
llvm::DIModule *getOrCreateModule (const void *Key, llvm::DIScope *Parent,
849
849
StringRef Name, StringRef IncludePath,
850
+ StringRef CompDir,
850
851
uint64_t Signature = ~1ULL ,
851
852
StringRef ASTFile = StringRef()) {
852
853
// Look in the cache first.
@@ -856,6 +857,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
856
857
857
858
std::string RemappedIncludePath = DebugPrefixMap.remapPath (IncludePath);
858
859
std::string RemappedASTFile = DebugPrefixMap.remapPath (ASTFile);
860
+ std::string RemappedCompDir = DebugPrefixMap.remapPath (CompDir);
859
861
860
862
// For Clang modules / PCH, create a Skeleton CU pointing to the PCM/PCH.
861
863
if (!Opts.DisableClangModuleSkeletonCUs ) {
@@ -865,7 +867,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
865
867
llvm::DIBuilder DIB (M);
866
868
DIB.createCompileUnit (IGM.ObjCInterop ? llvm::dwarf::DW_LANG_ObjC
867
869
: llvm::dwarf::DW_LANG_C99,
868
- DIB.createFile (Name, RemappedIncludePath ),
870
+ DIB.createFile (Name, RemappedCompDir ),
869
871
TheCU->getProducer (), true , StringRef (), 0 ,
870
872
RemappedASTFile, llvm::DICompileUnit::FullDebug,
871
873
Signature);
@@ -892,12 +894,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
892
894
uint64_t Signature =
893
895
Desc.getSignature () ? Desc.getSignature ().truncatedValue () : ~1ULL ;
894
896
895
- // Clang modules using fmodule-file-home-is-cwd should have their
896
- // include path set to the working directory.
897
- auto &HSI =
898
- CI.getClangPreprocessor ().getHeaderSearchInfo ().getHeaderSearchOpts ();
899
- StringRef IncludePath =
900
- HSI.ModuleFileHomeIsCwd ? Opts.DebugCompilationDir : Desc.getPath ();
897
+ StringRef CompDir = Opts.DebugCompilationDir ;
898
+ StringRef IncludePath = Desc.getPath ();
901
899
902
900
// Handle Clang modules.
903
901
if (ClangModule) {
@@ -919,12 +917,13 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
919
917
ClangModule->Parent );
920
918
}
921
919
return getOrCreateModule (ClangModule, Parent, Desc.getModuleName (),
922
- IncludePath, Signature, Desc.getASTFile ());
920
+ IncludePath, CompDir, Signature,
921
+ Desc.getASTFile ());
923
922
}
924
923
// Handle PCH.
925
924
return getOrCreateModule (Desc.getASTFile ().bytes_begin (), nullptr ,
926
- Desc.getModuleName (), IncludePath, Signature ,
927
- Desc.getASTFile ());
925
+ Desc.getModuleName (), IncludePath, CompDir ,
926
+ Signature, Desc.getASTFile ());
928
927
};
929
928
930
929
static std::optional<ASTSourceDescriptor>
@@ -947,7 +946,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
947
946
// the module on disk is Bar (.swiftmodule or .swiftinterface), and is used
948
947
// for loading and mangling.
949
948
StringRef Name = M->getRealName ().str ();
950
- return getOrCreateModule (M, TheCU, Name, Path);
949
+ return getOrCreateModule (M, TheCU, Name, Path, Opts. DebugCompilationDir );
951
950
}
952
951
953
952
TypeAliasDecl *getMetadataType (StringRef ArchetypeName) {
@@ -2543,8 +2542,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2543
2542
auto Identifier = IGM.getSILModule ().getASTContext ().getIdentifier (
2544
2543
Attribute->ManglingModuleName );
2545
2544
void *Key = (void *)Identifier.get ();
2546
- Scope =
2547
- getOrCreateModule (Key, TheCU, Attribute-> ManglingModuleName , {});
2545
+ Scope = getOrCreateModule (Key, TheCU, Attribute-> ManglingModuleName , {},
2546
+ {});
2548
2547
} else {
2549
2548
Context = ND->getParent ();
2550
2549
}
@@ -2791,7 +2790,8 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
2791
2790
// Create a module for the current compile unit.
2792
2791
auto *MDecl = IGM.getSwiftModule ();
2793
2792
llvm::sys::path::remove_filename (SourcePath);
2794
- MainModule = getOrCreateModule (MDecl, TheCU, Opts.ModuleName , SourcePath);
2793
+ MainModule = getOrCreateModule (MDecl, TheCU, Opts.ModuleName , SourcePath,
2794
+ Opts.DebugCompilationDir );
2795
2795
DBuilder.createImportedModule (MainFile, MainModule, MainFile, 0 );
2796
2796
2797
2797
// Macro definitions that were defined by the user with "-Xcc -D" on the
0 commit comments