diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2014-02-12 10:33:14 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2014-02-12 10:33:14 +0000 |
commit | f430da4de68b5569634b03df30b38d1133dc169b (patch) | |
tree | 3cbc33ed201f16def4c5052e05004820a6800b0e /clang/tools | |
parent | ecbe18e01dc42fb5e60fdac361ce74f9ab8c5307 (diff) | |
download | bcm5719-llvm-f430da4de68b5569634b03df30b38d1133dc169b.tar.gz bcm5719-llvm-f430da4de68b5569634b03df30b38d1133dc169b.zip |
Add an option to allow Clang verify source files for a module only once during
the build
When Clang loads the module, it verifies the user source files that the module
was built from. If any file was changed, the module is rebuilt. There are two
problems with this:
1. correctness: we don't verify system files (there are too many of them, and
stat'ing all of them would take a lot of time);
2. performance: the same module file is verified again and again during a
single build.
This change allows the build system to optimize source file verification. The
idea is based on the fact that while the project is being built, the source
files don't change. This allows us to verify the module only once during a
single build session. The build system passes a flag,
-fbuild-session-timestamp=, to inform Clang of the time when the build started.
The build system also requests to enable this feature by passing
-fmodules-validate-once-per-build-session. If these flags are not passed, the
behavior is not changed. When Clang verifies the module the first time, it
writes out a timestamp file. Then, when Clang loads the module the second
time, it finds a timestamp file, so it can compare the verification timestamp
of the module with the time when the build started. If the verification
timestamp is too old, the module is verified again, and the timestamp file is
updated.
llvm-svn: 201224
Diffstat (limited to 'clang/tools')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 10 | ||||
-rw-r--r-- | clang/tools/libclang/CMakeLists.txt | 1 | ||||
-rw-r--r-- | clang/tools/libclang/libclang.exports | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 9288f92d17d..7f5bf4c2edf 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -2,6 +2,7 @@ #include "clang-c/Index.h" #include "clang-c/CXCompilationDatabase.h" +#include "clang-c/BuildSystem.h" #include "llvm/Config/config.h" #include <ctype.h> #include <stdlib.h> @@ -3800,6 +3801,11 @@ static int read_diagnostics(const char *filename) { return 0; } +static int perform_print_build_session_timestamp(void) { + printf("%lld\n", clang_getBuildSessionTimestamp()); + return 0; +} + /******************************************************************************/ /* Command line processing. */ /******************************************************************************/ @@ -3856,6 +3862,8 @@ static void print_usage(void) { fprintf(stderr, " c-index-test -compilation-db [lookup <filename>] database\n"); fprintf(stderr, + " c-index-test -print-build-session-timestamp\n"); + fprintf(stderr, " c-index-test -read-diagnostics <file>\n\n"); fprintf(stderr, " <symbol filter> values:\n%s", @@ -3955,6 +3963,8 @@ int cindextest_main(int argc, const char **argv) { return write_pch_file(argv[2], argc - 3, argv + 3); else if (argc > 2 && strcmp(argv[1], "-compilation-db") == 0) return perform_test_compilation_db(argv[argc-1], argc - 3, argv + 2); + else if (argc == 2 && strcmp(argv[1], "-print-build-session-timestamp") == 0) + return perform_print_build_session_timestamp(); print_usage(); return 1; diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index 97203b0df4d..95a8a6ccbaf 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS set(SOURCES ARCMigrate.cpp + BuildSystem.cpp CIndex.cpp CIndexCXX.cpp CIndexCodeCompletion.cpp diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports index 809cf03a10b..975993adb35 100644 --- a/clang/tools/libclang/libclang.exports +++ b/clang/tools/libclang/libclang.exports @@ -119,6 +119,7 @@ clang_formatDiagnostic clang_getArgType clang_getArrayElementType clang_getArraySize +clang_getBuildSessionTimestamp clang_getCString clang_getCXTUResourceUsage clang_getCXXAccessSpecifier |