Fixes #1663.
// These options require special handling, because they behave differently
// with gcc -E, when the output file is not specified.
- if ((arg == "-MD" || arg == "-MMD") && !config.is_compiler_group_msvc()) {
+ if (!config.is_compiler_group_msvc()
+ && (arg == "-MD"
+ || arg == "-MMD"
+ // nvcc -MD:
+ || arg == "--generate-dependencies-with-compile"
+ // nvcc -MMD:
+ || arg == "--generate-nonsystem-dependencies-with-compile")) {
state.found_md_or_mmd_opt = true;
args_info.generating_dependencies = true;
state.add_compiler_only_arg(args[i]);
return Statistic::none;
}
- if (util::starts_with(arg, "-MF")) {
+ if (util::starts_with(arg, "-MF")
+ // nvcc -MF:
+ || arg == "--dependency-output") {
state.found_mf_opt = true;
std::string dep_file;
- bool separate_argument = (arg.size() == 3);
+ bool separate_argument = (arg.size() == 3 || arg == "--dependency-output");
if (separate_argument) {
// -MF arg
if (i == args.size() - 1) {
return Statistic::none;
}
- if ((util::starts_with(arg, "-MQ") || util::starts_with(arg, "-MT"))
- && !config.is_compiler_group_msvc()) {
+ if (!config.is_compiler_group_msvc()
+ && (util::starts_with(arg, "-MQ")
+ || util::starts_with(arg, "-MT")
+ // nvcc -MT:
+ || arg == "--dependency-target-name")) {
const bool is_mq = arg[2] == 'Q';
std::string_view dep_target;
- if (arg.size() == 3) {
+ if (arg.size() == 3 || arg == "--dependency-target-name") {
// -MQ arg or -MT arg
if (i == args.size() - 1) {
LOG("Missing argument to {}", args[i]);
return Statistic::none;
}
- if (arg == "-MP") {
+ if (arg == "-MP"
+ // nvcc -MP:
+ || arg == "--generate-dependency-targets") {
state.add_compiler_only_arg(args[i]);
return Statistic::none;
}
}
if (ctx.args_info.generating_dependencies) {
- std::optional<std::string_view> option;
- std::optional<std::string_view> value;
-
if (util::starts_with(args[i], "-Wp,")) {
// Skip the dependency filename since it doesn't impact the output.
if (util::starts_with(args[i], "-Wp,-MD,")
hash.hash(args[i].data(), 9);
return {};
}
- } else if (std::tie(option, value) = get_option_and_value("-MF", args, i);
- option) {
- // Skip the dependency filename since it doesn't impact the output.
- hash.hash(*option);
- return {};
- } else if (std::tie(option, value) = get_option_and_value("-MQ", args, i);
- option) {
- hash.hash(*option);
- // No need to hash the dependency target since we always calculate it on
- // a cache hit.
- return {};
- } else if (std::tie(option, value) = get_option_and_value("-MT", args, i);
- option) {
- hash.hash(*option);
- // No need to hash the dependency target since we always calculate it on
- // a cache hit.
- return {};
+ } else {
+ static std::array skip_options = {
+ "-MF", // dependency filename doesn't impact the output
+ "-MQ", // dependency target is calculated on cache hit
+ "-MT", // dependency target is calculated on cache hit
+ "--dependency-output", // nvcc version of -MF
+ "--dependency-target-name", // nvcc version of -MT
+ };
+ for (auto opt : skip_options) {
+ if (const auto [option, _value] = get_option_and_value(opt, args, i);
+ option) {
+ hash.hash(*option);
+ return {};
+ }
+ }
}
}
int type;
};
+// clang-format off
const CompOpt compopts[] = {
{"--Werror", TAKES_ARG | AFFECTS_COMP }, // nvcc
{"--analyzer-output", TOO_HARD }, // Clang
{"--config", TAKES_ARG }, // Clang
{"--em-config", TAKES_ARG }, // emcc
{"--gcc-toolchain=", TAKES_CONCAT_ARG | TAKES_PATH }, // Clang
+ {"--generate-dependencies", TOO_HARD }, // nvcc (-M)
+ {"--generate-nonsystem-dependencies", TOO_HARD }, // nvcc (-MM)
{"--include", AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
{"--libdevice-directory", AFFECTS_CPP | TAKES_ARG }, // nvcc
{"--offload-compress", AFFECTS_COMP }, // Clang
{"-wrapper", TAKES_ARG | TOO_HARD },
{"-z", TAKES_ARG | TAKES_CONCAT_ARG | AFFECTS_COMP },
};
+// clang-format on
static int
compare_compopts(const void* key1, const void* key2)