-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang++ failed create output file on windows if path more 247 chars #478
Comments
I assume you rebooted after changing that registry key? (It should only require a new run of clang, but ¯\_(ツ)_/¯) Assuming that is the case: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath Only a small family of functions is affected by that registry key. @stephenhines @pirama-arumuga-nainar: I assume that mingw is using multibyte strings. Any idea if there's a way to get it moved over to wide strings? (Or can we build Clang with msvc in the new system?) |
Yes, I rebooted after change registry value, nothing happened, and after that start counting how many characters in path and it was not MAX_PATH limit of 260 only 248. Also this bug present in last windows build of clang++-4.0.1 too(just checked), maybe report there. |
Found problem in clang in path convertion. If input file path not fit into MAX_PATH then clang use on windows long path names started from
look at first after D: should be:
incoming parameter in command line was:
All directory separators in unix style. And after internal clang conversion only first not changed. |
look at the: llvm/lib/Support/Path.cpp:427 (current trunk version) void append(SmallVectorImpl<char> &path, Style style, const Twine &a,
const Twine &b, const Twine &c, const Twine &d) {
SmallString<32> a_storage;
SmallString<32> b_storage;
SmallString<32> c_storage;
SmallString<32> d_storage;
SmallVector<StringRef, 4> components;
if (!a.isTriviallyEmpty()) components.push_back(a.toStringRef(a_storage));
if (!b.isTriviallyEmpty()) components.push_back(b.toStringRef(b_storage));
if (!c.isTriviallyEmpty()) components.push_back(c.toStringRef(c_storage));
if (!d.isTriviallyEmpty()) components.push_back(d.toStringRef(d_storage));
for (auto &component : components) {
bool path_has_sep =
!path.empty() && is_separator(path[path.size() - 1], style);
bool component_has_sep =
!component.empty() && is_separator(component[0], style);
bool is_root_name = has_root_name(component, style);
if (path_has_sep) {
// Strip separators from beginning of component.
size_t loc = component.find_first_not_of(separators(style));
StringRef c = component.substr(loc);
// Append it.
path.append(c.begin(), c.end());
continue;
}
if (!component_has_sep && !(path.empty() || is_root_name)) {
// Add a separator.
path.push_back(preferred_separator(style));
}
// START FIX
else if (component_has_sep && component.size() == 1)
{
// component itself is a separator '/' on windows after split: [c:/j/file] ->[{c:}, {/}, {j}, {/file}]
// we have to change '/' into '\\' on windows on path start with "\\\\?\\"
path.push_back(preferred_separator(style));
continue;
}
// END FIX
path.append(component.begin(), component.end());
}
} |
@leanid: Thanks for the diagnosis. It is indeed correct. Only suggestion would be to defensively invoke the fix only on Windows and only when |
Nice, please do the patch to upstream yourself. |
https://reviews.llvm.org/rL311382 is the commit from upstream. We'll cherry-pick it to r16 (hopefully in one of the betas). |
If this didn't make r16 then it's in r17 since that has another update. |
Problem seems not solved totally in r17.
The fd_recv.o is built successfully (I've checked the file, it exist in correct place) but can't be found in linking. |
The path is longer than 260 characters, but the failure is from arm-linux-androideabi-ar. @DanAlbert should the build system be prepending long paths with '\?' when invoking tools? |
@pirama-arumuga-nainar Any update? Should I open a new issue on this problem? |
IIUC, the failure is when invoking arm-linux-androideabi-ar and not clang itself. If that's the case, then open a new issue. |
Description
clang++.exe failed to compile file on windows 10 if output object file path length more then 247 chars on my machine. I prepare minimal test case. Also I try to enable LongPathSupport but it not influence on clang++.exe.
Minimal test case:
Environment Details
command line:
The text was updated successfully, but these errors were encountered: