ccc with Xcode tool targets

The attached patch adds more gcc-like functionality to ccc so that it can be used as a drop-in CC/LD with Xcode/xcodebuild for building tool targets.

For example, given a "CoreFoundation Tool" target (and the default main.c that Xcode creates), you can do:

$ export PATH=/Volumes/HD/ltmp/ssen/src/llvm/Debug/bin:$PATH
$ export CCC=/Volumes/HD/ltmp/ssen/src/llvm/tools/clang/utils/ccc
$ rm -rf build
$ xcodebuild CC=$CCC LD=$CCC
=== BUILDING NATIVE TARGET foo WITH THE DEFAULT CONFIGURATION (Release) ===

Checking Dependencies...

CompileC build/foo.build/Release/foo.build/Objects-normal/i386/main.o /tmp/foo/main.c normal i386 c com.apple.compilers.gcc.4_0
    cd /tmp/foo
    /Volumes/HD/ltmp/ssen/src/llvm/tools/clang/utils/ccc -x c -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -mdynamic-no-pic -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -I/tmp/foo/build/foo.build/Release/foo.build/foo.hmap -F/tmp/foo/build/Release -I/tmp/foo/build/Release/include -I/tmp/foo/build/foo.build/Release/foo.build/DerivedSources -c /tmp/foo/main.c -o /tmp/foo/build/foo.build/Release/foo.build/Objects-normal/i386/main.o
clang -emit-llvm-bc -x c -o /tmp/foo/build/foo.build/Release/foo.build/Objects-normal/i386/main.o /tmp/foo/main.c -I/tmp/foo/build/foo.build/Release/foo.build/foo.hmap -F/tmp/foo/build/Release -I/tmp/foo/build/Release/include -I/tmp/foo/build/foo.build/Release/foo.build/DerivedSources

Ld /tmp/foo/build/Release/foo normal i386
    mkdir /tmp/foo/build/Release
    cd /tmp/foo
    /Volumes/HD/ltmp/ssen/src/llvm/tools/clang/utils/ccc -o /tmp/foo/build/Release/foo -L/tmp/foo/build/Release -F/tmp/foo/build/Release -filelist /tmp/foo/build/foo.build/Release/foo.build/Objects-normal/i386/foo.LinkFileList -framework CoreFoundation -arch i386 -mmacosx-version-min=10.5
llvm-ld -native -o /tmp/foo/build/Release/foo -L/tmp/foo/build/Release -F/tmp/foo/build/Release -framework CoreFoundation /tmp/foo/build/foo.build/Release/foo.build/Objects-normal/i386/main.o

GenerateDSYMFile
    cd /tmp/foo
    /Developer/usr/bin/dsymutil -o /tmp/foo/build/Release/foo.dSYM /tmp/foo/build/Release/foo
warning: no debug map in executable (-arch i386)
** BUILD SUCCEEDED **
$ ./build/Release/foo
Hello, World!
$

This patch builds on top of the following llvm/clang patches, so you will want up-to-date versions of both trees:
<http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080121/057631.html >
<http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080121/003943.html >

In addition, I added support for -save-temps in a manner similar to gcc, to aid with debugging some failures with -emit-llvm

ccc-savetemps-and-Xcode.patch (5.72 KB)

27 jan 2008 kl. 20.40 skrev Shantonu Sen:

The attached patch adds more gcc-like functionality to ccc so that it can be used as a drop-in CC/LD with Xcode/xcodebuild for building tool targets.

For example, given a "CoreFoundation Tool" target (and the default main.c that Xcode creates), you can do:

Looks great, committed.

Thanks!
Anders