From b2d6d53d7cbb303573ccce79ddfe74acad08c03f Mon Sep 17 00:00:00 2001 From: Clemens Rabe Date: Fri, 7 Nov 2014 21:10:51 +0100 Subject: [PATCH] Add support for cuda including the -optf option --- ccache.c | 41 +++++++++++++++++++++++++++++++++++++++++ language.c | 3 +++ 2 files changed, 44 insertions(+) diff --git a/ccache.c b/ccache.c index 7bd7788e8..2bb2179e2 100644 --- a/ccache.c +++ b/ccache.c @@ -1884,6 +1884,47 @@ cc_process_args(struct args *args, struct args **preprocessor_args, continue; } + /* Handle cuda "-optf" and "--options-file" argument. */ + if (str_eq(argv[i], "-optf") || str_eq(argv[i], "--options-file")) { + if (++i >= argc) { + cc_log("Expected argument after the '-optf' resp. '--options-file' option!"); + stats_update(STATS_UNSUPPORTED); + result = false; + goto out; + } + + /* Argument is a comma separated list of files. */ + char *strStart = argv[i]; + char *strEnd = strchr(strStart,','); + int index = i+1; + + if (!strEnd) { + strEnd = strStart + strlen(strStart); + } + + while (strEnd) { + *strEnd = (char) 0; + struct args *file_args; + file_args = args_init_from_gcc_atfile(strStart); + if (!file_args) { + cc_log("Couldn't read cuda options file %s", strStart); + stats_update(STATS_ARGS); + result = false; + goto out; + } + + int newIndex = file_args->argc + index; + args_insert(expanded_args, index, file_args, false); + index = newIndex; + strStart = strEnd; + strEnd = strchr(strStart,','); + } + + argc = expanded_args->argc; + argv = expanded_args->argv; + continue; + } + /* These are always too hard. */ if (compopt_too_hard(argv[i]) || str_startswith(argv[i], "-fdump-")) { diff --git a/language.c b/language.c index 78c4a7d02..bea4bf9d2 100644 --- a/language.c +++ b/language.c @@ -61,6 +61,8 @@ static const struct { {".HXX", "c++-header"}, {".tcc", "c++-header"}, {".TCC", "c++-header"}, + {".cu", "cuda"}, + {".ic", "cuda-output"}, {NULL, NULL} }; @@ -85,6 +87,7 @@ static const struct { {"objc++-cpp-output", "objective-c++-cpp-output"}, {"objective-c++-header", "objective-c++-cpp-output"}, {"objective-c++-cpp-output", "objective-c++-cpp-output"}, + {"cuda", "cuda-output"}, {NULL, NULL} }; -- 2.47.2