[clang] [clang] Absoultify paths in dependency file output (PR #117458)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 30 13:50:49 PST 2024
================
@@ -312,11 +314,18 @@ 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, StringRef Filename,
+static void PrintFilename(raw_ostream &OS, llvm::vfs::FileSystem *FS,
+ StringRef Filename,
DependencyOutputFormat OutputFormat) {
// Convert filename to platform native path
llvm::SmallString<256> NativePath;
llvm::sys::path::native(Filename.str(), NativePath);
+ // Make path absolute. 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))
+ FS->makeAbsolute(NativePath);
----------------
MaskRay wrote:
`makeAbsolute` does not resolve an absolute path, so this does not work as intended.
`Make path absolute` => `Resolve an absolute path`?
https://github.com/llvm/llvm-project/pull/117458
More information about the cfe-commits
mailing list