We recommend that developers who want the fastest incremental builds use the Ninja build system. You can use the generated Visual Studio project files to edit Clang source code and generate a second build directory next to it for running the tests with these steps:
The clang tool is the compiler driver and front-end, which is designed to be a drop-in replacement for the gcc command. Here are some examples of how to use the high-level driver:
$ cat t.c #include <stdio.h> int main(int argc, char **argv) { printf("hello world\n"); } $ clang t.c $ ./a.out hello world
The 'clang' driver is designed to work as closely to GCC as possible to maximize portability. The only major difference between the two is that Clang defaults to gnu99 mode while GCC defaults to gnu89 mode. If you see weird link-time errors relating to inline functions, try passing -std=gnu89 to clang.
$ cat ~/t.c typedef float V __attribute__((vector_size(16))); V foo(V a, V b) { return a+b*a; }
$ clang ~/t.c -E # 1 "/Users/sabre/t.c" 1 typedef float V __attribute__((vector_size(16))); V foo(V a, V b) { return a+b*a; }
$ clang -fsyntax-only ~/t.c
$ clang -fsyntax-only ~/t.c -pedantic /Users/sabre/t.c:2:17: warning: extension used typedef float V __attribute__((vector_size(16))); ^ 1 diagnostic generated.
Note, the -cc1 argument indicates the compiler front-end, and not the driver, should be run. The compiler front-end has several additional Clang specific features which are not exposed through the GCC compatible driver interface.
$ clang -cc1 ~/t.c -ast-print typedef float V __attribute__(( vector_size(16) )); V foo(V a, V b) { return a + b * a; }
$ clang ~/t.c -S -emit-llvm -o - define <4 x float> @foo(<4 x float> %a, <4 x float> %b) { entry: %mul = mul <4 x float> %b, %a %add = add <4 x float> %mul, %a ret <4 x float> %add } $ clang -fomit-frame-pointer -O3 -S -o - t.c# On x86_64 ... _foo: Leh_func_begin1: mulps %xmm0, %xmm1 addps %xmm1, %xmm0 ret Leh_func_end1: