Libstdc++ questions regarding Windows symlink patch
Adam Wood
adam.wood@mines.sdsmt.edu
Sun Jan 25 16:32:27 GMT 2026
On Sun, Jan 25, 2026 at 5:22 AM Jonathan Wakely <jwakely.gcc@gmail.com>
wrote:
>
>
> On Sun, 25 Jan 2026, 04:25 Adam Wood wrote:
>
>> Hello,
>>
>> I have a couple questions regarding my patch titled "Add symlink support
>> on Windows".
>>
>> First, who should I ask to review the Windows API parts of the patch?
>>
>
> I reviewed the v3 patch in October and had some questions. If I need more
> help with the Windows parts I'll ask the mingw-w64 target maintainers to
> look.
>
>
Oops. I missed those questions in October, but I'll take a look them now.
Thanks.
>
>> Second, I am not sure that the approach I took regarding path
>> normalization was correct. Windows will normalize paths with dot-dots
>> before checking if the parent directory existed or was a symlink. For
>> example, if you had the path "folder/doesntexist/.." on Linux, this is an
>> error. Windows doesn't care about the non-existent folder, and the path is
>> resolved to just "folder".
>>
>> I tried to circumvent this behavior in my patch so that functions like
>> std::filesystem::canonical acted more like Linux so "folder/doesntexist/.."
>> would throw an error on Windows as well. I now think I was wrong to do
>> this. What are your thoughts?
>>
>
> How does the Microsoft implementation behave for that case? I think we
> should follow that, because whatever behaviour they implemented is probably
> what windows users expect.
>
>
>
I wrote a simple cpp file to quickly test this:
#include <filesystem>
#include <iostream>
int main() {
namespace fs = std::filesystem;
try {
fs::create_directories("test_cpp_dir/A/B/");
fs::create_directories("test_cpp_dir/A/B/D/E");
fs::create_directory_symlink("D/E", "test_cpp_dir/A/B/C");
// test if the path resolution resolves symlinks or dot-dots first
fs::path p { fs::canonical("test_cpp_dir/A/B/C/..") };
std::cout << p.string() << '\n';
} catch ( const std::exception & err ) {
std::cout << err.what() << '\n';
}
return 0;
}
On Linux with GCC, this prints "<some absolute
path>/test_cpp_dir/A/B/D". On Windows with MSVC, this prints "<some
absolute path>/test_cpp_dir/A/B". In other words, MSVC's implementation
resolves the dot-dot before it resolves the symlink. I haven't as of right
now looked into the MSVC STL source code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20260125/21bc2f5f/attachment.htm>
More information about the Libstdc++
mailing list