]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Enforce cpp2 mode on macOS if -g is given
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 5 Mar 2021 19:37:51 +0000 (20:37 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 6 Mar 2021 18:02:37 +0000 (19:02 +0100)
Newer Clang versions on macOS apparently produce different debug
information when compiling preprocessed code.

As mentioned in issue #807.

src/argprocessing.cpp

index ec8d7952b27bb3ab7f68b4089282d5b85acb19c3..fb90fc71598768a51b2f8da663e0c944aab55a83 100644 (file)
@@ -1000,10 +1000,21 @@ process_args(Context& ctx)
   }
 
   if (state.generating_debuginfo_level_3 && !config.run_second_cpp()) {
+    // Debug level 3 makes line number information incorrect when compiling
+    // preprocessed code.
     LOG_RAW("Generating debug info level 3; not compiling preprocessed code");
     config.set_run_second_cpp(true);
   }
 
+#ifdef __APPLE__
+  // Newer Clang versions on macOS are known to produce different debug
+  // information when compiling preprocessed code.
+  if (args_info.generating_debuginfo && !config.run_second_cpp()) {
+    LOG_RAW("Generating debug info; not compiling preprocessed code");
+    config.set_run_second_cpp(true);
+  }
+#endif
+
   handle_dependency_environment_variables(ctx, state);
 
   if (args_info.input_file.empty()) {