[Issue 17888] New: dmd fails on Windows if path is too long
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 9 16:02:22 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=17888
Issue ID: 17888
Summary: dmd fails on Windows if path is too long
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: laeeth at laeeth.com
DMD fails on Windows if the path is too long. (Sorry for not giving specific
test case yet - I'm on Linux right now, but Atila Neves will elaborate
shortly).
This is particularly a problem when using dub, which likes to turn all paths
into relative ones and this has the consequence of making even a shortish path
long.
There are two reasons for this. One is that the static array in tk/filespec.c
in the function that builds a path is only 131 chars + null. Another is that
for the getcwd Windows API function we call, the MAXPATH limit of 260
characters applies. The way to avoid this is to use the unicode function and
Win32 File namespaces instead of a regular path. So if the path does not begin
\\ then we should make it look something like: \?\C\D\foo (note, not \?C\D\foo
- which does something entirely different). I believe that should:
1. be one step towards permitting unicode characters in the path. (probably
there are other functions that would need to be changed - I haven't had time
to look). See https://issues.dlang.org/show_bug.cgi?id=13493
2. be one step towards removing the path length limit on Windows which
interacts badly with dub's style in relativisation of paths. there might be
other functions that need to be changed - in a hurry.
https://github.com/dlang/dmd/blob/2bf9a9d731e88ebd8a175bd0a990a3b651e8df82/src/ddmd/tk/filespec.c
line 119 - cwd is 131 chars + null
prototype:
extern (C) char* getcwd(char* buffer, size_t maxlen);
it's deprecated and replaced by the ISO function:
https://docs.microsoft.com/en-gb/cpp/c-runtime-library/reference/getcwd-wgetcwd
on Windows and indeed other operating systems we already have the correct code
to get current working directory. so we just need to update dmd to use this.
https://github.com/dlang/phobos/blob/v2.076.0/std/file.d#L2681
even if we can't use Phobos I guess we could copy /paste that code.
--
More information about the Digitalmars-d-bugs
mailing list