@@ -855,6 +855,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
855
855
856
856
llvm::DIModule *getOrCreateModule (const void *Key, llvm::DIScope *Parent,
857
857
StringRef Name, StringRef IncludePath,
858
+ StringRef CompDir,
858
859
uint64_t Signature = ~1ULL ,
859
860
StringRef ASTFile = StringRef()) {
860
861
// Look in the cache first.
@@ -864,6 +865,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
864
865
865
866
std::string RemappedIncludePath = DebugPrefixMap.remapPath (IncludePath);
866
867
std::string RemappedASTFile = DebugPrefixMap.remapPath (ASTFile);
868
+ std::string RemappedCompDir = DebugPrefixMap.remapPath (CompDir);
867
869
868
870
// For Clang modules / PCH, create a Skeleton CU pointing to the PCM/PCH.
869
871
if (!Opts.DisableClangModuleSkeletonCUs ) {
@@ -873,7 +875,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
873
875
llvm::DIBuilder DIB (M);
874
876
DIB.createCompileUnit (IGM.ObjCInterop ? llvm::dwarf::DW_LANG_ObjC
875
877
: llvm::dwarf::DW_LANG_C99,
876
- DIB.createFile (Name, RemappedIncludePath ),
878
+ DIB.createFile (Name, RemappedCompDir ),
877
879
TheCU->getProducer (), true , StringRef (), 0 ,
878
880
RemappedASTFile, llvm::DICompileUnit::FullDebug,
879
881
Signature);
@@ -900,12 +902,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
900
902
uint64_t Signature =
901
903
Desc.getSignature () ? Desc.getSignature ().truncatedValue () : ~1ULL ;
902
904
903
- // Clang modules using fmodule-file-home-is-cwd should have their
904
- // include path set to the working directory.
905
- auto &HSI =
906
- CI.getClangPreprocessor ().getHeaderSearchInfo ().getHeaderSearchOpts ();
907
- StringRef IncludePath =
908
- HSI.ModuleFileHomeIsCwd ? Opts.DebugCompilationDir : Desc.getPath ();
905
+ StringRef CompDir = Opts.DebugCompilationDir ;
906
+ StringRef IncludePath = Desc.getPath ();
909
907
910
908
// Handle Clang modules.
911
909
if (ClangModule) {
@@ -927,12 +925,13 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
927
925
ClangModule->Parent );
928
926
}
929
927
return getOrCreateModule (ClangModule, Parent, Desc.getModuleName (),
930
- IncludePath, Signature, Desc.getASTFile ());
928
+ IncludePath, CompDir, Signature,
929
+ Desc.getASTFile ());
931
930
}
932
931
// Handle PCH.
933
932
return getOrCreateModule (Desc.getASTFile ().bytes_begin (), nullptr ,
934
- Desc.getModuleName (), IncludePath, Signature ,
935
- Desc.getASTFile ());
933
+ Desc.getModuleName (), IncludePath, CompDir ,
934
+ Signature, Desc.getASTFile ());
936
935
};
937
936
938
937
static std::optional<ASTSourceDescriptor>
@@ -955,7 +954,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
955
954
// the module on disk is Bar (.swiftmodule or .swiftinterface), and is used
956
955
// for loading and mangling.
957
956
StringRef Name = M->getRealName ().str ();
958
- return getOrCreateModule (M, TheCU, Name, Path);
957
+ return getOrCreateModule (M, TheCU, Name, Path, Opts. DebugCompilationDir );
959
958
}
960
959
961
960
TypeAliasDecl *getMetadataType (StringRef ArchetypeName) {
@@ -2551,8 +2550,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2551
2550
auto Identifier = IGM.getSILModule ().getASTContext ().getIdentifier (
2552
2551
Attribute->ManglingModuleName );
2553
2552
void *Key = (void *)Identifier.get ();
2554
- Scope =
2555
- getOrCreateModule (Key, TheCU, Attribute-> ManglingModuleName , {});
2553
+ Scope = getOrCreateModule (Key, TheCU, Attribute-> ManglingModuleName , {},
2554
+ {});
2556
2555
} else {
2557
2556
Context = ND->getParent ();
2558
2557
}
@@ -2799,7 +2798,8 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
2799
2798
// Create a module for the current compile unit.
2800
2799
auto *MDecl = IGM.getSwiftModule ();
2801
2800
llvm::sys::path::remove_filename (SourcePath);
2802
- MainModule = getOrCreateModule (MDecl, TheCU, Opts.ModuleName , SourcePath);
2801
+ MainModule = getOrCreateModule (MDecl, TheCU, Opts.ModuleName , SourcePath,
2802
+ Opts.DebugCompilationDir );
2803
2803
DBuilder.createImportedModule (MainFile, MainModule, MainFile, 0 );
2804
2804
2805
2805
// Macro definitions that were defined by the user with "-Xcc -D" on the
0 commit comments