[PATCH] D21113: Add support for case-insensitive header lookup

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 18:12:31 PDT 2016


hans created this revision.
hans added reviewers: rsmith, rnk, thakis.
hans added subscribers: compnerd, majnemer, benlangmuir, cfe-commits.

This is useful when dealing with headers that are normally used on case-insensitive filesystems, such as the Windows SDK, when cross-compiling from a file-system that is case-sensitive (such as Linux). A prime example would be compiling "#include <windows.h>" (the file is really called Windows.h).

There has been a patch for this before (http://reviews.llvm.org/D2972), but this one is more general, as it works on the virtual filesystem layer, and also supports case-insensitive lookups of parent directories not just the filename.

I was initially worried about performance here. The most common case is trying to lookup a header file in the wrong include path, and instead of a simple stat, this patch will cause a full directory listing for each such attempt.

I tried a version of this patch that used a small Bloom filter for each directory to avoid unnecessary searches for non-existing files, but that broke a lot of modules tests. It seems those tests would end up writing to a module cache directory, but the vfs wasn't aware of those writes so subsequent attempts to open files in that directory would fail because of the filter (yay, cache invalidation). Maybe that could be fixed, and maybe such filtering would be useful for broadly too, but perhaps we could look at that separately.

I measured compile-time of a file in V8 on Linux with and without case-sensitive includes, and also with the filter:

  Case sensitive: (default)   8.60s +- 2.90%
  Case insensitive:           8.74s +- 1.18%
  Case insensitive w/ filter: 8.46s +- 0.82%

Adding some folks who were on Saleem's patch.

http://reviews.llvm.org/D21113

Files:
  include/clang/Basic/VirtualFileSystem.h
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearchOptions.h
  lib/Basic/VirtualFileSystem.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/cl-options.c
  test/Frontend/Inputs/case-insensitive-includes.h
  test/Frontend/case-insensitive-includes.c
  unittests/Basic/VirtualFileSystemTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21113.59980.patch
Type: text/x-patch
Size: 11099 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160608/632dfc72/attachment-0001.bin>


More information about the cfe-commits mailing list