[ccache] [PATCH] Support multiple -arch options

David Vasilevsky djvasi at gmail.com
Thu Oct 5 15:48:12 GMT 2006

On Mac OS X, it is common to create "Universal binary" (aka "fat") binaries
that work on both x86 and PowerPC. This is done with a command like: "gcc
-arch ppc -arch i386 -c foo.c". When GCC encounters a command like this, it
icompiles once for each arch and then combines the results with the "lipo"
tool. Unfortunately, "gcc -E" can't work with two arches since there is only
one stdout, so ccache rejects this sort of compilation with "preprocessor

The attached patch adds support to ccache for these sorts of commands. If
multiple arches are requested, ccache will do the hash/search/store thing
once per arch, and then use lipo just like GCC. Any number of arches may be
fetched or stored in a single compilation.

If the environment variable CCACHE_DEFAULT_ARCH is set and non-empty, then
it contains the arch that ccache should assume if no -arch is given. This
allows it to recognize that -arch ppc should hash the same as with no arch
on a PPC machine, etc. If CCACHE_DEFAULT_ARCH is set and empty, ccache will
not assume any default arch. If it is unset, then on OS X ccache will
attempt to discover the default arch--this feature may be unsafe in the case
that the user has compiled their own multi-arch GCC.

A few important global variables are added or changed:
- output_file splits into final_out (for the final output) and current_out
(the output file for the current loop).
- arches lists all requested arches.
- arch_outs lists the intermediate output files, so they can be cleaned up
- arch_str contains a string indicating the current arch, for logging

My svn repo is at


More information about the ccache mailing list