This is an archive of the discontinued LLVM Phabricator instance.

lit: Let lit.util.which() return a normcase()ed path
ClosedPublic

Authored by thakis on Jan 28 2019, 11:07 AM.

Details

Summary

LLVMConfig.with_environment() uses os.path.normcase(os.path.normpath(x)) to normalize temporary env vars. LLVMConfig.use_clang() uses with_environment() to temporarily set PATH and then look for clang there. This means that on Windows, clang will be run with a path like c:\foo\bin\clang.EXE (with a lower-case "C:").

lit.util.which() used to not do this, which means the executables added in clang/test/lit.cfg.py (e.g. c-index-test) were run with a path like C:\foo\bin\c-index-test.EXE (because both CMake and GN happen to write clang_tools_dir with an upper-case C to lit.site.cfg.py).

clang/test/Index/pch-from-libclang.c requires that both c-index-test and clang use _exactly_ the same resource dir path (same case and everything), because a hash of the resource directory is used as module cache path.

This patch is necessary but not sufficient to make pch-from-libclang.c pass on Windows.

Diff Detail

Repository
rL LLVM

Event Timeline

thakis created this revision.Jan 28 2019, 11:07 AM

Shouldn't the hash be case-insensitive on windows?

Shouldn't the hash be case-insensitive on windows?

I'm not sure: I think case-sensitive file systems on Windows are becoming more common with WSL. This seemed like the less intrusive change to me at least. If we make it case-insensitive on Win, we probably also want that on macOS, but there case-sensitive file systems also exist and are maybe more common, and it feels like a can of worms that I'd rather leave closed.

zturner: ping

zturner accepted this revision.Jan 30 2019, 9:10 AM

I think it's possible to detect the case insensitivity of the file system itself, rather than relying on the operating system which as you point out is neither necessary nor sufficient to identify case insensitivity. But, also like you pointed out, that's another can of worms entirely, so I agree this is the simplest thing to make things better than before.

This revision is now accepted and ready to land.Jan 30 2019, 9:10 AM
This revision was automatically updated to reflect the committed changes.