Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 129 lines (94 sloc) 4.192 kb
e05ef9bf » richlowe
2011-06-16 GCC-README: Add a description of the GCC4 work
1
2 # Illumos GCC 4
3
4 ## Intro
5
6 This is a work in progress that may or may not work (or work well) at any
7 given time. If you encounter problems you think are likely my fault, send me
8 email describing them in detail.
9
10 This has booted to login and done fairly basic work on 32bit and 64bit x86 in
11 qemu, VirtualBox (32bit), and a random whitebox Athlon 64. And on a Sun-Fire
12 V250 on sun4u. It has been tried nowhere else.
13
14 ## What you need
15
16 ### Patched GCC 4.4.4
17
18 This is the GCC available at http://github.com/richlowe/gcc on the il-4_4_4
19 branch. It is patched in numerous ways, a stock GCC will most certainly not
20 work.
21
22 I've made binary tarballs available, they assume a `--prefix` of
23 `/opt/gcc/4.4.4` (unpack them from `/opt`)
24
25 i386: http://richlowe.openindiana.org/~richlowe/il-gcc-444-i386.tar.bz2
26 sparc: http://richlowe.openindiana.org/~richlowe/il-gcc-444-sparc.tar.bz2
27
28 ### Further patch GCC
29
30 Unfortunately, we need to bake appropriate runpaths for libstdc++ and libgcc_s
31 into the GCC spec, at least at present, so you need to further patch GCC to
32 reflect the location in which you're going to install it.
33
34 Choose a prefix in which to install GCC (the one you'll give to `configure
35 --prefix`), I'm using /opt/gcc/4.4.4.
36
37 Now, look at revision a1583073 (`git show a1583073`). In every place that
38 changeset added a /usr/sfw/lib path, adding a matching path based on your
39 prefix _before_ the SFW path (you need your libcc_s to be found first).
40
41 I'm hoping to find a way to avoid doing this, but at present haven't come up
42 with one that works in every case.
43
44 ### Build GCC
45
46 I've been using a script to make this easier on myself
47
48 ```bash
49 #!/bin/ksh -e
50 VER=$1
51
52 if [[ -z $VER ]]; then
53 print -u2 "Usage: build.sh <Version>"
54 exit 2
55 fi
56
57 export PATH="/opt/dejagnu/bin:/opt/SUNWspro/bin:"
58 PATH="$PATH:/usr/gnu/bin:/usr/sfw/bin"
59 PATH="$PATH:/usr/bin:/usr/ccs/bin"
60
61 export CC=/usr/sfw/bin/gcc
62 export CFLAGS="-g -O2"
63
64 AS_OPTIONS=""
65 if [[ $(mach) == "sparc" ]]; then
66 CFLAGS="$CFLAGS -fkeep-inline-functions"
67 AS_OPTIONS="--without-gnu-as --with-as=/usr/ccs/bin/as"
68 else
69 AS_OPTIONS="--with-gnu-as --with-as=/usr/sfw/bin/as"
70 fi
71
72 export STAGE1_CFLAGS=$CFLAGS
73 export CFLAGS_FOR_TARGET=$CFLAGS
74
75 GMSGFMT=/usr/gnu/bin/msgfmt \
76 ../../configure --prefix=/opt/gcc/$VER $AS_OPTIONS \
77 --with-ld=/usr/bin/ld \
78 --without-gnu-ld \
79 --enable-languages="c,c++,objc" \
80 --enable-shared \
81 --with-mpfr-include=/usr/include/mpfr \
82 --with-gmp-include=/usr/include/gmp
83
84 gmake -j8 CFLAGS="$CFLAGS" STAGE1_CFLAGS="$CFLAGS" \
85 CFLAGS_FOR_TARGET="$CFLAGS" bootstrap
86 ```
87
88 Then:
89
90 ```bash
91 mkdir -p builds/il-444 && cd builds/il-444
92 ../../build.sh 4.4.4
93 ```
94
95 If you wish to run the tests, you'll need to install expect, then build and
96 install dejagnu and run 'gmake check-gcc'. It's most useful to compare the
97 test results of an unpatched build and a patch build at the same GCC revision
98 (the gcc-4.4.4 tag, v. the il-4_4_4 branch for instance).
99
100 ## Build Illumos
101
102 As part of this, I've (at least temporarily) adjusted the build infrastruture
103 to support building with either version of GCC as either shadow or primary
104 compiler. This adds a little complication to building with GCC4
105
106 In addition to your normal settings in your env file you should add
107
108 ```bash
109 source ./illumos.sh # Source your normal environment file
110 export GCC_ROOT=/opt/gcc/4.4.4; # Where to find GCC4.x
111 export CW_GCC_DIR=${GCC_ROOT}/bin; # A temporary hack to allow bootstrap of cw(1)
112 export __GNUC=""; # Use GCC as the primary compiler
113 export __GNUC4=""; # Use GCC4 specific flags
114 ```
115
116 This should be sufficient to have GCC 4 used as the primary throughout the
117 build (check nightly.log, and/or run `mcs -p foo.o` to check individual
118 objects.
119
120 ## Illumos Live is really helpful
121
122 A good and convenient way to test stuff is to use Joyent's illumos-live
123 (http://github.com/joyent/illumos-live). My fork contains some additional
124 changes to make it mildly more convenient if you don't have netbooting
125 infrastructure.
126
127 Just make sure that the projects/illumos tree is a clone of this branch, edit
128 the generated illumos.sh env file as in "Build Illumos" above, and build it
129 following their directions.
Something went wrong with that request. Please try again.