From: Alexander Korsunsky Date: Tue, 16 Apr 2019 14:38:51 +0000 (+0200) Subject: When compiling CUDA code, recognize -dc as compilation only argument X-Git-Tag: v4.0~862 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cece6046bbab113eb57018b41a679b82ff6d8f62;p=thirdparty%2Fccache.git When compiling CUDA code, recognize -dc as compilation only argument nvcc's options -dc or --device-c imply -c but also generates device code. We catch it as an option if our guessed compiler is NVCC --- diff --git a/src/ccache.c b/src/ccache.c index 1781fb114..d87c53b9f 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -2300,6 +2300,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, struct args **compiler_args) { bool found_c_opt = false; + bool found_dc_opt = false; bool found_S_opt = false; bool found_pch = false; bool found_fpch_preprocess = false; @@ -2508,6 +2509,12 @@ cc_process_args(struct args *args, struct args **preprocessor_args, continue; } + // when using nvcc with separable compilation, -dc implies -c + if ((str_eq(argv[i], "-dc") || str_eq(argv[i], "--device-c")) && guessed_compiler == GUESSED_NVCC) { + found_dc_opt = true; + continue; + } + // -S changes the default extension. if (str_eq(argv[i], "-S")) { args_add(common_args, argv[i]); @@ -3013,7 +3020,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, if (language_for_file(argv[i])) { cc_log("Multiple input files: %s and %s", input_file, argv[i]); stats_update(STATS_MULTIPLE); - } else if (!found_c_opt) { + } else if (!found_c_opt && !found_dc_opt) { cc_log("Called for link with %s", argv[i]); if (strstr(argv[i], "conftest.")) { stats_update(STATS_CONFTEST); @@ -3152,7 +3159,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, goto out; } - if (!found_c_opt && !found_S_opt) { + if (!found_c_opt && !found_dc_opt && !found_S_opt) { if (output_is_precompiled_header) { args_add(common_args, "-c"); } else { @@ -3355,6 +3362,10 @@ cc_process_args(struct args *args, struct args **preprocessor_args, args_add(*compiler_args, "-c"); } + if (found_dc_opt) { + args_add(*compiler_args, "-dc"); + } + for (size_t i = 0; i < arch_args_size; ++i) { args_add(*compiler_args, "-arch"); args_add(*compiler_args, arch_args[i]);