[PATCH] D152709: [lit] Avoid os.path.realpath in lit.py due to MAX_PATH limitations on Windows

Tristan Labelle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 07:35:25 PDT 2023


MrTrillian created this revision.
MrTrillian added reviewers: mstorsjo, ldionne.
Herald added a subscriber: delcypher.
Herald added a project: All.
MrTrillian requested review of this revision.
Herald added a project: LLVM.

`lit.py` uses `os.path.realpath` on file paths. Somewhere between Python 3.7 and 3.9, `os.path.realpath` was updated to resolve substitute drives on Windows (`subst S: C:\Long\Path\To\My\Code`). This is a problem because it prevents using substitute drives to work around `MAX_PATH` path length limitations on Windows.

We run into this while building & testing, the Swift compiler on Windows, which uses a substitute drive in CI to shorten the workspace directory. `cmake` builds without resolving the substitute drive and can apply its logic to avoid output files exceeding `MAX_PATH`. However, when running tests, `lit.py`'s use of `os.path.realpath` will resolve the substitute drive (with newer Python versions), resulting in some paths being longer than MAX_PATH, which cause all kinds of failures (for example `rd` in tests fails, or `link.exe` fails, etc).

How tested: Ran `check-all`, and lit tests, saw no failures

  > ninja -C build check-all
  Testing Time: 262.63s
    Skipped          :    24
    Unsupported      :  2074
    Passed           : 51812
    Expectedly Failed:   167
  
  > python utils\lit\lit.py --path ..\build\bin utils\lit\tests
  Testing Time: 12.17s
    Unsupported:  6
    Passed     : 47


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152709

Files:
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/lit/builtin_commands/diff.py
  llvm/utils/lit/lit/discovery.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152709.530497.patch
Type: text/x-patch
Size: 4888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230612/edaa11ca/attachment.bin>


More information about the llvm-commits mailing list