Skip to content

Commit f11b056

Browse files
authored
[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.
1 parent aca3727 commit f11b056

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/Support/Windows/Path.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ std::string getMainExecutable(const char *argv0, void *MainExecAddr) {
154154
return "";
155155

156156
llvm::sys::path::make_preferred(PathNameUTF8);
157-
return std::string(PathNameUTF8.data());
157+
158+
SmallString<256> RealPath;
159+
sys::fs::real_path(PathNameUTF8, RealPath);
160+
return std::string(RealPath);
158161
}
159162

160163
UniqueID file_status::getUniqueID() const {

0 commit comments

Comments
 (0)