]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Support `-specs file.specs` and `--specs file.specs` (#843)
authorJosh Triplett <josh@joshtriplett.org>
Mon, 3 May 2021 17:00:19 +0000 (10:00 -0700)
committerGitHub <noreply@github.com>
Mon, 3 May 2021 17:00:19 +0000 (19:00 +0200)
* Support `-specs file.specs` and `--specs file.specs`

ccache currently supports specs files supplied via `-specs=file.specs`
and `--specs=file.specs`, but using a space instead of an `=` will cause
ccache to error out on the subsequent .specs file with
"unsupported source language".

Add support for `-specs file.specs` and `--specs file.specs`.

src/ccache.cpp
src/compopt.cpp

index 8410e64665d0cf9d8c9e2f795e9fdff5e416a26d..a40b21e17382a27d31cff277721e9fa5f9244a87 100644 (file)
@@ -1652,8 +1652,20 @@ calculate_result_name(Context& ctx,
     }
 
     if (Util::starts_with(args[i], "-specs=")
-        || Util::starts_with(args[i], "--specs=")) {
-      std::string path = args[i].substr(args[i].find('=') + 1);
+        || Util::starts_with(args[i], "--specs=")
+        || (args[i] == "-specs" || args[i] == "--specs")) {
+      std::string path;
+      size_t eq_pos = args[i].find('=');
+      if (eq_pos == std::string::npos) {
+        if (i + 1 >= args.size()) {
+          LOG("missing argument for \"{}\"", args[i]);
+          throw Failure(Statistic::bad_compiler_arguments);
+        }
+        path = args[i + 1];
+        i++;
+      } else {
+        path = args[i].substr(eq_pos + 1);
+      }
       auto st = Stat::stat(path, Stat::OnError::log);
       if (st) {
         // If given an explicit specs file, then hash that file, but don't
index 447f8e99aca54496a0dbdd80b5ddfd80424b1664..3ed4f5b5b8acb0ec44558407834cd1b79af3bc41 100644 (file)
@@ -62,6 +62,7 @@ const CompOpt compopts[] = {
   {"--save-temps=cwd", TOO_HARD},
   {"--save-temps=obj", TOO_HARD},
   {"--serialize-diagnostics", TAKES_ARG | TAKES_PATH},
+  {"--specs", TAKES_ARG},
   {"-A", TAKES_ARG},
   {"-B", TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
   {"-D", AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG},
@@ -132,6 +133,7 @@ const CompOpt compopts[] = {
   {"-save-temps", TOO_HARD},
   {"-save-temps=cwd", TOO_HARD},
   {"-save-temps=obj", TOO_HARD},
+  {"-specs", TAKES_ARG},
   {"-stdlib=", AFFECTS_CPP | TAKES_CONCAT_ARG},
   {"-trigraphs", AFFECTS_CPP},
   {"-u", TAKES_ARG | TAKES_CONCAT_ARG},