]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Handle command line config options ending with /ccache properly
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 25 Jan 2025 19:32:29 +0000 (20:32 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 25 Jan 2025 21:14:14 +0000 (22:14 +0100)
Fixes #1560.

src/ccache/ccache.cpp
unittest/test_ccache.cpp

index 4608f92b64d641646600e4f8f791f8112e7572cc..53003753a32cec8fbb7f50fd73a7b3b6adc1ec54 100644 (file)
@@ -2504,7 +2504,8 @@ split_argv(int argc, const char* const* argv)
 {
   ArgvParts argv_parts;
   int i = 0;
-  while (i < argc && is_ccache_executable(argv[i])) {
+  while (i < argc && !std::strchr(argv[i], '=')
+         && is_ccache_executable(argv[i])) {
     argv_parts.masquerading_as_compiler = false;
     ++i;
   }
index d80981e1b733e72489159861ca033f686e50c666..69770cb22904d47b2ef93fd02b2cda2d1723b91c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -109,6 +109,15 @@ TEST_CASE("split_argv")
           == std::vector<std::string>{"a=b", "c = d"});
     CHECK(argv_parts.compiler_and_args == Args::from_string("/usr/bin/gcc"));
   }
+
+  SUBCASE("compilation with config option ending with /ccache")
+  {
+    const char* const argv[] = {"ccache", "a=b/ccache", "/usr/bin/gcc"};
+    argv_parts = split_argv(std::size(argv), argv);
+    CHECK(!argv_parts.masquerading_as_compiler);
+    CHECK(argv_parts.config_settings == std::vector<std::string>{"a=b/ccache"});
+    CHECK(argv_parts.compiler_and_args == Args::from_string("/usr/bin/gcc"));
+  }
 }
 
 TEST_CASE("find_compiler")