[llvm-commits] [llvm-gcc-4.2] r54387 - /llvm-gcc-4.2/trunk/build_gcc
Bill Wendling
isanbard at gmail.com
Tue Aug 5 16:53:16 PDT 2008
Author: void
Date: Tue Aug 5 18:53:16 2008
New Revision: 54387
URL: http://llvm.org/viewvc/llvm-project?rev=54387&view=rev
Log:
Merge over support for building ARM.
Modified:
llvm-gcc-4.2/trunk/build_gcc
Modified: llvm-gcc-4.2/trunk/build_gcc
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/build_gcc?rev=54387&r1=54386&r2=54387&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/build_gcc (original)
+++ llvm-gcc-4.2/trunk/build_gcc Tue Aug 5 18:53:16 2008
@@ -6,9 +6,7 @@
# -arch arguments are different than configure arguments. We need to
# translate them.
-TRANSLATE_ARCH="sed -e s/ppc/powerpc/ -e s/i386/i686/ -e s/ppc64/powerpc64/"
-TRANSLATE_TARGETS="sed -e s/ppc/powerpc/ -e s/i386/i686/ -e s/x86_64// \
- -e s/powerpc64// -e s/ppc64//"
+TRANSLATE_ARCH="sed -e s/ppc/powerpc/ -e s/i386/i686/ -e s/armv6/arm/"
OMIT_X86_64="sed -e s/x86_64//"
# Build GCC the "Apple way".
@@ -23,7 +21,7 @@
# compilers will generate code for. If the current machine isn't in
# the list, a compiler for it will get built anyway, but won't be
# installed.
-TARGETS=`echo $2 | $TRANSLATE_TARGETS | $OMIT_X86_64`
+TARGETS=`echo $2 | $TRANSLATE_ARCH | $OMIT_X86_64`
# The GNU makefile target ('bootstrap' by default).
BOOTSTRAP=${BOOTSTRAP-bootstrap}
@@ -36,11 +34,13 @@
# $RC_NONARCH_CFLAGS (and mysteriously prepends '-pipe' thereto).
# We will allow this to override the default $CFLAGS and $CXXFLAGS.
+# LLVM LOCAL begin
if [ "x$LLVM_DEBUG" == "x" ]; then
CFLAGS="-g -O2 ${RC_NONARCH_CFLAGS/-pipe/}"
else
CFLAGS="-g"
fi
+# LLVM LOCAL end
# This isn't a parameter; it is the architecture of the current machine.
BUILD=`arch | $TRANSLATE_ARCH`
@@ -104,13 +104,24 @@
# to be built. It's VERS but only up to the second '.' (if there is one).
MAJ_VERS=`echo $VERS | sed 's/\([0-9]*\.[0-9]*\)[.-].*/\1/'`
+# APPLE LOCAL begin ARM ARM_CONFIGFLAGS
+# For ARM, grab all system files from an SDK.
+ARM_SYSROOT="/Developer/SDKs/Extra"
+ARM_LIBSTDCXX_VERSION=4.2.1
+ARM_CONFIGFLAGS="--with-sysroot=\"$ARM_SYSROOT\" \
+ --with-gxx-include-dir=\${prefix}/include/c++/$ARM_LIBSTDCXX_VERSION"
+# APPLE LOCAL end ARM ARM_CONFIGFLAGS
+
# This is the libstdc++ version to use.
LIBSTDCXX_VERSION=4.2.1
+# LLVM LOCAL begin
# DO NOT USE $DEST_ROOT to check LIBSTDCXX_VERSION here. Directly use /usr here.
# $DEST_ROOT is /Developer for llvm-gcc
if [ ! -d "/usr/include/c++/$LIBSTDCXX_VERSION" ]; then
LIBSTDCXX_VERSION=4.0.0
fi
+# LLVM LOCAL end
+NON_ARM_CONFIGFLAGS="--with-gxx-include-dir=\${prefix}/include/c++/$LIBSTDCXX_VERSION"
DARWIN_VERS=`uname -r | sed 's/\..*//'`
echo DARWIN_VERS = $DARWIN_VERS
@@ -129,14 +140,14 @@
mkdir $SRC_DIR || exit 1
ln -s $ORIG_SRC_DIR/* $SRC_DIR/ || exit 1
rm -rf $SRC_DIR/tcl $SRC_DIR/expect $SRC_DIR/dejagnu || exit 1
-
# Also remove libstdc++ since it is built from a separate project.
+# LLVM LOCAL
rm -rf $SRC_DIR/libstdc++-v3 || exit 1
# Clean out old specs files
rm -f /usr/lib/gcc/*/4.0.0/specs
# These are the configure and build flags that are used.
-
+# LLVM LOCAL begin
if [ "x$LLVM_DEBUG" == "x" ]; then
CHECKING_FLAGS="--disable-checking --enable-werror"
else
@@ -153,7 +164,6 @@
--with-slibdir=/usr/lib \
--build=$BUILD-apple-darwin$DARWIN_VERS"
-# LLVM LOCAL begin
if [ "$ENABLE_LLVM" == true ]; then
CONFIGFLAGS="$CONFIGFLAGS --enable-llvm=$LLVMCORE_PATH"
fi
@@ -191,6 +201,7 @@
cd $DIR/obj-$BUILD-$BUILD || exit 1
if [ \! -f Makefile ]; then
$SRC_DIR/configure $bootstrap $CONFIGFLAGS \
+ $NON_ARM_CONFIGFLAGS \
--host=$BUILD-apple-darwin$DARWIN_VERS --target=$BUILD-apple-darwin$DARWIN_VERS || exit 1
fi
# Unset RC_DEBUG_OPTIONS because it causes the bootstrap to fail.
@@ -203,12 +214,12 @@
CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
# Add the compiler we just built to the path, giving it appropriate names.
-# LLVM LOCAL Support for non /usr $DEST_ROOT
+# LLVM LOCAL begin Support for non /usr $DEST_ROOT
D=$DIR/dst-$BUILD-$BUILD$DEST_ROOT/bin
ln -f $D/llvm-gcc $D/gcc || exit 1
ln -f $D/gcc $D/$BUILD-apple-darwin$DARWIN_VERS-gcc || exit 1
-# LLVM LOCAL Support for non /usr $DEST_ROOT
PATH=$DIR/dst-$BUILD-$BUILD$DEST_ROOT/bin:$PATH
+# LLVM LOCAL end Support for non /usr $DEST_ROOT
# The cross-tools' build process expects to find certain programs
# under names like 'i386-apple-darwin$DARWIN_VERS-ar'; so make them.
@@ -250,16 +261,19 @@
mkdir -p $DIR/obj-$BUILD-$t $DIR/dst-$BUILD-$t || exit 1
cd $DIR/obj-$BUILD-$t || exit 1
if [ \! -f Makefile ]; then
+ # APPLE LOCAL begin ARM ARM_CONFIGFLAGS
$SRC_DIR/configure $CONFIGFLAGS --enable-werror-always \
+ `if [ $t = 'arm' ] ; then echo $ARM_CONFIGFLAGS ; else echo $NON_ARM_CONFIGFLAGS ; fi` \
--program-prefix=$t-apple-darwin$DARWIN_VERS- \
--host=$BUILD-apple-darwin$DARWIN_VERS --target=$t-apple-darwin$DARWIN_VERS || exit 1
+ # APPLE LOCAL end ARM ARM_CONFIGFLAGS
fi
make $MAKEFLAGS all CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
make $MAKEFLAGS DESTDIR=$DIR/dst-$BUILD-$t install-gcc install-target \
CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
# Add the compiler we just built to the path.
- # LLVM LOCAL Support for non /usr $DEST_ROOT
+ # LLVM LOCAL Support for non /usr $DEST_ROOT
PATH=$DIR/dst-$BUILD-$t/$DEST_ROOT/bin:$PATH
fi
done
@@ -267,7 +281,7 @@
# Rearrange various libraries, for no really good reason.
for t in $CROSS_TARGETS ; do
DT=$DIR/dst-$BUILD-$t
- # LLVM LOCAL begin Support for non /usr $DEST_ROOT
+ # LLVM LOCAL Support for non /usr $DEST_ROOT
D=`echo $DT/$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS`
mv $D/static/libgcc.a $D/libgcc_static.a || exit 1
mv $D/kext/libgcc.a $D/libcc_kext.a || exit 1
@@ -293,9 +307,12 @@
fi
if [ \! -f Makefile ]; then
+ # APPLE LOCAL begin ARM ARM_CONFIGFLAGS
$SRC_DIR/configure $CONFIGFLAGS \
+ `if [ $t = 'arm' ] && [ $h != 'arm' ] ; then echo $ARM_CONFIGFLAGS ; else echo $NON_ARM_CONFIGFLAGS ; fi` \
--program-prefix=$pp \
--host=$h-apple-darwin$DARWIN_VERS --target=$t-apple-darwin$DARWIN_VERS || exit 1
+ # APPLE LOCAL end ARM ARM_CONFIGFLAGS
fi
if [ $h = $t ] ; then
make $MAKEFLAGS all CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
@@ -319,14 +336,14 @@
# Clean out DEST_DIR in case -noclean was passed to buildit.
rm -rf * || exit 1
-# LLVM LOCAL begin - Don't install HTML docs.
+# LLVM LOCAL begin Don't install HTML docs.
if [ "$ENABLE_LLVM" == false ]; then
# HTML documentation
HTMLDIR="/Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.DeveloperTools.docset/Contents/Resources/Documents/documentation/DeveloperTools"
mkdir -p ".$HTMLDIR" || exit 1
cp -Rp $DIR/obj-$BUILD-$BUILD/gcc/HTML/* ".$HTMLDIR/" || exit 1
fi
-# LLVM LOCAL end - Don't install docs.
+# LLVM LOCAL end Don't install docs.
# Manual pages
mkdir -p .$DEST_ROOT/share || exit 1
@@ -348,22 +365,26 @@
mkdir -p .$DL/$d || exit 1
done
for f in $LIBEXEC_FILES ; do
+ # LLVM LOCAL
if file $DIR/dst-*-$t$DL/$f | grep -q -E 'Mach-O (executable|dynamically linked shared library)' ; then
lipo -output .$DL/$f -create $DIR/dst-*-$t$DL/$f || exit 1
else
cp -p $DIR/dst-$BUILD-$t$DL/$f .$DL/$f || exit 1
fi
done
- # LLVM LOCAL fix broken link
+ # LLVM LOCAL begin fix broken link
ln -s ../../../../../bin/as .$DL/as
ln -s ../../../../../bin/ld .$DL/ld
+ # LLVM LOCAL end fix broken link
done
# bin
# The native drivers ('native' is different in different architectures).
+# LLVM LOCAL begin
mkdir .$DEST_ROOT/bin
cpp_files=`ls $DIR/dst-*$DEST_ROOT/bin/{llvm-cpp,cpp-$MAJ_VERS} 2>/dev/null`
lipo -output .$DEST_ROOT/bin/llvm-cpp-$MAJ_VERS -create $cpp_files || exit 1
+# LLVM LOCAL end
# gcov, which is special only because it gets built multiple times and lipo
# will complain if we try to add two architectures into the same output.
@@ -383,14 +404,19 @@
# lib
mkdir -p .$DEST_ROOT/lib/gcc || exit 1
for t in $TARGETS ; do
-# APPLE LOCAL LLVM build_gcc bug with non-/usr $DEST_ROOT
+ # LLVM LOCAL build_gcc bug with non-/usr $DEST_ROOT
cp -Rp $DIR/dst-$BUILD-$t/$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS \
.$DEST_ROOT/lib/gcc || exit 1
done
+# APPLE LOCAL begin native compiler support
+# libgomp is not built for ARM
+LIBGOMP_TARGETS=`echo $TARGETS | sed -E -e 's/(^|[[:space:]])arm($|[[:space:]])/ /'`
+LIBGOMP_HOSTS=`echo $HOSTS | $OMIT_X86_64 | sed -E -e 's/(^|[[:space:]])arm($|[[:space:]])/ /'`
+
# And copy libgomp stuff by hand...
-for t in $TARGETS ; do
- for h in $HOSTS ; do
+for t in $LIBGOMP_TARGETS ; do
+ for h in $LIBGOMP_HOSTS ; do
if [ $h = $t ] ; then
cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/libgomp.a \
.$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ || exit 1
@@ -398,9 +424,9 @@
.$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ || exit 1
if [ $h = 'powerpc' ] ; then
cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/ppc64/libgomp.a \
- .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/
+ .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/ || exit 1
cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/ppc64/libgomp.spec \
- .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/
+ .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/ || exit 1
elif [ $h = 'i686' ] ; then
cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/x86_64/libgomp.a \
.$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/x86_64/ || exit 1
@@ -410,12 +436,18 @@
fi
done
done
+# APPLE LOCAL end native compiler support
-# FIXME: What is the motivation here ?
for t in $TARGETS ; do
- cp -p /usr/lib/libstdc++.6.dylib \
- .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/libstdc++.dylib \
- || exit 1
+ if [ "$t" == 'arm' ] ; then
+ cp -p $ARM_SYSROOT/usr/lib/libstdc++.6.dylib \
+ .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/libstdc++.dylib \
+ || exit 1
+ else
+ cp -p /usr/lib/libstdc++.6.dylib \
+ .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/libstdc++.dylib \
+ || exit 1
+ fi
# LLVM LOCAL
# strip -x -c .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/libstdc++.dylib || exit 1
done
@@ -446,16 +478,20 @@
# Add extra man page symlinks for 'c++' and for arch-specific names.
MDIR=$DEST_DIR$DEST_ROOT/share/man/man1
+# LLVM LOCAL
ln -f $MDIR/llvm-g++.1 $MDIR/llvm-c++.1 || exit 1
for t in $TARGETS ; do
+ # LLVM LOCAL begin
ln -f $MDIR/llvm-gcc.1 $MDIR/$t-apple-darwin$DARWIN_VERS-llvm-gcc.1 \
|| exit 1
ln -f $MDIR/llvm-g++.1 $MDIR/$t-apple-darwin$DARWIN_VERS-llvm-g++.1 \
|| exit 1
+ # LLVM LOCAL end
done
# Build driver-driver using fully-named drivers
for h in $HOSTS ; do
+ # LLVM LOCAL begin
$h-apple-darwin$DARWIN_VERS-gcc \
$ORIG_SRC_DIR/driverdriver.c \
-DPDN="\"-apple-darwin$DARWIN_VERS-llvm-gcc-$MAJ_VERS\"" \
@@ -475,8 +511,10 @@
-L$DIR/dst-$BUILD-$h$DEST_ROOT/$h-apple-darwin$DARWIN_VERS/lib/ \
-L$DIR/obj-$h-$BUILD/libiberty/ \
-o $DEST_DIR/$DEST_ROOT/bin/tmp-$h-llvm-g++-$MAJ_VERS || exit 1
+ # LLVM LOCAL end
done
+# LLVM LOCAL begin
lipo -output $DEST_DIR/$DEST_ROOT/bin/llvm-gcc-$MAJ_VERS -create \
$DEST_DIR/$DEST_ROOT/bin/tmp-*-llvm-gcc-$MAJ_VERS || exit 1
@@ -487,6 +525,7 @@
rm $DEST_DIR/$DEST_ROOT/bin/tmp-*-llvm-gcc-$MAJ_VERS || exit 1
rm $DEST_DIR/$DEST_ROOT/bin/tmp-*-llvm-g++-$MAJ_VERS || exit 1
+# LLVM LOCAL end
########################################
# Create SYM_DIR with information required for debugging.
@@ -525,7 +564,7 @@
| xargs ranlib || exit 1
fi
-# APPLE LOCAL begin LLVM
+# LLVM LOCAL begin
# Set up the llvm-gcc/llvm-g++ symlinks.
mkdir -p $DEST_DIR$LLVM_BIN_DIR
cd $DEST_DIR$LLVM_BIN_DIR
@@ -551,7 +590,7 @@
rm libllvmgcc.dylib
ln -s ../../libllvmgcc.dylib
done
-# APPLE LOCAL end LLVM
+# LLVM LOCAL end
find $DEST_DIR -name \*.dSYM -print | xargs rm -r || exit 1
chgrp -h -R wheel $DEST_DIR
More information about the llvm-commits
mailing list