Hi, at the moment, if I try to build with multiple -arch flags (so i create an universal binary) ccache only reports "preprocessor error" in the ccache-stats (on 2.4 and 3.0pre0) I made a little (perhaps not so clean) patch for 2.4 to strip out the -arch parameters on the preprocessor run: ----------------------------------------------------------------------------- --- ccache.c.orig 2004-09-13 12:38:30.000000000 +0200 +++ ccache.c 2010-04-30 15:45:43.000000000 +0200 @@ -363,11 +363,27 @@ x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string()); if (!direct_i_file) { + int i = 0; + ARGS *nargs = args_init(args->argc, args->argv); + /* run cpp on the input file to obtain the .i */ - args_add(args, "-E"); - args_add(args, input_file); - status = execute(args->argv, path_stdout, path_stderr); - args_pop(args, 2); + args_add(nargs, "-E"); + args_add(nargs, input_file); + + /* remove -arch parameters */ + for(i = 0; i < nargs->argc;) + { + if(strcmp(nargs->argv[i], "-arch") == 0) + { + strcpy(nargs->argv[i++],""); + strcpy(nargs->argv[i],""); + } + else + ++i; + } + + status = execute(nargs->argv, path_stdout, path_stderr); + /*args_pop(args, 2);*/ } else { /* we are compiling a .i or .ii file - that means we can skip the cpp stage and directly form the ------------------------------------------------------------------------------ (i hope the whitespaces are not stripped here)
Created attachment 5675 [details] the patch as attachment
Hi, I don't know much about Mac OS X, but does your patch really preserve the semantics of the compiler? I.e., will gcc -arch x -arch y -c foo.c -o foo.o and gcc -c foo.c -E -o foo.i gcc -arch x -arch y -c foo.i -o foo.o always give the same foo.o? The reason I'm asking is that apparently there was some work made in 2006 by David Vasilevsky to fix the same problem: http://www.mail-archive.com/ccache@lists.samba.org/msg00125.html His repository seems to be gone, but you can read the commits here: http://www.mail-archive.com/search?l=fink-commits%40lists.sourceforge.net&q=ccache-multiarch The changes he made seem to be much more complicated than your fix. Do you have any thoughts about his approach?
Hi, yes I think its not as easy as I thought, My first approach was not working correctly. I will look at the code you mentioned, perhaps I can change my patch so it will work (or simply use the multiarch-stuff)
Hi, I don't know if here's some progress on that topic, but I've created a little wrapper (like ccache itself) for ccache and universal-builds https://code.launchpad.net/~flosoft/+junk/ccache_lipo its really quick&dirty solution, but it works for my cross-compilers and my use-case (called via cmake) perhaps someone can use it to create a universally working solution
Florian, any news on this issue? Perhaps it should be closed?
well, I use the ccache_lipo I wrote "instead" of ccache for multi-arch compiles and that works fine. ccache_lipo does nothing else than splitting the command line (filtering out -arch parameters) and call the (ccache)-compiler for each arch, and "lipo" them at the end. perhaps someone can integrate it into ccache directly.
Closing this as WONTFIX.