summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoshimasa Niwa <niw@niw.at>2021-04-28 11:20:35 -0700
committerGitHub <noreply@github.com>2021-04-28 20:20:35 +0200
commit97f42b963e1d82f038990e11cc81c21bd7743011 (patch)
tree71215833bcf11b72c7fd0cd39dc53576fe41d6da
parentaa7fd27609bea5ec78fd85afaec297d028119ee0 (diff)
downloadccache-97f42b963e1d82f038990e11cc81c21bd7743011.tar.gz
Ignore -ivfsoverlay parameter (#839)
Co-authored-by: Peter Steinberger <steipete@gmail.com>
-rw-r--r--doc/MANUAL.adoc4
-rw-r--r--src/Config.cpp5
-rw-r--r--src/Sloppiness.hpp2
-rw-r--r--src/argprocessing.cpp9
-rw-r--r--src/compopt.cpp1
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/suites/ivfsoverlay.bash44
-rw-r--r--unittest/test_Config.cpp9
8 files changed, 71 insertions, 4 deletions
diff --git a/doc/MANUAL.adoc b/doc/MANUAL.adoc
index 2b6f0012..b74277c5 100644
--- a/doc/MANUAL.adoc
+++ b/doc/MANUAL.adoc
@@ -824,6 +824,10 @@ still has to do _some_ preprocessing (like macros).
mtime is too new. This sloppiness disables that check. See also
_<<_handling_of_newly_created_header_files,Handling of newly created header
files>>_.
+*ivsfsoverlay*::
+ Ignore the Clang compiler option *-ivfsoverlay* and its argument. This is
+ useful if you use Xcode, which uses virtual file system (VFS) for
+ combining Objective-C and Swift code for example.
*locale*::
Ccache includes the environment variables *LANG*, *LC_ALL*, *LC_CTYPE* and
*LC_MESSAGES* in the hash by default since they may affect localization of
diff --git a/src/Config.cpp b/src/Config.cpp
index 68dc3f57..9e709236 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -275,6 +275,8 @@ parse_sloppiness(const std::string& value)
result |= SLOPPY_LOCALE;
} else if (token == "modules") {
result |= SLOPPY_MODULES;
+ } else if (token == "ivfsoverlay") {
+ result |= SLOPPY_IVFSOVERLAY;
} // else: ignore unknown value for forward compatibility
start = value.find_first_not_of(", ", end);
}
@@ -315,6 +317,9 @@ format_sloppiness(uint32_t sloppiness)
if (sloppiness & SLOPPY_MODULES) {
result += "modules, ";
}
+ if (sloppiness & SLOPPY_IVFSOVERLAY) {
+ result += "ivfsoverlay, ";
+ }
if (!result.empty()) {
// Strip last ", ".
result.resize(result.size() - 2);
diff --git a/src/Sloppiness.hpp b/src/Sloppiness.hpp
index bd2078e9..62c0508a 100644
--- a/src/Sloppiness.hpp
+++ b/src/Sloppiness.hpp
@@ -38,4 +38,6 @@ enum Sloppiness {
SLOPPY_LOCALE = 1 << 8,
// Allow caching even if -fmodules is used.
SLOPPY_MODULES = 1 << 9,
+ // Ignore virtual file system (VFS) overlay file.
+ SLOPPY_IVFSOVERLAY = 1 << 10,
};
diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp
index b2ba1e0c..92b929e0 100644
--- a/src/argprocessing.cpp
+++ b/src/argprocessing.cpp
@@ -232,6 +232,15 @@ process_arg(Context& ctx,
return nullopt;
}
+ // Ignore clang -ivfsoverlay <arg> to not detect multiple input files.
+ if (args[i] == "-ivfsoverlay"
+ && !(config.sloppiness() & SLOPPY_IVFSOVERLAY)) {
+ LOG_RAW(
+ "You have to specify \"ivfsoverlay\" sloppiness when using"
+ " -ivfsoverlay to get hits");
+ return Statistic::unsupported_compiler_option;
+ }
+
// Special case for -E.
if (args[i] == "-E") {
return Statistic::called_for_preprocessing;
diff --git a/src/compopt.cpp b/src/compopt.cpp
index 96cc047c..447f8e99 100644
--- a/src/compopt.cpp
+++ b/src/compopt.cpp
@@ -115,6 +115,7 @@ const CompOpt compopts[] = {
{"-iquote", AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
{"-isysroot", AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
{"-isystem", AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
+ {"-ivfsoverlay", TAKES_ARG},
{"-iwithprefix", AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
{"-iwithprefixbefore",
AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c33befd0..ae0df8e8 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -47,6 +47,7 @@ addtest(fileclone)
addtest(hardlink)
addtest(inode_cache)
addtest(input_charset)
+addtest(ivfsoverlay)
addtest(masquerading)
addtest(modules)
addtest(multi_arch)
diff --git a/test/suites/ivfsoverlay.bash b/test/suites/ivfsoverlay.bash
new file mode 100644
index 00000000..ca882217
--- /dev/null
+++ b/test/suites/ivfsoverlay.bash
@@ -0,0 +1,44 @@
+SUITE_ivfsoverlay_PROBE() {
+ if ! $COMPILER_TYPE_CLANG; then
+ echo "-ivfsoverlay not supported by compiler"
+ else
+ touch test.c
+ cat <<EOF >test.yaml
+{"case-sensitive":"false","roots":[],"version":0}
+EOF
+ $COMPILER -ivfsoverlay test.yaml test.c -S || echo "compiler does not support -ivfsoverlay"
+ fi
+}
+
+SUITE_ivfsoverlay_SETUP() {
+ unset CCACHE_NODIRECT
+
+ cat <<EOF >test.yaml
+{"case-sensitive":"false","roots":[],"version":0}
+EOF
+ cat <<EOF >test.c
+// test.c
+int test;
+EOF
+}
+
+SUITE_ivfsoverlay() {
+ # -------------------------------------------------------------------------
+ TEST "without sloppy ivfsoverlay"
+
+ $CCACHE_COMPILE -ivfsoverlay test.yaml -c test.c
+ expect_stat 'cache hit (direct)' 0
+ expect_stat 'cache miss' 0
+ expect_stat 'unsupported compiler option' 1
+
+ # -------------------------------------------------------------------------
+ TEST "with sloppy ivfsoverlay"
+
+ CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS ivfsoverlay" $CCACHE_COMPILE -ivfsoverlay test.yaml -c test.c
+ expect_stat 'cache hit (direct)' 0
+ expect_stat 'cache miss' 1
+
+ CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS ivfsoverlay" $CCACHE_COMPILE -ivfsoverlay test.yaml -c test.c
+ expect_stat 'cache hit (direct)' 1
+ expect_stat 'cache miss' 1
+}
diff --git a/unittest/test_Config.cpp b/unittest/test_Config.cpp
index fad4ff42..e509c9ce 100644
--- a/unittest/test_Config.cpp
+++ b/unittest/test_Config.cpp
@@ -128,7 +128,7 @@ TEST_CASE("Config::update_from_file")
"run_second_cpp = false\n"
"sloppiness = time_macros ,include_file_mtime"
" include_file_ctime,file_stat_matches,file_stat_matches_ctime,pch_defines"
- " , no_system_headers,system_headers,clang_index_store\n"
+ " , no_system_headers,system_headers,clang_index_store,ivfsoverlay\n"
"stats = false\n"
"temporary_dir = ${USER}_foo\n"
"umask = 777"); // Note: no newline.
@@ -169,7 +169,8 @@ TEST_CASE("Config::update_from_file")
== (SLOPPY_INCLUDE_FILE_MTIME | SLOPPY_INCLUDE_FILE_CTIME
| SLOPPY_TIME_MACROS | SLOPPY_FILE_STAT_MATCHES
| SLOPPY_FILE_STAT_MATCHES_CTIME | SLOPPY_SYSTEM_HEADERS
- | SLOPPY_PCH_DEFINES | SLOPPY_CLANG_INDEX_STORE));
+ | SLOPPY_PCH_DEFINES | SLOPPY_CLANG_INDEX_STORE
+ | SLOPPY_IVFSOVERLAY));
CHECK_FALSE(config.stats());
CHECK(config.temporary_dir() == FMT("{}_foo", user));
CHECK(config.umask() == 0777);
@@ -402,7 +403,7 @@ TEST_CASE("Config::visit_items")
"run_second_cpp = false\n"
"sloppiness = include_file_mtime, include_file_ctime, time_macros,"
" file_stat_matches, file_stat_matches_ctime, pch_defines, system_headers,"
- " clang_index_store\n"
+ " clang_index_store, ivfsoverlay\n"
"stats = false\n"
"temporary_dir = td\n"
"umask = 022\n");
@@ -459,7 +460,7 @@ TEST_CASE("Config::visit_items")
"(test.conf) run_second_cpp = false",
"(test.conf) sloppiness = include_file_mtime, include_file_ctime,"
" time_macros, pch_defines, file_stat_matches, file_stat_matches_ctime,"
- " system_headers, clang_index_store",
+ " system_headers, clang_index_store, ivfsoverlay",
"(test.conf) stats = false",
"(test.conf) temporary_dir = td",
"(test.conf) umask = 022",