[llvm] f11b056 - [Support] Resolve symlinks in `getMainExecutable()` on Windows (#76304)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 26 07:33:46 PST 2023


Author: Alexandre Ganea
Date: 2023-12-26T10:33:42-05:00
New Revision: f11b056c02cca28fe0b82ec44c59537035100e67

URL: https://github.com/llvm/llvm-project/commit/f11b056c02cca28fe0b82ec44c59537035100e67
DIFF: https://github.com/llvm/llvm-project/commit/f11b056c02cca28fe0b82ec44c59537035100e67.diff

LOG: [Support] Resolve symlinks in `getMainExecutable()` on Windows (#76304)

This makes the Windows implementation for `getMainExecutable()` behave
the same as its Linux counterpart, in regards to symlinks. Previously,
when using `cmake ... -DLLVM_USE_SYMLINKS=ON`, calling this function
wouldn't resolve to the "real", non-symlinked path.

Added: 
    

Modified: 
    llvm/lib/Support/Windows/Path.inc

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 168a63bb2d969d..2bf68b7972e746 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -154,7 +154,10 @@ std::string getMainExecutable(const char *argv0, void *MainExecAddr) {
     return "";
 
   llvm::sys::path::make_preferred(PathNameUTF8);
-  return std::string(PathNameUTF8.data());
+
+  SmallString<256> RealPath;
+  sys::fs::real_path(PathNameUTF8, RealPath);
+  return std::string(RealPath);
 }
 
 UniqueID file_status::getUniqueID() const {


        


More information about the llvm-commits mailing list