Skip to content

clang does not support long paths #46966

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

Closed
fekir opened this issue Sep 23, 2020 · 4 comments
Closed

clang does not support long paths #46966

fekir opened this issue Sep 23, 2020 · 4 comments
Labels
bugzilla Issues migrated from bugzilla llvm:support

Comments

@fekir
Copy link

fekir commented Sep 23, 2020

Bugzilla Link 47622
Version trunk
OS Windows NT
CC @zygoloid

Extended Description

Hello, clang is inconsistent on how ti handles long paths.

I'm using the cygwin environment for simplicity, but it has nothing to do with cygwin, as it is only used for calling clang and creating feils/directories.


LONG_DIR="D:/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
mkdir -p "$LONG_DIR"
echo "int main(){}" > "$LONG_DIR/main.cpp"
'/cygdrive/c/Program Files/LLVM/bin/clang++.exe' "$LONG_DIR/main.cpp" -o "$LONG_DIR/main.exe"

LINK : fatal error LNK1104: cannot open file 'D:\1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234\12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\123456789012345678901234567890123456789012345
67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\main.exe'

While following works without issues


LONG_DIR="D:/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
mkdir -p "$LONG_DIR"
echo "int main(){}" > "$LONG_DIR/main.cpp"
'/cygdrive/c/Program Files/LLVM/bin/clang++.exe' "$LONG_DIR/main.cpp"

Thus it seems that clang has issues writing, not reading, files in long paths.

If case it is relevant, I've enabled "LongPathsEnabled" on my machine (Windows 10 Version 1909).

@fekir
Copy link
Author

fekir commented Sep 23, 2020

Also note that using

LONG_DIR='\?\D:\1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234\12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'

as path did not change anything, the inconsistency is still there.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@bgamari
Copy link

bgamari commented Mar 25, 2022

#54559 notes a similar issue in llvm-ar.

@RyanGlScott
Copy link

I think this issue may be fixed as of Clang 14.0.6. Here is a standalone script:

#!/usr/bin/env bash

DIR="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
LONG_DIR="$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR/$DIR"
mkdir -p "$LONG_DIR"
echo "int main(){}" > "$LONG_DIR/main.cpp"
clang++.exe --version
clang++.exe "$LONG_DIR/main.cpp" -o "$LONG_DIR/main.exe" && echo "Long path used successfully"

If I use Clang 13.0.0, then this fails:

$ PATH=/c/ghcup/ghc/9.4.1/mingw/bin:$PATH ./test.sh
clang version 13.0.0
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/ghcup/ghc/9.4.1/mingw/bin
clang++: error: no such file or directory: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/main.cpp'
clang++: error: no input files

If I use Clang 14.0.6, however, then this succeeds:

$ ./test.sh
clang version 14.0.6
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/clang64/bin
Long path used successfully

@mplatings
Copy link
Collaborator

Yes, this works for me also. https://reviews.llvm.org/D75372 looks like the fix, but that predates this issue so maybe it was https://reviews.llvm.org/D111880. Closing.

@EugeneZelenko EugeneZelenko added llvm:support and removed clang Clang issues not falling into any other category labels Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:support
Projects
None yet
Development

No branches or pull requests

5 participants