Testing LLVM 3.0 on Ubuntu 11.10 ARM

LLVM 3.0 was released some time ago and I’ve thought it’ll be good to give it a try on stock Ubuntu 11.10 ARM. That means I’ve tested LLVM 3.0 with Ubuntu provided GNU C++ 4.6.1 and Clang 2.9. GNU C++ configuration looks:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabi/4.6.1/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-float=softfp --with-fpu=vfpv3-d16 --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) 

I’ve compiled LLVM 3.0 by those two compilers with default configuration and then with optimization flags set to -O0, -O1, -O2 and -O3. The table below lists sum of unexpected failures and unexpected passes with appropriate links to the tests output files. What’s surprising to me is that Clang on ARM even in version 2.9 performs so well. I know, Clang depends on LLVM and LLVM by default checks for Clang as a preferred compiler and both projects are mainly developed by Apple’s engineers, but still this is on native ARM/Linux system, so nothing like cross-compilation from MacOSX/x64 to iOS/ARM!

-O0 -O1 -O2 -O3 default
GCC 4.6.1 6 6 51 51 51
Clang 2.9 1147 8 12 12 12

So as you can see GCC still wins on the lowest number of failures while using -O0/-O1, but Clang performs very well on -O2/-O3/default optimization levels. Please note that the excess number of failures on -O0 with Clang is probably caused by the fact that LLVM code requires some optimization to be performed on it to behaves correctly and it looks like Clang does not perform such optimization while GCC does when compiling with -O0.
Also what’s kind of surprise to me is to see Clang compilation performance. I’ve not marked hard numbers since this was not the task for this testing, but I’ve been surprised to see what GCC took around 700 minutes, Clang did in about 400 minutes. I’m talking about default compilation on i.MX53 Quick Start Board here.

Now the questions are: how Clang compiled LLVM affects GHC tests and GHC compilation speed? (i.e. I may use -O3 compiled LLVM for this). Also how would the numbers look like while testing latest greatest Linaro GCC and Clang 3.0? Perhaps material for another post or two…

Advertisements

GHC 7.4.1 Release Candidate 1 is out!

If you have not noticed yet, then please note that GHC 7.4.1 Release Candidate 1 is out. Please also note that 7.4.1 will be the first public release which will support registerised compilation on ARM/Linux platform. If you are a haskell fan and do have some ARM/Linux platform available, please do not forget to give it a try.
What’s basically needed is to have some recent Ubuntu installed together with its provided GNU C++ and GHC compilers. If you do have this, then just grab the LLVM 3.0 source code and unpack it somewhere and run following inside its directory:

$ ./configure
$ make ENABLE_OPTIMIZED=1 OPTIMIZE_OPTION=-O1

when it finishes successfully (it really should), then inside the Release/bin subdirectory you do have LLVM binaries. Extend your PATH variable:

$ export PATH=$PATH:`pwd`/Release/bin

and then move somewhere and download ghc-7.4.0.20111219-src.tar.bz2 which is 7.4.1 RC1 distribution tarball. Unpack it somewhere go into its directory (ghc-7.4.0.20111219) and run:

$ ./configure
$ make

Here the compilation should fail with error like:

"inplace/bin/ghc-stage2"   -H32m -O    -package-name dph-prim-par-0.5.2.0 -hide-all-packages -i -ilibraries/dph/dph-prim-par/. -ilibraries/dph/dph-prim-par/dist-install/build -ilibraries/dph/dph-prim-par/dist-install/build/autogen -Ilibraries/dph/dph-prim-par/dist-install/build -Ilibraries/dph/dph-prim-par/dist-install/build/autogen -Ilibraries/dph/dph-prim-par/.    -optP-include -optPlibraries/dph/dph-prim-par/dist-install/build/autogen/cabal_macros.h -package base-4.5.0.0 -package dph-base-0.5.2.0 -package dph-prim-interface-0.5.2.0 -package dph-prim-seq-0.5.2.0 -package old-time-1.1.0.0 -package random-1.0.1.1 -package vector-0.9.1  -Odph -funbox-strict-fields -fcpr-off -Werror -XHaskell98 -XTypeFamilies -XGADTs -XRankNTypes -XBangPatterns -XMagicHash -XUnboxedTuples -XTypeOperators -XFlexibleInstances -XFlexibleContexts -O2  -no-user-package-conf -rtsopts     -odir libraries/dph/dph-prim-par/dist-install/build -hidir libraries/dph/dph-prim-par/dist-install/build -stubdir libraries/dph/dph-prim-par/dist-install/build -hisuf hi -osuf  o -hcsuf hc -c libraries/dph/dph-prim-par/./Data/Array/Parallel/Unlifted/Distributed/Types/Unit.hs -o libraries/dph/dph-prim-par/dist-install/build/Data/Array/Parallel/Unlifted/Distributed/Types/Unit.o
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.4.0.20111219 for arm-unknown-linux):
        Cant do annotations without GHCi
    {libraries/vector/Data/Vector/Fusion/Stream/Monadic.hs:104:19-33}
    base:GHC.Exts.ForceSpecConstr{d rbL}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

