[llvm] [Support] Resolve symlinks in `getMainExecutable()` on Windows (PR #76304)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 23 16:22:23 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-platform-windows
Author: Alexandre Ganea (aganea)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/76304.diff
1 Files Affected:
- (modified) llvm/lib/Support/Windows/Path.inc (+4-1)
``````````diff
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 168a63bb2d969d..6b50309be94d77 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 {
``````````
</details>
https://github.com/llvm/llvm-project/pull/76304
More information about the llvm-commits
mailing list