[ccache] Bail out on -arch?

Joel Rosdahl joel at rosdahl.net
Wed May 12 00:53:18 MDT 2010


On 2010-05-11 13:03, Bernhard Bauer wrote:
> I agree, with a single -arch option gcc should behave fully identical.

The change was made as a "better safe than sorry" reaction to this bug
report: <https://bugzilla.samba.org/show_bug.cgi?id=7401>. I didn't
realize that the -arch option was used for one architecture builds.
Here's a fix:

--- a/ccache.c
+++ b/ccache.c
@@ -1214,6 +1214,7 @@ static void process_args(int argc, char **argv,
ARGS **preprocessor_args,
        int i;
        int found_c_opt = 0;
        int found_S_opt = 0;
+       int found_arch_opt = 0;
        struct stat st;
        /* is the dependency makefile name overridden with -MF? */
        int dependency_filename_specified = 0;
@@ -1238,7 +1239,6 @@ static void process_args(int argc, char **argv,
ARGS **preprocessor_args,
                    strcmp(argv[i], "--coverage") == 0 ||
                    strcmp(argv[i], "-M") == 0 ||
                    strcmp(argv[i], "-MM") == 0 ||
-                   strcmp(argv[i], "-arch") == 0 ||
                    strcmp(argv[i], "-fbranch-probabilities") == 0 ||
                    strcmp(argv[i], "-fprofile-arcs") == 0 ||
                    strcmp(argv[i], "-fprofile-generate") == 0 ||
@@ -1261,6 +1261,18 @@ static void process_args(int argc, char **argv,
ARGS **preprocessor_args,
                        }
                }

+               /* Multiple -arch options are too hard. */
+               if (strcmp(argv[i], "-arch") == 0) {
+                       if (found_arch_opt) {
+                               cc_log("More than one -arch compiler option"
+                                      " is unsupported");
+                               stats_update(STATS_UNSUPPORTED);
+                               failed();
+                       } else {
+                               found_arch_opt = 1;
+                       }
+               }
+
                /* we must have -c */
                if (strcmp(argv[i], "-c") == 0) {
                        args_add(stripped_args, argv[i]);



> And even with multiple architectures we should be fine, because ccache
> doesn't really depend on the output format of the compiler, as long as
> the semantics of how the output file depends on the input files and
> the compiler options are the same.

The problem is that ccache needs to run the preprocessor explicitly, and
that fails when there are multiple -arch options.

-- Joel


More information about the ccache mailing list