1  _ _ _                                                                
   2 (_) | |_   _ _ __ ___   ___  ___    ___  _ __     __ _ _ __ _ __ ___  
   3 | | | | | | | '_ ` _ \ / _ \/ __|  / _ \| '_ \   / _` | '__| '_ ` _ \ 
   4 | | | | |_| | | | | | | (_) \__ \ | (_) | | | | | (_| | |  | | | | | |
   5 |_|_|_|\__,_|_| |_| |_|\___/|___/  \___/|_| |_|  \__,_|_|  |_| |_| |_|
   6 
   7 
   8 Welcome brave fool. Don't Panic! The writer of this README is an even bigger
   9 fool than you could be (even if old Ben wonders if those who follow fools are
  10 more foolish).
  11 
  12 So here's where you get started building illumos on ARM.
  13 
  14 Step 1) You need to get a build environment set up. There's the easy way and the
  15 fun way.
  16 
  17 Easy way:
  18 
  19 cd $HOME
  20 curl -O https://fingolfin.org/illumos/arm/armtc.tar.gz
  21 pfexec tar xvzf armtc.tar.gz -C /
  22 find /opt/armtc
  23 
  24 Fun way:
  25 
  26 Using a normal i386 on i386 build:
  27 cd usr/src
  28 dmake setup
  29 cd cmd/sgs
  30 dmake install
  31 
  32 mkdir -p /opt/armtc/lib/amd64 /opt/armtc/usr/bin/amd64
  33 cd /opt/armtc/lib/
  34 ln -s amd64 64
  35 cd ../usr/bin
  36 ln -s amd64 64
  37 
  38 Then from your proto area, install the following:
  39  o /usr/bin/ld
  40  o /usr/bin/amd64/ld
  41  o /lib/libld.so.4
  42  o /lib/amd64/libld.so.4
  43  o /lib/liblddbg.so.4
  44  o /lib/amd64/liblddb.so.4
  45  o /lib/libelf.so.1
  46  o /lib/amd64/libelf.so.1
  47 
  48 Now that's all set go grab illumos-arm-extra (git clone
  49 gitosis@zelgadis.fingolfin.org:illumos-arm-extra.git) and build that. You'll
  50 need something like:
  51 
  52 gmake ARCH=arm STRAP=strap LD_ALTEXEC=/opt/armtc/usr/bin/ld install
  53 
  54 Once that's done, you'll need to fix up the rpath there. so from the root of
  55 that workspace run:
  56 
  57 ./tools/setrpath proto-arm/usr/ /opt/armtc/usr/lib:/opt/gcc/4.4.4/lib:/lib:/usr/lib
  58 
  59 Finally, you can copy all of that into your arm compiler toolchain directory
  60 (use pfexec / sudo as appropriate):
  61 
  62 cp -r proto-arm/usr /opt/armtc/
  63 
  64 Step 2) Set up illumos.sh
  65 
  66 In a fresh workspace, you're going to want to set up your illumos.sh with the
  67 following:
  68 
  69 # Enable GCC 4 default
  70 export __GNUC="";
  71 export CW_NO_SHADOW=1
  72 export MACH=arm;
  73 export NATIVE_MACH=i386;
  74 export BUILD64="#"
  75  
  76 # Re-set all this MACH-based crud
  77 REF_PROTO_LIST=$PARENT_WS/usr/src/proto_list_${MACH}; export REF_PROTO_LIST
  78 ROOT="$CODEMGR_WS/proto/root_${MACH}"; export ROOT
  79 PARENT_ROOT=$PARENT_WS/proto/root_$MACH; export PARENT_ROOT
  80 PKGARCHIVE="${CODEMGR_WS}/packages/${MACH}/nightly"; export PKGARCHIVE
  81 unset GCC_ROOT GNU_ROOT CW_GCC_DIR
  82 export i386_GCC_ROOT=/opt/gcc/4.4.4
  83 export arm_GCC_ROOT=/opt/armtc/usr
  84 export i386_GNU_ROOT=/usr/sfw
  85 export arm_GNU_ROOT=/opt/armtc/usr/gnu
  86 
  87 #
  88 # XXX our gcc isn't called ./usr/bin/gcc fix it up via CW env vars for now.
  89 #
  90 export CW_arm_GCC=/opt/armtc/usr/bin/arm-pc-solaris2.11-gcc-4.6.3
  91 
  92 #
  93 # XXX We need to set CPP to our specific cpp, not the generic /usr/ccs/lib/cpp
  94 # as that's rather, well, x86.
  95 #
  96 export CPP=/opt/armtc/usr/lib/cpp
  97 export AW_CPP=/opt/armtc/usr/lib/cpp
  98 export LD_ALTEXEC=/opt/armtc/usr/bin/ld
  99 
 100 Step 3) Start your build engines
 101 
 102 Once you've done that, you're doing to need to need to use the *new* bldenv to
 103 get started building. For the first time you can go ahead and do something like: 
 104 
 105 cd usr/src
 106 ksh93 ./tools/scripts/bldenv.sh ../../illumos.sh
 107 
 108 This is really just a bit of a bootstrapping weirdness. Once that's done you can
 109 go ahead and continue on.
 110 
 111 As a part of this you should see an important two lines:
 112 
 113 Cross-building enabled
 114 Targeting arm on i386
 115 
 116 If you don't, stop. illumos.sh is not configured correctly.
 117 
 118 
 119 Once you have that you can get going. Start off with a resounding:
 120 
 121 dmake setup
 122 
 123 Following this, you can build the kernel as far as we have it for ARM
 124 
 125 cd uts; dmake install
 126 
 127 You now have a lovely unix and boot_archive pair in bcm2835/unix (raspberry
 128 pi) and qvpb/unix (qemu versatilepb).  These should be booted with a kernel
 129 command line mimicing that of the boot_archive (regardless of the path of the
 130 unix you actually provide).  For example: kernel /platform/bcm2835/kernel/unix
 131 -Bconsole=text
 132