From: Josh Triplett Date: Mon, 3 May 2021 17:00:19 +0000 (-0700) Subject: Support `-specs file.specs` and `--specs file.specs` (#843) X-Git-Tag: v4.3~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5aadd84bc6652f32eed7600c97a85debd117260d;p=thirdparty%2Fccache.git Support `-specs file.specs` and `--specs file.specs` (#843) * 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`. --- diff --git a/src/ccache.cpp b/src/ccache.cpp index 8410e6466..a40b21e17 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -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 diff --git a/src/compopt.cpp b/src/compopt.cpp index 447f8e99a..3ed4f5b5b 100644 --- a/src/compopt.cpp +++ b/src/compopt.cpp @@ -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},