[llvm] 14a19ce - Fix Windows Path Separator issues in create_symlink and readlink (#206665)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 30 19:15:23 PDT 2026
Author: Junji Watanabe
Date: 2026-07-01T12:15:18+10:00
New Revision: 14a19ce1580733ec75dd4cbc5214e7d40d90cbba
URL: https://github.com/llvm/llvm-project/commit/14a19ce1580733ec75dd4cbc5214e7d40d90cbba
DIFF: https://github.com/llvm/llvm-project/commit/14a19ce1580733ec75dd4cbc5214e7d40d90cbba.diff
LOG: Fix Windows Path Separator issues in create_symlink and readlink (#206665)
- Force create_symlink target path to use backslashes on Windows, as
NTFS reparse points require backslashes.
- Normalize readlink output to native path separators to match preferred
style.
This fixes the following test failure:
```
PS C:\src\chromium\src\third_party\llvm> .\build_repro\unittests\Support\SupportTests.exe --gtest_filter=FileSystemTest.CreateRelativeDirectorySymlink
[ RUN ] FileSystemTest.CreateRelativeDirectorySymlink
Test Directory: C:/src/temp/file-system-test-a3fd42
C:\src\chromium\src\third_party\llvm\llvm\unittests\Support\Path.cpp(896): error: Value of: fs::is_directory(Link) Actual: false
Expected: true
```
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 b4be1c2d6f5c2..d149cd4476b11 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -342,7 +342,7 @@ std::error_code create_symlink(const Twine &to, const Twine &from) {
// The Win32 API normally allows forward slashes, but under some cases it does
// not correctly handle them in the target of a symlink.
SmallString<128> ToStr;
- llvm::sys::path::native(to, ToStr);
+ llvm::sys::path::native(to, ToStr, llvm::sys::path::Style::windows_backslash);
SmallVector<wchar_t, 128> WideFrom;
SmallVector<wchar_t, 128> WideTo;
@@ -1819,6 +1819,7 @@ std::error_code readlink(const Twine &path, SmallVectorImpl<char> &dest) {
if (std::error_code EC = UTF16ToUTF8(Target, TargetLen, dest))
return EC;
+ llvm::sys::path::native(dest);
return std::error_code();
}
More information about the llvm-commits
mailing list