🌲[lit][clang] Avoid realpath on Windows due to MAX_PATH limitations #7298
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Running lit tests on Windows can fail because its use of
os.path.realpath
expands substitute drives, which are used to keep paths short and avoid hitting MAX_PATH limitations.Changes lit logic to:
Use
os.path.abspath
on Windows, whereMAX_PATH
is a concern that we can work around using substitute drives, whichos.path.realpath
would resolve.Use
os.path.realpath
on Unix, where the current directory always has symlinks resolved, so it is impossible to preserve symlinks in the presence of relative paths, and so we must make sure that all code paths use real paths.Also updates clang's
FileManager::getCanonicalName
andExtractAPI
code to avoid resolving substitute drives (i.e. resolving to a path under a different root).How tested: built with
-DLLVM_ENABLE_PROJECTS=clang
and builtcheck-all
on both WindowsDifferential Revision: https://reviews.llvm.org/D154130
Reviewed By: @benlangmuir
Patch by Tristan Labelle [email protected]!
CC @tristanlabelle
Fixes
AttributeError: module 'lit.util' has no attribute 'abs_path_preserve_drive'
failure on Rebranch CI.