[cfe-commits] [patch] Add support for -fpredictive-compilation

Nico Weber thakis at chromium.org
Mon Sep 12 21:43:08 PDT 2011


Hi,

the attached patch adds support for -fpredictive-compilation, for
compatibility with Apple gcc 4.2.

With this flag, clang needs an input file name like normally, and uses
the input file to deduce the language (but -x can override it) and the
default output filename (but -o can override it). The input filename
is also used in diagnostic messages, but the actual compiler input is
read from standard input.

With this patch, Xcode 3.2 can be started with

    /Developer/Applications/Xcode.app/Contents/MacOS/Xcode CC=path/to/clang

and even with predictive compilation enabled (the default), cmd-k and
friends work correctly. (Xcode uses -fpredictive-compilation for this
as soon as the user changes a file. Since clang used to ignore this
flag, clang would compile the file as it exists on disk, while Xcode
would think that the file that it piped to stdin was built, which
would lead to error messages that were delayed by one compilation.)

Ok?

(In gcc, -fpredictive-compilation does not read from stdin if
-fpreprocessed is passed as well, but clang doesn't support
-fpreprocessed, so that logic is not required.)

Thanks,
Nico
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-fpredictive.patch
Type: application/octet-stream
Size: 8505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110912/eb37effa/attachment.obj>


More information about the cfe-commits mailing list