Skip to content

Instantly share code, notes, and snippets.

@torarnv
Created August 18, 2026 21:57
Show Gist options
  • Select an option

  • Save torarnv/ad6c6495e15f06392c0cce9492ff07ac to your computer and use it in GitHub Desktop.

Select an option

Save torarnv/ad6c6495e15f06392c0cce9492ff07ac to your computer and use it in GitHub Desktop.
commit b8a8c3f5ff88f444d67cdedac4e192821a93e1c5
Author: Tor Arne Vestbø <torarnv@gmail.com>
Date: Tue Aug 18 23:31:53 2026 +0200
gcc_wrapper: Recognize Objective-C and Objective-C++ source files
is_source_file() only knew about .c, .cc, .cpp and .cxx. For an .m or
.mm compilation get_input_files() therefore returned an empty list,
which disabled direct mode, and maybe_generate_dependency_file() found
no source file and threw. That happens after the cache entry has already
been restored, so handle_command() aborted and buildcache fell back to
running the compiler. An Objective-C++ compilation thus paid for both a
full preprocessing pass and a full compilation on every build.
Objective-C and Objective-C++ entries stored by earlier versions become
unreachable, since the source file argument is now filtered out of the
hashed arguments. HASH_VERSION is left alone so that entries for the
other languages remain valid.
diff --git a/src/wrappers/gcc_wrapper.cpp b/src/wrappers/gcc_wrapper.cpp
index 84368e1..0e85618 100644
--- a/src/wrappers/gcc_wrapper.cpp
+++ b/src/wrappers/gcc_wrapper.cpp
@@ -188,8 +188,10 @@ bool gcc_wrapper_t::is_arg_plus_file_name(const std::string& arg) {
}
bool gcc_wrapper_t::is_source_file(const std::string& arg) {
+ static const std::set<std::string> source_exts = {
+ ".c", ".cc", ".cpp", ".cxx", ".m", ".mm"};
const auto ext = lower_case(file::get_extension(arg));
- return ((ext == ".cpp") || (ext == ".cc") || (ext == ".cxx") || (ext == ".c"));
+ return source_exts.find(ext) != source_exts.end();
}
gcc_wrapper_t::gcc_wrapper_t(const file::exe_path_t& exe_path,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment