aaron.ballman created this revision. on POSIX systems, CIndexer::getClangResourcesPath() uses dladdr() to get the path of the shared object. It seems that on some systems (in our case, OS X 10.6.8), dladdr() does not return a canonicalized path. We're getting a path like PATH/TO/CLANG/build/bin/../lib/clang/4.0.0. This resource directory path is then used to calculate a hash used by CompilerInvocation::getModuleHash(). This, in turn, is causing Index/pch-from-libclang.c to fail for us because the module cache paths have different names -- the first path is calculated with PATH/TO/CLANG/build/lib/clang/4.0.0 and the second path uses PATH/TO/CLANG/build/bin/../lib/clang/4.0.0.
Fix this bug by returning a canonicalized path. https://reviews.llvm.org/D33788 Files: tools/libclang/CIndexer.cpp Index: tools/libclang/CIndexer.cpp =================================================================== --- tools/libclang/CIndexer.cpp +++ tools/libclang/CIndexer.cpp @@ -73,6 +73,11 @@ llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING); // Cache our result. - ResourcesPath = LibClangPath.str(); + SmallString<260> RealPath; + if (!llvm::sys::fs::real_path(LibClangPath, RealPath, /*expand_tilde=*/false)) + ResourcesPath = RealPath.str(); + else + ResourcesPath = LibClangPath.str(); + return ResourcesPath; }
Index: tools/libclang/CIndexer.cpp =================================================================== --- tools/libclang/CIndexer.cpp +++ tools/libclang/CIndexer.cpp @@ -73,6 +73,11 @@ llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING); // Cache our result. - ResourcesPath = LibClangPath.str(); + SmallString<260> RealPath; + if (!llvm::sys::fs::real_path(LibClangPath, RealPath, /*expand_tilde=*/false)) + ResourcesPath = RealPath.str(); + else + ResourcesPath = LibClangPath.str(); + return ResourcesPath; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits