Skip to content

llvm-ar fails to handle long paths on Windows #54559

Closed
@bgamari

Description

@bgamari

It appears that llvm-ar.exe (version 13.0.1) fails to accept long paths on Windows. For instance, clang can output to a long path without any trouble:

#!/usr/bin/env python
from pathlib import Path
tmp = Path('/'.join('a'*32 for j in range(16)))
tmp.mkdir(True, True)
Path('hi.c').write_text('int main() { return 0; }')

import subprocess
subprocess.run(['clang', '-o', tmp / 'out.o', 'hi.c'])

whereas asking ar to write an archive to a long path fails:

#!/usr/bin/env python
from pathlib import Path
tmp = Path('/'.join('a'*32 for j in range(16)))
tmp.mkdir(True, True)
Path('hi.c').write_text('int main() { return 0; }')

import subprocess
subprocess.run(['llvm-ar', 'rc', tmp / 'out.a', 'hi.c'])
$ python test.py
Traceback (most recent call last):
  File "C:\msys64\home\ben\ghc-2\test2.py", line 4, in <module>
    tmp.mkdir(True, True)
  File "C:/msys64/mingw64/lib/python3.9/pathlib.py", line 1325, in mkdir
    self._accessor.mkdir(self, mode)
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions