From: Joel Rosdahl Date: Sat, 25 Mar 2017 15:59:22 +0000 (+0100) Subject: Revert "Better parsing of g* Options, and only use last argument" X-Git-Tag: v3.3.5~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8aeb9826fcbf4627df8c0d9a9b110c4523ea0f1;p=thirdparty%2Fccache.git Revert "Better parsing of g* Options, and only use last argument" This reverts commit 21e2652c62762e5c9a017ea1523f6cfb3f1bcf7d. The feature introduced in #92 changes the order of debug options, leading to bugs like #149. It would be possible to add more logic to handle special cases like -gsplit-dwarf, but for now I'll just back out the patch and keep ccache ignorant about debug options. Fixes #149 --- diff --git a/NEWS.txt b/NEWS.txt index e15f18cd1..225a400ab 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,6 +1,17 @@ ccache news =========== +ccache 3.3.5 +------------ +Not yet released + +Bug fixes +~~~~~~~~~ + +- Fixed a regression where the original order of debug options could be lost. + This reverts the ``Improved parsing of `-g*` options'' feature in ccache 3.3. + + ccache 3.3.4 ------------ Release date: 2017-02-17 diff --git a/ccache.c b/ccache.c index de2b1e3d5..4081b0b2f 100644 --- a/ccache.c +++ b/ccache.c @@ -2110,8 +2110,6 @@ cc_process_args(struct args *args, struct args **preprocessor_args, struct args *dep_args = args_init(0, NULL); bool found_color_diagnostics = false; - int debug_level = 0; - const char *debug_argument = NULL; int argc = expanded_args->argc; char **argv = expanded_args->argv; @@ -2317,32 +2315,17 @@ cc_process_args(struct args *args, struct args **preprocessor_args, // Debugging is handled specially, so that we know if we can strip line // number info. if (str_startswith(argv[i], "-g")) { - const char *pLevel = argv[i] + 2; - if (str_startswith(argv[i], "-ggdb")) { - pLevel = argv[i] + 5; - } else if (str_startswith(argv[i], "-gstabs")) { - pLevel = argv[i] + 7; - } else if (str_startswith(argv[i], "-gcoff")) { - pLevel = argv[i] + 6; - } else if (str_startswith(argv[i], "-gxcoff")) { - pLevel = argv[i] + 7; - } else if (str_startswith(argv[i], "-gvms")) { - pLevel = argv[i] + 5; - } - - // Deduce level from argument, default is 2. - int foundlevel = -1; - if (pLevel[0] == '\0') { - foundlevel = 2; - } else if (pLevel[0] >= '0' && pLevel[0] <= '9') { - foundlevel = atoi(pLevel); - } - - if (foundlevel >= 0) { - debug_level = foundlevel; - debug_argument = argv[i]; - continue; + generating_debuginfo = true; + args_add(stripped_args, argv[i]); + if (conf->unify && !str_eq(argv[i], "-g0")) { + cc_log("%s used; disabling unify mode", argv[i]); + conf->unify = false; } + if (str_eq(argv[i], "-g3")) { + cc_log("%s used; not compiling preprocessed code", argv[i]); + conf->run_second_cpp = true; + } + continue; } // These options require special handling, because they behave differently @@ -2726,19 +2709,6 @@ cc_process_args(struct args *args, struct args **preprocessor_args, } } // for - if (debug_level > 0) { - generating_debuginfo = true; - args_add(stripped_args, debug_argument); - if (conf->unify) { - cc_log("%s used; disabling unify mode", debug_argument); - conf->unify = false; - } - if (debug_level >= 3 && !conf->run_second_cpp) { - cc_log("%s used; not compiling preprocessed code", debug_argument); - conf->run_second_cpp = true; - } - } - if (found_S_opt) { // Even if -gsplit-dwarf is given, the .dwo file is not generated when -S // is also given.