diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2898,6 +2898,7 @@ case ORIGINAL_PCH_DIR: F.OriginalDir = std::string(Blob); + ResolveImportedPath(F, F.OriginalDir); break; case MODULE_NAME: diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1470,8 +1470,7 @@ unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev)); SmallString<128> OutputPath(OutputFile); - - SM.getFileManager().makeAbsolutePath(OutputPath); + PreparePathForOutput(OutputPath); StringRef origDir = llvm::sys::path::parent_path(OutputPath); RecordData::value_type Record[] = {ORIGINAL_PCH_DIR}; diff --git a/clang/test/Modules/relative-original-dir.m b/clang/test/Modules/relative-original-dir.m new file mode 100644 --- /dev/null +++ b/clang/test/Modules/relative-original-dir.m @@ -0,0 +1,7 @@ +// RUN: rm -rf %t/normal-module-map +// RUN: mkdir -p %t +// RUN: cp -r %S/Inputs/normal-module-map %t +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-name=libA -emit-module %t/normal-module-map/module.map -o %t/normal-module-map/outdir/mod.pcm +// RUN: llvm-bcanalyzer --dump --disable-histogram %t/normal-module-map/outdir/mod.pcm | FileCheck %s + +// CHECK: blob data = 'outdir'