Home | History | Annotate | Download | only in Unit
      1 #!/usr/bin/env bash
      2 
      3 ARCHS='<host>'
      4 REMOTE=0
      5 if test `uname` = "Darwin"; then
      6   if test "$1" = "armv6"; then
      7     ARCHS="armv6"
      8     LIBS="-lSystem"
      9     REMOTE=1
     10     mkdir -p remote
     11   else
     12     ARCHS="i386 x86_64 ppc"
     13     LIBS="-lSystem"
     14   fi
     15 else
     16   LIBS="-lc -lm"
     17 fi
     18 
     19 for ARCH in $ARCHS; do
     20   CFLAGS="-Os -nodefaultlibs -I../../lib"
     21   if test "$ARCH" != '<host>'; then
     22     CFLAGS="-arch $ARCH $CFLAGS"
     23   fi
     24   for FILE in $(ls *.c); do
     25     # Use -nodefaultlibs to avoid using libgcc.a
     26     # Use -lSystem to link with libSystem.dylb.
     27     # Note -lSystem is *after* libcompiler_rt.Optimized.a so that linker will 
     28     # prefer our implementation over the ones in libSystem.dylib
     29     EXTRA=
     30     if test $FILE = gcc_personality_test.c
     31     then
     32       # the gcc_personality_test.c requires a helper C++ program
     33       EXTRA="-fexceptions gcc_personality_test_helper.cxx -lstdc++ /usr/lib/libgcc_s.1.dylib"
     34       # the libgcc_s.1.dylib use at the end is a hack until libSystem contains _Unwind_Resume
     35     fi
     36     if test $FILE = trampoline_setup_test.c
     37     then
     38       # this test requires an extra compiler option
     39       EXTRA="-fnested-functions"
     40     fi
     41     if test "$REMOTE" = "1"
     42     then 
     43       if gcc $CFLAGS $FILE ../../darwin_fat/Release/libcompiler_rt.a $LIBS $EXTRA -o ./remote/$FILE.exe
     44       then
     45         echo "Built $FILE.exe for $ARCH"
     46       else
     47         echo "$FILE failed to compile"
     48       fi
     49     else
     50       if gcc $CFLAGS $FILE ../../darwin_fat/Release/libcompiler_rt.a $LIBS $EXTRA
     51       then
     52         echo "Testing $FILE for $ARCH"
     53         if ./a.out
     54         then
     55           rm ./a.out
     56         else
     57           echo "fail"
     58           exit 1
     59         fi
     60       else
     61         echo "$FILE failed to compile"
     62         exit 1
     63       fi
     64     fi
     65   done
     66 done
     67 echo "pass"
     68 exit
     69