]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Revert "Better parsing of g* Options, and only use last argument"
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 25 Mar 2017 15:59:22 +0000 (16:59 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 25 Mar 2017 15:59:22 +0000 (16:59 +0100)
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

NEWS.txt
ccache.c

index e15f18cd1c2d895c5f6d0ad016593de910244071..225a400abf68edc179f3fa35b805cab252ff9b09 100644 (file)
--- 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
index de2b1e3d53670762b206dd2eb8c3b2b2478716f7..4081b0b2fd94f537cfa1f5a833d5f2cf88634efa 100644 (file)
--- 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.