[cfe-dev] ccc with Xcode tool targets
Shantonu Sen
ssen at apple.com
Sun Jan 27 20:40:20 PST 2008
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
> $ mkdir -p obj
> $ echo "int main() {}" > a.c
> $ ccc -o obj/a a.c -save-temps
> clang -E -x c -o a.i a.c
> clang -emit-llvm-bc -x c-cpp-output -o a.o a.i
> llvm-ld -native -o obj/a a.o
> $ ls -l a* obj/*
> -rw-r--r-- 1 shantonu wheel 14 Jan 27 20:29 a.c
> -rw-r--r-- 1 shantonu wheel 69 Jan 27 20:29 a.i
> -rw-r--r-- 1 shantonu wheel 412 Jan 27 20:29 a.o
> -rwxr-xr-x 1 shantonu wheel 12564 Jan 27 20:29 obj/a*
> -rwxr-xr-x 1 shantonu wheel 428 Jan 27 20:29 obj/a.bc*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ccc-savetemps-and-Xcode.patch
Type: application/octet-stream
Size: 5855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080127/6ce4cec5/attachment.obj>
-------------- next part --------------
Shantonu Sen
Apple Inc.
More information about the cfe-dev
mailing list