-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
raw_headers_as_headers_mode
Summary: There has been a tension, a disconnect, between `raw_headers` and `headers` for years. `raw_headers` + `include_directories` were a necessity to support msvc and third-party code which does 'bad things' with includes, like, `#include "../some_header.h"`, or which would have problems with buck generated symlink trees and include the same header via different paths. This results in buck targets either using `headers` (and fixing or working around the above issues) or code using `raw_headers` (and not having to worry about it). Reconciling this tension was never a priority because it felt like a simple harmless convention. There is a harm, though. The Windows filesystem is slow. Clang on Windows, when searching for headers, has to wade through potentially hundreds or thousands of directories for each one. In the process clang also performs a filename canonicalization operation that can contend on a lock deep in the filesystem, when run with large local concurrency. This was profiled as taking up to 7 seconds to resolve `<string>` in a .cpp file in a certain build, compared to potentially just 100ms without having all of the extraneous user deps. This is because clang always searches system header paths last, after searching user include paths, because that is how the standard library header paths are specified. There is a mitigation, however. Clang supports header maps, which are essentially 'pre-indexed' header lookup tables. Instead of searching the filesystem, clang just does an in memory map lookup to resolve an include. No lock contention, no slowdowns in the filesystem layers. While we can operate buck in a 'mixed' mode where code using `headers` can take advantage of header maps, targets using `raw_headers` were out of luck. Until now. Paralleling the similarly named (but presently unused) `headers_as_raw_headers_mode`, this introduces a conversion mechanism which can convert `raw_headers` and `include_directories` into an internal representation that can treat them as `headers`. Thus we can emit header maps for all targets, and then reap the performance benefits for clang users on Windows. A per target setting is also supported for targets we can't or don't want to fix. Or, for incremental adoptions by using a default disabled mode but enabling it on specific targets. The behavior is disabled entirely unless the toolchain explicitly opts into the feature through a non-default value on `raw_headers_as_headers_mode` on the `cxx_toolchain`. Reviewed By: jtbraun Differential Revision: D65517235 fbshipit-source-id: 778d79cfc5ede5c114b342c67b4f90cd6a7b9742
- Loading branch information
1 parent
a66b931
commit 9f90f62
Showing
8 changed files
with
119 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters