]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Allow nonexistent include files in preprocessor mode
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 21 Feb 2024 19:25:03 +0000 (20:25 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 21 Feb 2024 19:51:55 +0000 (20:51 +0100)
After 43c3a44aadcb nonexistent include files found in the preprocessed
output would increment "Could not read or parse input file" and fall
back to just running the compiler. This made ccache not attempt
preprocessor mode for generated code with #line header referencing files
that can't be found, e.g. in an out-of-source build scenario.

Fix this by just disabling direct mode, restoring the pre-43c3a44aadcb
behavior in such cases.

Fixes #1406.

src/ccache.cpp

index 3bf62142136f0ba35102bcbaedb5f9819fc86aee..e9db8c5727cb8a10ec08fa4d4b2b9e38e1996540 100644 (file)
@@ -349,7 +349,12 @@ remember_include_file(Context& ctx,
 
   DirEntry dir_entry(path, DirEntry::LogOnError::yes);
   if (!dir_entry.exists()) {
-    return tl::unexpected(Statistic::bad_input_file);
+    if (ctx.config.direct_mode()) {
+      LOG("Include file {} does not exist, disabling direct mode",
+          dir_entry.path());
+      ctx.config.set_direct_mode(false);
+    }
+    return {};
   }
   if (dir_entry.is_directory()) {
     // Ignore directory, typically $PWD.