Lower __builtin_flt_rounds into LLVM intrinsic
[llvm-gcc-4.2.git] / build_gcc
blob8a63787f70d273531ddd06ca5f0b60ba21bf9b68
1 #!/bin/sh
2 # APPLE LOCAL file B&I
4 set -x
6 # -arch arguments are different than configure arguments. We need to
7 # translate them.
9 TRANSLATE_ARCH="sed -e s/ppc/powerpc/ -e s/i386/i686/ -e s/ppc64/powerpc64/"
10 TRANSLATE_TARGETS="sed -e s/ppc/powerpc/ -e s/i386/i686/ -e s/x86_64// \
11 -e s/powerpc64// -e s/ppc64//"
13 # Build GCC the "Apple way".
14 # Parameters:
16 # The first parameter is a space-separated list of the architectures
17 # the compilers will run on. For instance, "ppc i386". If the
18 # current machine isn't in the list, it will (effectively) be added.
19 HOSTS=`echo $1 | $TRANSLATE_ARCH `
21 # The second parameter is a space-separated list of the architectures the
22 # compilers will generate code for. If the current machine isn't in
23 # the list, a compiler for it will get built anyway, but won't be
24 # installed.
25 TARGETS=`echo $2 | $TRANSLATE_TARGETS`
27 # The GNU makefile target ('bootstrap' by default).
28 BOOTSTRAP=${BOOTSTRAP-bootstrap}
29 if [ "$BOOTSTRAP" != bootstrap ]; then
30 bootstrap=--disable-bootstrap
33 # The B&I build srcript (~rc/bin/buildit) accepts an '-othercflags'
34 # command-line flag, and captures the argument to that flag in
35 # $RC_NONARCH_CFLAGS (and mysteriously prepends '-pipe' thereto).
36 # We will allow this to override the default $CFLAGS and $CXXFLAGS.
38 if [ "x$LLVM_DEBUG" == "x" ]; then
39 CFLAGS="-g -O2 ${RC_NONARCH_CFLAGS/-pipe/}"
40 else
41 CFLAGS="-g"
44 # This isn't a parameter; it is the architecture of the current machine.
45 BUILD=`arch | $TRANSLATE_ARCH`
47 # The third parameter is the path to the compiler sources. There should
48 # be a shell script named 'configure' in this directory. This script
49 # makes a copy...
50 ORIG_SRC_DIR="$3"
52 # The fourth parameter is the location where the compiler will be installed,
53 # normally "/usr". You can move it once it's built, so this mostly controls
54 # the layout of $DEST_DIR.
55 DEST_ROOT="$4"
57 # The fifth parameter is the place where the compiler will be copied once
58 # it's built.
59 DEST_DIR="$5"
61 # The sixth parameter is a directory in which to place information (like
62 # unstripped executables and generated source files) helpful in debugging
63 # the resulting compiler.
64 SYM_DIR="$6"
66 # LLVM LOCAL begin
67 # The seventh parameter is true/false indicating whether LLVM should be enabled
68 # or not.
69 ENABLE_LLVM="$7"
71 # The eighth parameter is a yes/no that indicates whether assertions should be
72 # enabled in the LLVM libs/tools.
73 LLVM_ASSERTIONS="$8"
75 # The nineth parameter indicates llvmCore location.
76 LLVMCORE_PATH="$9"
78 # The tenth parameter is the version number of the submission, e.g. 1007.
79 LLVM_SUBMIT_VERSION="${10}"
81 # The eleventh parameter is the subversion number of the submission, e.g. 03.
82 LLVM_SUBMIT_SUBVERSION="${11}"
84 # LLVM_BIN_DIR - This is the place where llvm-gcc/llvm-g++ symlinks get installed.
85 LLVM_BIN_DIR=/Developer/usr/bin
87 # LLVM_ARCHS - This tells us which architectures we'd like the libraries to be
88 # build for. The default is 4-way.
89 if [ "x$LLVM_ARCHS" == "x" ]; then
90 LLVM_ARCHS="ppc i386 ppc64 x86_64"
93 # LLVM LOCAL end
95 # The current working directory is where the build will happen.
96 # It may already contain a partial result of an interrupted build,
97 # in which case this script will continue where it left off.
98 DIR=`pwd`
100 # This isn't a parameter; it's the version of the compiler that we're
101 # about to build. It's included in the names of various files and
102 # directories in the installed image.
103 VERS=`cat $ORIG_SRC_DIR/gcc/BASE-VER`
104 if [ -z "$VERS" ]; then
105 exit 1
108 # This isn't a parameter either, it's the major version of the compiler
109 # to be built. It's VERS but only up to the second '.' (if there is one).
110 MAJ_VERS=`echo $VERS | sed 's/\([0-9]*\.[0-9]*\)[.-].*/\1/'`
112 # This is the libstdc++ version to use.
113 LIBSTDCXX_VERSION=4.0.0
115 DARWIN_VERS=`uname -r | sed 's/\..*//'`
116 echo DARWIN_VERS = $DARWIN_VERS
118 # If the user has CC set in their environment unset it now
119 unset CC
121 ########################################
122 # Run the build.
124 # Create the source tree we'll actually use to build, deleting
125 # tcl since it doesn't actually build properly in a cross environment
126 # and we don't really need it.
127 SRC_DIR=$DIR/src
128 rm -rf $SRC_DIR || exit 1
129 mkdir $SRC_DIR || exit 1
130 ln -s $ORIG_SRC_DIR/* $SRC_DIR/ || exit 1
131 rm -rf $SRC_DIR/tcl $SRC_DIR/expect $SRC_DIR/dejagnu || exit 1
133 # Also remove libstdc++ since it is built from a separate project.
134 rm -rf $SRC_DIR/libstdc++-v3 || exit 1
135 # Clean out old specs files
136 rm -f /usr/lib/gcc/*/4.0.0/specs
138 # These are the configure and build flags that are used.
140 if [ "x$LLVM_DEBUG" == "x" ]; then
141 CHECKING_FLAGS="--disable-checking --enable-werror"
142 else
143 CHECKING_FLAGS="--enable-checking"
146 CONFIGFLAGS="$CHECKING_FLAGS \
147 --prefix=$DEST_ROOT \
148 --mandir=\${prefix}/share/man \
149 --enable-languages=c,objc,c++,obj-c++ \
150 --program-prefix=llvm- \
151 --program-transform-name=/^[cg][^.-]*$/s/$/-$MAJ_VERS/ \
152 --with-gxx-include-dir=/usr/include/c++/$LIBSTDCXX_VERSION \
153 --with-slibdir=/usr/lib \
154 --build=$BUILD-apple-darwin$DARWIN_VERS"
156 # LLVM LOCAL begin
157 if [ "$ENABLE_LLVM" == true ]; then
158 CONFIGFLAGS="$CONFIGFLAGS --enable-llvm=/usr/local"
160 # LLVM LOCAL end
162 # Figure out how many make processes to run.
163 SYSCTL=`sysctl -n hw.activecpu`
165 # hw.activecpu only available in 10.2.6 and later
166 if [ -z "$SYSCTL" ]; then
167 SYSCTL=`sysctl -n hw.ncpu`
170 # sysctl -n hw.* does not work when invoked via B&I chroot /BuildRoot.
171 # Builders can default to 2, since even if they are single processor,
172 # nothing else is running on the machine.
173 if [ -z "$SYSCTL" ]; then
174 SYSCTL=2
177 # The $LOCAL_MAKEFLAGS variable can be used to override $MAKEFLAGS.
178 MAKEFLAGS=${LOCAL_MAKEFLAGS-"-j $SYSCTL"}
180 # LLVM LOCAL begin
181 if [ "$ENABLE_LLVM" == true ]; then
182 # Build llvm-gcc in 'dylib mode'.
183 MAKEFLAGS="$MAKEFLAGS BUILD_LLVM_INTO_A_DYLIB=1"
184 MAKEFLAGS="$MAKEFLAGS LLVM_VERSION_INFO=$LLVM_GCC_SUBMIT_VERSION"
186 # LLVM LOCAL end
188 # Build the native GCC. Do this even if the user didn't ask for it
189 # because it'll be needed for the bootstrap.
190 mkdir -p $DIR/obj-$BUILD-$BUILD $DIR/dst-$BUILD-$BUILD || exit 1
191 cd $DIR/obj-$BUILD-$BUILD || exit 1
192 if [ \! -f Makefile ]; then
193 $SRC_DIR/configure $bootstrap $CONFIGFLAGS \
194 --host=$BUILD-apple-darwin$DARWIN_VERS --target=$BUILD-apple-darwin$DARWIN_VERS || exit 1
196 # Unset RC_DEBUG_OPTIONS because it causes the bootstrap to fail.
197 # Also keep unset for cross compilers so that the cross built libraries are
198 # comparable to the native built libraries.
199 unset RC_DEBUG_OPTIONS
200 make $MAKEFLAGS CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
201 make $MAKEFLAGS html CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
202 make $MAKEFLAGS DESTDIR=$DIR/dst-$BUILD-$BUILD install-gcc install-target \
203 CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
205 # Add the compiler we just built to the path, giving it appropriate names.
206 # LLVM LOCAL Support for non /usr $DEST_ROOT
207 D=$DIR/dst-$BUILD-$BUILD$DEST_ROOT/bin
208 ln -f $D/llvm-gcc $D/gcc || exit 1
209 ln -f $D/gcc $D/$BUILD-apple-darwin$DARWIN_VERS-gcc || exit 1
210 # LLVM LOCAL Support for non /usr $DEST_ROOT
211 PATH=$DIR/dst-$BUILD-$BUILD$DEST_ROOT/bin:$PATH
213 # The cross-tools' build process expects to find certain programs
214 # under names like 'i386-apple-darwin$DARWIN_VERS-ar'; so make them.
215 # Annoyingly, ranlib changes behaviour depending on what you call it,
216 # so we have to use a shell script for indirection, grrr.
217 rm -rf $DIR/bin || exit 1
218 mkdir $DIR/bin || exit 1
219 for prog in ar nm ranlib strip lipo ld ; do
220 for t in `echo $TARGETS $HOSTS | sort -u`; do
221 P=$DIR/bin/${t}-apple-darwin$DARWIN_VERS-${prog}
222 echo '#!/bin/sh' > $P || exit 1
223 echo 'exec /usr/bin/'${prog}' "$@"' >> $P || exit 1
224 chmod a+x $P || exit 1
225 done
226 done
227 for t in `echo $1 $2 | sort -u`; do
228 gt=`echo $t | $TRANSLATE_ARCH`
229 P=$DIR/bin/${gt}-apple-darwin$DARWIN_VERS-as
230 echo '#!/bin/sh' > $P || exit 1
232 echo 'for a; do case $a in -arch) exec /usr/bin/as "$@";; esac; done' >> $P || exit 1
233 echo 'exec /usr/bin/as -arch '${t}' "$@"' >> $P || exit 1
234 chmod a+x $P || exit 1
235 done
236 PATH=$DIR/bin:$PATH
238 # Determine which cross-compilers we should build. If our build architecture is
239 # one of our hosts, add all of the targets to the list.
240 if echo $HOSTS | grep $BUILD
241 then
242 CROSS_TARGETS=`echo $TARGETS $HOSTS | tr ' ' '\n' | sort -u`
243 else
244 CROSS_TARGETS="$HOSTS"
247 # Build the cross-compilers, using the compiler we just built.
248 for t in $CROSS_TARGETS ; do
249 if [ $t != $BUILD ] ; then
250 mkdir -p $DIR/obj-$BUILD-$t $DIR/dst-$BUILD-$t || exit 1
251 cd $DIR/obj-$BUILD-$t || exit 1
252 if [ \! -f Makefile ]; then
253 $SRC_DIR/configure $CONFIGFLAGS --enable-werror-always \
254 --program-prefix=$t-apple-darwin$DARWIN_VERS- \
255 --host=$BUILD-apple-darwin$DARWIN_VERS --target=$t-apple-darwin$DARWIN_VERS || exit 1
257 make $MAKEFLAGS all CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
258 make $MAKEFLAGS DESTDIR=$DIR/dst-$BUILD-$t install-gcc install-target \
259 CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
261 # Add the compiler we just built to the path.
262 # LLVM LOCAL Support for non /usr $DEST_ROOT
263 PATH=$DIR/dst-$BUILD-$t/$DEST_ROOT/bin:$PATH
265 done
267 # Rearrange various libraries, for no really good reason.
268 for t in $CROSS_TARGETS ; do
269 DT=$DIR/dst-$BUILD-$t
270 # LLVM LOCAL begin Support for non /usr $DEST_ROOT
271 D=`echo $DT/$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS`
272 mv $D/static/libgcc.a $D/libgcc_static.a || exit 1
273 mv $D/kext/libgcc.a $D/libcc_kext.a || exit 1
274 rm -r $D/static $D/kext || exit 1
275 done
277 # Build the cross-hosted compilers.
278 for h in $HOSTS ; do
279 if [ $h != $BUILD ] ; then
280 for t in $TARGETS ; do
281 mkdir -p $DIR/obj-$h-$t $DIR/dst-$h-$t || exit 1
282 cd $DIR/obj-$h-$t || exit 1
283 if [ $h = $t ] ; then
285 else
286 pp=$t-apple-darwin$DARWIN_VERS-
289 if [ \! -f Makefile ]; then
290 $SRC_DIR/configure $CONFIGFLAGS \
291 --program-prefix=$pp \
292 --host=$h-apple-darwin$DARWIN_VERS --target=$t-apple-darwin$DARWIN_VERS || exit 1
294 if [ $h = $t ] ; then
295 make $MAKEFLAGS all CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
296 make $MAKEFLAGS DESTDIR=$DIR/dst-$h-$t install-gcc install-target \
297 CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
298 else
299 make $MAKEFLAGS all-gcc CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
300 make $MAKEFLAGS DESTDIR=$DIR/dst-$h-$t install-gcc \
301 CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
303 done
305 done
307 ########################################
308 # Construct the actual destination root, by copying stuff from
309 # $DIR/dst-* to $DEST_DIR, with occasional 'lipo' commands.
311 cd $DEST_DIR || exit 1
313 # Clean out DEST_DIR in case -noclean was passed to buildit.
314 rm -rf * || exit 1
316 # LLVM LOCAL begin - Don't install HTML docs.
317 if [ "$ENABLE_LLVM" == false ]; then
318 # HTML documentation
319 HTMLDIR="/Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.DeveloperTools.docset/Contents/Resources/Documents/documentation/DeveloperTools"
320 mkdir -p ".$HTMLDIR" || exit 1
321 cp -Rp $DIR/obj-$BUILD-$BUILD/gcc/HTML/* ".$HTMLDIR/" || exit 1
323 # LLVM LOCAL end - Don't install docs.
325 # Manual pages
326 mkdir -p .$DEST_ROOT/share || exit 1
327 cp -Rp $DIR/dst-$BUILD-$BUILD$DEST_ROOT/share/man .$DEST_ROOT/share/ \
328 || exit 1
329 # exclude fsf-funding.7 gfdl.7 gpl.7 as they are currently built in
330 # the gcc project
331 rm -rf .$DEST_ROOT/share/man/man7
333 # libexec
334 cd $DIR/dst-$BUILD-$BUILD$DEST_ROOT/libexec/gcc/$BUILD-apple-darwin$DARWIN_VERS/$VERS \
335 || exit 1
336 LIBEXEC_FILES=`find . -type f -print || exit 1`
337 LIBEXEC_DIRS=`find . -type d -print || exit 1`
338 cd $DEST_DIR || exit 1
339 for t in $TARGETS ; do
340 DL=$DEST_ROOT/libexec/gcc/$t-apple-darwin$DARWIN_VERS/$VERS
341 for d in $LIBEXEC_DIRS ; do
342 mkdir -p .$DL/$d || exit 1
343 done
344 for f in $LIBEXEC_FILES ; do
345 if file $DIR/dst-*-$t$DL/$f | grep -q 'Mach-O executable' ; then
346 lipo -output .$DL/$f -create $DIR/dst-*-$t$DL/$f || exit 1
347 else
348 cp -p $DIR/dst-$BUILD-$t$DL/$f .$DL/$f || exit 1
350 done
351 ln -s ../../../../bin/as .$DL/as
352 ln -s ../../../../bin/ld .$DL/ld
353 done
355 # bin
356 # The native drivers ('native' is different in different architectures).
357 BIN_FILES=`ls $DIR/dst-$BUILD-$BUILD$DEST_ROOT/bin | grep '^[^-]*-[0-9.]*$' \
358 | grep -v gccbug | grep -v gcov || exit 1`
359 mkdir .$DEST_ROOT/bin
360 for f in $BIN_FILES ; do
361 lipo -output .$DEST_ROOT/bin/$f -create $DIR/dst-*$DEST_ROOT/bin/$f || exit 1
362 done
363 # gcov, which is special only because it gets built multiple times and lipo
364 # will complain if we try to add two architectures into the same output.
365 TARG0=`echo $TARGETS | cut -d ' ' -f 1`
366 lipo -output .$DEST_ROOT/bin/gcov-$MAJ_VERS -create \
367 $DIR/dst-*-$TARG0$DEST_ROOT/bin/*gcov* || exit 1
368 # The fully-named drivers, which have the same target on every host.
369 for t in $TARGETS ; do
370 # APPLE LOCAL LLVM build_gcc bug with non-/usr $DEST_ROOT
371 lipo -output .$DEST_ROOT/bin/$t-apple-darwin$DARWIN_VERS-llvm-gcc-$MAJ_VERS -create \
372 $DIR/dst-*-$t/$DEST_ROOT/bin/$t-apple-darwin$DARWIN_VERS-gcc || exit 1
373 # APPLE LOCAL LLVM build_gcc bug with non-/usr $DEST_ROOT
374 lipo -output .$DEST_ROOT/bin/$t-apple-darwin$DARWIN_VERS-llvm-g++-$MAJ_VERS -create \
375 $DIR/dst-*-$t/$DEST_ROOT/bin/$t-apple-darwin$DARWIN_VERS-g++ || exit 1
376 done
378 # lib
379 mkdir -p .$DEST_ROOT/lib/gcc || exit 1
380 for t in $TARGETS ; do
381 # APPLE LOCAL LLVM build_gcc bug with non-/usr $DEST_ROOT
382 cp -Rp $DIR/dst-$BUILD-$t/$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS \
383 .$DEST_ROOT/lib/gcc || exit 1
384 done
386 # And copy libgomp stuff by hand...
387 for t in $TARGETS ; do
388 for h in $HOSTS ; do
389 if [ $h = $t ] ; then
390 cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/libgomp.a \
391 .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ || exit 1
392 cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/libgomp.spec \
393 .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ || exit 1
394 if [ $h = 'powerpc' ] ; then
395 cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/ppc64/libgomp.a \
396 .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/ || exit 1
397 cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/ppc64/libgomp.spec \
398 .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/ || exit 1
399 elif [ $h = 'i686' ] ; then
400 cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/x86_64/libgomp.a \
401 .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/x86_64/ || exit 1
402 cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/x86_64/libgomp.spec \
403 .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/x86_64/ || exit 1
406 done
407 done
409 for t in $TARGETS ; do
410 cp -p /usr/lib/libstdc++.6.dylib \
411 .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/libstdc++.dylib \
412 || exit 1
413 # LLVM LOCAL
414 # strip -x -c .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/libstdc++.dylib || exit 1
415 done
417 # include
418 HEADERPATH=$DEST_ROOT/include/gcc/darwin/$MAJ_VERS
419 mkdir -p .$HEADERPATH || exit 1
421 # Some headers are installed from more-hdrs/. They all share
422 # one common feature: they shouldn't be installed here. Sometimes,
423 # they should be part of FSF GCC and installed from there; sometimes,
424 # they should be installed by some completely different package; sometimes,
425 # they only exist for codewarrior compatibility and codewarrior should provide
426 # its own. We take care not to install the headers if Libc is already
427 # providing them.
428 cd $SRC_DIR/more-hdrs
429 for h in `echo *.h` ; do
430 if [ ! -f /usr/include/$h -o -L /usr/include/$h ] ; then
431 cp -R $h $DEST_DIR$HEADERPATH/$h || exit 1
432 for t in $TARGETS ; do
433 THEADERPATH=$DEST_DIR$DEST_ROOT/lib/gcc/${t}-apple-darwin$DARWIN_VERS/$VERS/include
434 [ -f $THEADERPATH/$h ] || \
435 ln -s ../../../../../include/gcc/darwin/$MAJ_VERS/$h $THEADERPATH/$h || \
436 exit 1
437 done
439 done
441 # Add extra man page symlinks for 'c++' and for arch-specific names.
442 MDIR=$DEST_DIR$DEST_ROOT/share/man/man1
443 ln -f $MDIR/llvm-g++.1 $MDIR/llvm-c++.1 || exit 1
444 for t in $TARGETS ; do
445 ln -f $MDIR/llvm-gcc.1 $MDIR/$t-apple-darwin$DARWIN_VERS-llvm-gcc.1 \
446 || exit 1
447 ln -f $MDIR/llvm-g++.1 $MDIR/$t-apple-darwin$DARWIN_VERS-llvm-g++.1 \
448 || exit 1
449 done
451 # Build driver-driver using fully-named drivers
452 for h in $HOSTS ; do
453 $h-apple-darwin$DARWIN_VERS-gcc \
454 $ORIG_SRC_DIR/driverdriver.c \
455 -DPDN="\"-apple-darwin$DARWIN_VERS-llvm-gcc-$MAJ_VERS\"" \
456 -DIL="\"$DEST_ROOT/bin/\"" -I $ORIG_SRC_DIR/include \
457 -I $ORIG_SRC_DIR/gcc -I $ORIG_SRC_DIR/gcc/config \
458 -liberty -L$DIR/dst-$BUILD-$h$DEST_ROOT/lib/ \
459 -L$DIR/dst-$BUILD-$h$DEST_ROOT/$h-apple-darwin$DARWIN_VERS/lib/ \
460 -L$DIR/obj-$h-$BUILD/libiberty/ \
461 -o $DEST_DIR/$DEST_ROOT/bin/tmp-$h-llvm-gcc-$MAJ_VERS || exit 1
463 $h-apple-darwin$DARWIN_VERS-gcc \
464 $ORIG_SRC_DIR/driverdriver.c \
465 -DPDN="\"-apple-darwin$DARWIN_VERS-llvm-g++-$MAJ_VERS\"" \
466 -DIL="\"$DEST_ROOT/bin/\"" -I $ORIG_SRC_DIR/include \
467 -I $ORIG_SRC_DIR/gcc -I $ORIG_SRC_DIR/gcc/config \
468 -liberty -L$DIR/dst-$BUILD-$h$DEST_ROOT/lib/ \
469 -L$DIR/dst-$BUILD-$h$DEST_ROOT/$h-apple-darwin$DARWIN_VERS/lib/ \
470 -L$DIR/obj-$h-$BUILD/libiberty/ \
471 -o $DEST_DIR/$DEST_ROOT/bin/tmp-$h-llvm-g++-$MAJ_VERS || exit 1
472 done
474 lipo -output $DEST_DIR/$DEST_ROOT/bin/llvm-gcc-$MAJ_VERS -create \
475 $DEST_DIR/$DEST_ROOT/bin/tmp-*-llvm-gcc-$MAJ_VERS || exit 1
477 lipo -output $DEST_DIR/$DEST_ROOT/bin/llvm-g++-$MAJ_VERS -create \
478 $DEST_DIR/$DEST_ROOT/bin/tmp-*-llvm-g++-$MAJ_VERS || exit 1
480 ln -f $DEST_DIR/$DEST_ROOT/bin/llvm-g++-$MAJ_VERS $DEST_DIR/$DEST_ROOT/bin/llvm-c++-$MAJ_VERS || exit 1
482 rm $DEST_DIR/$DEST_ROOT/bin/tmp-*-llvm-gcc-$MAJ_VERS || exit 1
483 rm $DEST_DIR/$DEST_ROOT/bin/tmp-*-llvm-g++-$MAJ_VERS || exit 1
485 ########################################
486 # Create SYM_DIR with information required for debugging.
488 cd $SYM_DIR || exit 1
490 # Clean out SYM_DIR in case -noclean was passed to buildit.
491 rm -rf * || exit 1
493 # Generate .dSYM files
494 find $DEST_DIR -perm -0111 \! -name fixinc.sh \
495 \! -name mkheaders -type f -print | xargs -n 1 -P ${SYSCTL} dsymutil
497 # Save .dSYM files and .a archives
498 cd $DEST_DIR || exit 1
499 find . \( -path \*.dSYM/\* -or -name \*.a \) -print \
500 | cpio -pdml $SYM_DIR || exit 1
501 # Save source files.
502 mkdir $SYM_DIR/src || exit 1
503 cd $DIR || exit 1
504 find obj-* -name \*.\[chy\] -print | cpio -pdml $SYM_DIR/src || exit 1
506 ########################################
507 # Remove debugging information from DEST_DIR.
509 find $DEST_DIR -perm -0111 \! -name \*.dylib \! -name fixinc.sh \
510 \! -name mkheaders \! -name libstdc++.dylib -type f -print \
511 | xargs strip || exit 1
512 # APPLE LOCAL begin LLVM - Strip with -Sx instead of -SX
513 find $DEST_DIR \( -name \*.a -or -name \*.dylib \) \
514 \! -name libgcc_s.10.*.dylib -type f -print \
515 | xargs strip -SX || exit 1
516 # APPLE LOCAL end LLVM - Strip with -Sx instead of -SX
517 find $DEST_DIR -name \*.a -type f -print \
518 | xargs ranlib || exit 1
520 # APPLE LOCAL begin LLVM
521 # Set up the llvm-gcc/llvm-g++ symlinks.
522 mkdir -p $DEST_DIR$LLVM_BIN_DIR
523 cd $DEST_DIR$LLVM_BIN_DIR
524 ln -s -f ../../../$DEST_ROOT/bin/llvm-gcc-$MAJ_VERS llvm-gcc-$MAJ_VERS || exit 1
525 ln -s -f ../../../$DEST_ROOT/bin/llvm-g++-$MAJ_VERS llvm-g++-$MAJ_VERS || exit 1
527 # Copy one of the libllvmgcc.dylib's up to libexec/gcc.
528 cp $DEST_DIR/$DEST_ROOT/libexec/gcc/$BUILD-apple-darwin$DARWIN_VERS/$VERS/libllvmgcc.dylib \
529 $DEST_DIR/$DEST_ROOT/libexec/gcc/
531 # Replace the installed ones with symlinks to the common one.
532 for t in $TARGETS ; do
533 cd $DEST_DIR/$DEST_ROOT/libexec/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/
534 rm libllvmgcc.dylib
535 ln -s ../../libllvmgcc.dylib
536 done
537 # APPLE LOCAL end LLVM
539 find $DEST_DIR -name \*.dSYM -print | xargs rm -r || exit 1
540 chgrp -h -R wheel $DEST_DIR
541 chgrp -R wheel $DEST_DIR
543 # Done!
544 exit 0