diff options
author | xtex <xtex@envs.net> | 2025-01-13 10:12:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-13 11:12:23 +0100 |
commit | 16923da241377b05cf485dcca07f2b00df6bf500 (patch) | |
tree | 09bb3f340cf368cecb0ef3b328319f25e81c9934 /clang/lib/Frontend/DependencyFile.cpp | |
parent | e2a071ece58790f8dd4886e998033cab82e906fb (diff) | |
download | llvm-16923da241377b05cf485dcca07f2b00df6bf500.zip llvm-16923da241377b05cf485dcca07f2b00df6bf500.tar.gz llvm-16923da241377b05cf485dcca07f2b00df6bf500.tar.bz2 |
Revert "[clang] Canonicalize absolute paths in dependency file" (#121638)
Reverts llvm/llvm-project#117458
https://github.com/llvm/llvm-project/pull/117458#issuecomment-2568804774
https://github.com/ninja-build/ninja/issues/2528
Diffstat (limited to 'clang/lib/Frontend/DependencyFile.cpp')
-rw-r--r-- | clang/lib/Frontend/DependencyFile.cpp | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp index 8a36d83..15fa7de 100644 --- a/clang/lib/Frontend/DependencyFile.cpp +++ b/clang/lib/Frontend/DependencyFile.cpp @@ -23,10 +23,8 @@ #include "llvm/ADT/StringSet.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" #include <optional> -#include <system_error> using namespace clang; @@ -238,7 +236,6 @@ void DependencyFileGenerator::attachToPreprocessor(Preprocessor &PP) { PP.SetSuppressIncludeNotFoundError(true); DependencyCollector::attachToPreprocessor(PP); - FS = PP.getFileManager().getVirtualFileSystemPtr(); } bool DependencyFileGenerator::sawDependency(StringRef Filename, bool FromModule, @@ -315,22 +312,11 @@ void DependencyFileGenerator::finishedMainFile(DiagnosticsEngine &Diags) { /// https://msdn.microsoft.com/en-us/library/dd9y37ha.aspx for NMake info, /// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx /// for Windows file-naming info. -static void printFilename(raw_ostream &OS, llvm::vfs::FileSystem *FS, - StringRef Filename, +static void PrintFilename(raw_ostream &OS, StringRef Filename, DependencyOutputFormat OutputFormat) { // Convert filename to platform native path llvm::SmallString<256> NativePath; llvm::sys::path::native(Filename.str(), NativePath); - // Resolve absolute path. Make and Ninja canonicalize paths - // without checking for symbolic links in the path, for performance concerns. - // If there is something like `/bin/../lib64` -> `/usr/lib64` - // (where `/bin` links to `/usr/bin`), Make will see them as `/lib64`. - if (FS != nullptr && llvm::sys::path::is_absolute(NativePath)) { - llvm::SmallString<256> NativePathTmp = NativePath; - std::error_code EC = FS->getRealPath(NativePathTmp, NativePath); - if (EC) - NativePath = NativePathTmp; - } if (OutputFormat == DependencyOutputFormat::NMake) { // Add quotes if needed. These are the characters listed as "special" to @@ -414,7 +400,7 @@ void DependencyFileGenerator::outputDependencyFile(llvm::raw_ostream &OS) { Columns = 2; } OS << ' '; - printFilename(OS, FS.get(), File, OutputFormat); + PrintFilename(OS, File, OutputFormat); Columns += N + 1; } OS << '\n'; @@ -425,7 +411,7 @@ void DependencyFileGenerator::outputDependencyFile(llvm::raw_ostream &OS) { for (auto I = Files.begin(), E = Files.end(); I != E; ++I) { if (Index++ == InputFileIndex) continue; - printFilename(OS, FS.get(), *I, OutputFormat); + PrintFilename(OS, *I, OutputFormat); OS << ":\n"; } } |