make[1]: *** [libraries/vector/dist-install/build/Data/Vector/Fusion/Stream/Monadic.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

This is expected result caused by the fact that GHC does not support GHCi on ARM yet. We are working on it be assured. Anyway, ghc-stage2 compiler should work for you quite well:

$ ./inplace/bin/ghc-stage2 --info
 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts"," -fwrapv")
 ,("C compiler command","/export/home/karel/arm-sfw/gcc-linaro-2011.12-0/bin/gcc")
 ,("C compiler flags"," -fno-stack-protector  -Wl,--hash-size=31 -Wl,--reduce-memory-overheads")
 ,("ar command","/usr/bin/ar")
 ,("ar flags","q")
 ,("ar supports at file","YES")
 ,("touch command","touch")
 ,("dllwrap command","/bin/false")
 ,("windres command","/bin/false")
 ,("perl command","/usr/bin/perl")
 ,("target os","OSLinux")
 ,("target arch","ArchARM {armISA = ARMv7, armISAExt = [VFPv3,NEON]}")
 ,("target has GNU nonexec stack","False")
 ,("target has subsections via symbols","False")
 ,("Project version","7.4.0.20111219")
 ,("Booter version","6.12.3")
 ,("Stage","2")
 ,("Build platform","arm-unknown-linux")
 ,("Host platform","arm-unknown-linux")
 ,("Target platform","arm-unknown-linux")
 ,("Have interpreter","NO")
 ,("Object splitting supported","NO")
 ,("Have native code generator","NO")
 ,("Support SMP","YES")
 ,("Unregisterised","NO")
 ,("Tables next to code","YES")
 ,("RTS ways","l debug  thr thr_debug thr_l  ")
 ,("Leading underscore","NO")
 ,("Debug on","False")
 ,("LibDir","/export/home/karel/src/ghc-7.4.0.20111219/inplace/lib")
 ,("Global Package DB","/export/home/karel/src/ghc-7.4.0.20111219/inplace/lib/package.conf.d")
 ,("Gcc Linker flags","[\"-Wl,--hash-size=31\",\"-Wl,--reduce-memory-overheads\"]")
 ,("Ld Linker flags","[\"--hash-size=31\",\"--reduce-memory-overheads\"]")
 ]

If you would like to run full GHC testsuite with this, then you will need to grab it from ghc-7.4 branch. For this please have a look at GHC page expaining details how to get source code here. Once you do have ghc-7.4 branch including testsuite checked out, just copy testsuite subdirectory to ghc-7.4.0.20111219 directory and then run:

$ cd testsuite
$ make TIMEOUT=1500 WAY="normal threaded1 threaded2"

This will take some time, but at the end you should get overall summary of testing. In my case it looked:

OVERALL SUMMARY for test run started at Fri Dec 23 20:15:32 CET 2011
    3158 total tests, which gave rise to
    6816 test cases, of which
       0 caused framework failures
    2731 were skipped

    3880 expected passes
     135 expected failures
       1 unexpected passes
      69 unexpected failures

Unexpected passes:
   quasiquotation  T5204 (normal)

