rmaz created this revision. Herald added a project: All. rmaz requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This diff changes the serialization of the `ORIGINAL_PCH_DIR` entry in module files to be serialized relative to the module's `BaseDirectory`. This will allow for the module to be relocatable across machines. The path is restored relative to the module's BaseDirectory on deserialization. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D124946 Files: clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/Modules/relative-original-dir.m Index: clang/test/Modules/relative-original-dir.m =================================================================== --- /dev/null +++ clang/test/Modules/relative-original-dir.m @@ -0,0 +1,6 @@ +// RUN: rm -rf %t/normal-module-map +// 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: <ORIGINAL_PCH_DIR abbrevid=7/> blob data = 'outdir' Index: clang/lib/Serialization/ASTWriter.cpp =================================================================== --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -1461,8 +1461,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}; Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ 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:
Index: clang/test/Modules/relative-original-dir.m =================================================================== --- /dev/null +++ clang/test/Modules/relative-original-dir.m @@ -0,0 +1,6 @@ +// RUN: rm -rf %t/normal-module-map +// 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: <ORIGINAL_PCH_DIR abbrevid=7/> blob data = 'outdir' Index: clang/lib/Serialization/ASTWriter.cpp =================================================================== --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -1461,8 +1461,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}; Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ 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:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits