[llvm] Fix Windows Path Separator issues in create_symlink and readlink (PR #206665)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 00:17:01 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-llvm-support

Author: Junji Watanabe (Jwata)

<details>
<summary>Changes</summary>

- 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
```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

---
Full diff: https://github.com/llvm/llvm-project/pull/206665.diff


1 Files Affected:

- (modified) llvm/lib/Support/Windows/Path.inc (+2-1) 


``````````diff
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();
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/206665


More information about the llvm-commits mailing list