Unexpected failures:
   ../../libraries/random/tests  rangeTest [bad exit code] (normal,threaded1,threaded2)
   annotations/should_run        annrun01 [exit code non-0] (normal,threaded1,threaded2)
   cabal                         ghcpkg05 [bad stderr] (normal)
   cabal/cabal04                 cabal04 [bad exit code] (normal)
   codeGen/should_compile        jmp_tbl [exit code non-0] (normal)
   codeGen/should_compile        massive_array [exit code non-0] (normal)
   dph/classes                   dph-classes-fast [exit code non-0] (normal,threaded1,threaded2)
   dph/dotp                      dph-dotp-fast [exit code non-0] (normal,threaded1,threaded2)
   dph/dotp                      dph-dotp-opt [exit code non-0] (normal,threaded1,threaded2)
   dph/primespj                  dph-primespj-fast [exit code non-0] (normal,threaded1,threaded2)
   dph/primespj                  dph-primespj-opt [exit code non-0] (normal,threaded1,threaded2)
   dph/quickhull                 dph-quickhull-fast [exit code non-0] (normal,threaded1,threaded2)
   dph/quickhull                 dph-quickhull-opt [exit code non-0] (normal,threaded1,threaded2)
   dph/sumnats                   dph-sumnats [exit code non-0] (normal,threaded1,threaded2)
   dph/words                     dph-words-fast [exit code non-0] (normal)
   dph/words                     dph-words-opt [exit code non-0] (normal)
   driver                        5313 [exit code non-0] (normal,threaded1,threaded2)
   driver/recomp009              recomp009 [bad exit code] (normal)
   ghc-api/T4891                 T4891 [bad exit code] (normal)
   ghc-api/apirecomp001          apirecomp001 [bad exit code] (normal)
   ghc-api/dynCompileExpr        dynCompileExpr [exit code non-0] (normal,threaded1,threaded2)
   ghci/linking                  ghcilink001 [bad exit code] (normal)
   ghci/linking                  ghcilink002 [bad exit code] (normal)
   ghci/linking                  ghcilink003 [bad exit code] (normal)
   ghci/linking                  ghcilink004 [bad exit code] (normal)
   ghci/linking                  ghcilink005 [bad exit code] (normal)
   ghci/linking                  ghcilink006 [bad exit code] (normal)
   ghci/scripts                  ghci024 [bad exit code] (normal)
   perf/compiler                 T1969 [stat not good enough] (normal)
   perf/compiler                 T3064 [stat not good enough] (normal)
   perf/compiler                 T4801 [stat not good enough] (normal)
   perf/compiler                 T5030 [stat not good enough] (normal)
   perf/compiler                 T5631 [stat not good enough] (normal)
   quasiquotation/qq007          qq007 [exit code non-0] (normal)
   quasiquotation/qq008          qq008 [exit code non-0] (normal)
   rts                           T2615 [exit code non-0] (normal,threaded1,threaded2)
   rts                           derefnull [bad exit code] (threaded2)
   rts                           testblockalloc [bad exit code] (normal,threaded1)
   safeHaskell/flags             Flags02 [exit code non-0] (normal)
   safeHaskell/safeLanguage      SafeLang01 [stderr mismatch] (normal)
   safeHaskell/safeLanguage      SafeLang12 [stderr mismatch] (normal)
   safeHaskell/safeLanguage      SafeLang16 [stderr mismatch] (normal)

Welcome back Freescale i.MX53

Few months ago I’ve been contacted by Marsha Chang from Freescale i.MX53 marketing division if I’d like to have another i.MX53 Quick Start Board as a replacement for the board I needed to return back to Freescale during this summer.
Having more ARM boards never hurts, so I replied “yes” quickly and today another i.MX53 is already siting on my SMC switch with preinstalled Ubuntu 11.10. The only quirk so far I’ve had with Ubuntu, which looks like switched to NFSv4 and this all goes kind of wrong with my Solaris 11 ZFS/NFS id mapping. Since both machines are well secured and basically just available to me alone, I’ve given up on increased NFSv4 security and decided to use quickest and least hurting path and enforce usage of NFSv3 on Ubuntu side about which I know is running well. At least it does so in Ubuntu 11.04 running on my Pandaboard. The trick is to put vers=3 into appropriate option column in /etc/fstab file:

solaris:/export/home/karel /export/home/karel nfs vers=3 0 0

Otherwise everything is working as expected and the board is already crunching through LLVM 3.0 compilation and testing, but that’s the topic for next post anyway.