This is the mail archive of the mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Solaris 9 crosstool cookbook (long)

Hi all,

After fighting for many days to try and get Dan Kegel's crosstool working on Solaris, I
finally succeeded. I figured I'd document the troubles I ran into (mostly due to Solaris
having a default shell of Bourne shell), in the hopes that it would help others (and maybe
provide patches to add portability to the tool :)

Anyway, I'm running Solaris 9, and needed to install gcc 3.4.4, glibc 2.3.5 (because I want
to use this machine as a node for distcc compiles for my gentoo box).

Not sure if there's any difference with Solaris 10, or different versions of gcc/glibc,
but hopefully this will serve as a starting point.

I grabbed the GNU stuff from (binutils, gawk, coreutils, textinfo, gcc, etc).
I made sure that /usr/local/bin was first in my path, and got to work.

First thing I encountered was a problem in, namely, the shell didn't like:

for arg; do

so I changed both occurrences into:

for arg

Next, I needed to fix a patch, namely gcc-3.4.4/fix-fixincl.patch. Change the double quotes
around the sed commands to single quotes:

+SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`
+SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta`


+ if test "x${SYSTEM_HEADER_DIR}" = "x`echo "${gcc_tooldir}/sys-include" | sed -e :a -
e "s,[^/]*/\.\.\/,," -e ta`";
+ if test "x${SYSTEM_HEADER_DIR}" = "x`echo "${gcc_tooldir}/sys-include" | sed -e :a -
e 's,[^/]*/\.\.\/,,' -e ta`";

if you don't, when running, you'll receive an error similar to:

chmod 755 ../
make[2]: Leaving directory `/export/home/rlippmann/crosstool-0.38/build/i686-unknown-linux-gnu
The directory that should contain system headers does not exist:
sed: -e expression #2, char 3: unterminated `s' command
/bin/sh: : cannot execute
/bin/sh: /]*/../,, -e ta: not found
sed: -e expression #2, char 3: unterminated `s' command
/bin/sh: : cannot execute
/bin/sh: : cannot execute
/bin/sh: /]*/../,, -e ta: not found
make[1]: *** [stmp-fixinc] Error 1
make[1]: Leaving directory `/export/home/rlippmann/crosstool-0.38/build/i686-unknown-linux-gnu
make: *** [all-gcc] Error 2
sed: -e expression #2, char 3: unterminated `s' command
/bin/sh: /]*/../,, -e ta: not found

Next, we add a patch to the glibc build bug (Debian Bug #207391). Create a file in the patche
s/glibc-{version} directory, called, say versioninfo.patch:

--- glibc-2.3.5/csu/Makefile.old        Sun Dec 11 14:11:32 2005
+++ glibc-2.3.5/csu/Makefile    Sun Dec 11 14:12:39 2005
@@ -241,7 +241,7 @@
        esac; \
        files="$(all-Banner-files)";                           \
        if test -n "$$files"; then                             \
-          echo "\"Available extensions:\\n\"";                 \
+          printf '"Available extensions:\\n"\n';                       \
          sed -e '/^#/d' -e 's/^[[:space:]]*/  /'              \
              -e 's/^\(.*\)$$/\"\1\\n\"/' $$files;             \
        fi) > $@T

If you don't do this, at build time, you will see an error like:

In file included from version.c:33:
-glibc/csu/version-info.h:2: error: missing terminating " character
-glibc/csu/version-info.h:3: error: missing terminating " character
version.c:40: error: parse error before string constant
make[2]: *** [/export/home/rlippmann/crosstool-0.38/build/i686-unknown-linux-gnu/gcc-3.4.4-gli
bc-2.3.5/build-glibc/csu/version.o] Error 1
make[2]: Leaving directory `/export/home/rlippmann/crosstool-0.38/build/i686-unknown-linux-gnu
make[1]: *** [csu/subdir_lib] Error 2
make[1]: Leaving directory `/export/home/rlippmann/crosstool-0.38/build/i686-unknown-linux-gnu
make: *** [lib] Error 2

Next, we need to apply the attached patch to It basically works around the
fact that configure for the initial glibc header install requires GNU binutils, and the
Sunfreeware compiler (and Solaris companion cd gcc) use the Solaris linker/assembler.

If you don't apply this patch, you'll see an error like:

checking for makeinfo... makeinfo
checking version of makeinfo... 4.5, ok
checking for sed... sed
checking version of sed... 4.1.1, ok
checking for autoconf... autoconf
checking whether autoconf works... no
configure: error:
*** These critical programs are missing or too old: as ld
*** Check the INSTALL file for required versions.

Finally, we can build. With a bit of luck, you'll get all the way to the point where you get
this error:

/usr/local/bin/install -c /export/home/rlippmann/crosstool-0.38/build/i686-unknown-lin
ux-gnu/gcc-3.4.4-glibc-2.3.5/build-glibc/posix/getconf /opt/crosstool/gcc-3.4.4-glibc-2.3.5/i6
86-unknown-linux-gnu/i686-unknown-linux-gnu/libexec/getconf/$; \
mv -f /opt/crosstool/gcc-3.4.4-glibc-2.3.5/i686-unknown-linux-gnu/i686-unknown-linux-g
nu/libexec/getconf/$ /opt/crosstool/gcc-3.4.4-glibc-2.3.5/i686-unknown-linux-gnu/i686-
unknown-linux-gnu/libexec/getconf/$spec; \
-glibc/elf/ syntax error at line 1: `(' unexpected
make[2]: *** [/opt/crosstool/gcc-3.4.4-glibc-2.3.5/i686-unknown-linux-gnu/i686-unknown-linux-g
nu/libexec/getconf] Error 2
make[2]: Leaving directory `/export/home/rlippmann/crosstool-0.38/build/i686-unknown-linux-gnu
make[1]: *** [posix/subdir_install] Error 2
make[1]: Leaving directory `/export/home/rlippmann/crosstool-0.38/build/i686-unknown-linux-gnu
make: *** [install] Error 2

which is because is a 386 elf binary, not sparc. I'm not certain why I didn't
have this problem on a Cygwin build, so a complete fix probably would involve seeing what the
Cygwin build did to work around this problem (or not run into it in the first place).

Anyway, all this step appears to be doing is running getconf on the installed headers to find
out what _POSIX_V6_WIDTH_RESTRICTED_ENVS is. According to my linux box, it should be:

[rlippmann@akko ~]$ getconf _POSIX_V6_WIDTH_RESTRICTED_ENVS

so, we edit build/*/*/glibc-{version}/posix/Makefile, and change the long, ugly:

for spec in .... \
; do


for spec in POSIX_V6_ILP32_OFF32 POSIX_V6_ILP32_OFFBIG \
   ; do

and re-run (don't forget to use --nounpack, or you'll hose these changes).

Voila, you should have a complete linux toolchain on Solaris.

-- rob

---	Tue Dec 13 23:27:02 2005
+++	Mon Dec 12 23:52:35 2005
@@ -398,12 +398,54 @@
         # is ok here, since all we want are the basic headers at this point.
         # Override libc_cv_ppc_machine so glibc-cvs doesn't complain
         # 'a version of binutils that supports .machine "altivec" is needed'.
+	# ugly solaris hack 
+	if [ "`uname`" = "SunOS" ]
+	then
+          # sunfreeware and companion CD gccs use Solaris native ld and as, need to check
+          # and hack around this as glibc configure requires GNU ld and as and gives up if
+	  # it doesn't find them
+	  # 
+	  # hack assumes that GNU binutils are first in PATH
+	  # 
+     	  # should really be able to set AS=`which as` and LD=`which ld` or
+	  # templd=`which ld`; --with-binutils=`basename $templd`, but neither of those seem
+	  # to work, so need to resort to these nasty internal variable settings
+           if `gcc -print-prog-name=ld` -V </dev/null 2>&1 | grep GNU >/dev/null 2>&1
+           then
+           # gnu ld, do nothing
+             sleep 1 
+           else
+             if `which ld` -V </dev/null 2>&1 | grep GNU >/dev/null 2>&1
+             then
+               # override configures ld
+               SOLARIS_HACK="libc_cv_prog_ld_gnu=yes ac_cv_prog_LD=`which ld`"
+               echo SOLARIS_HACK=$SOLARIS_HACK
+             else
+               abort "GNU ld not first in PATH"
+             fi
+           fi
+           # and do the same for as
+           if `gcc -print-prog-name=as` -V </dev/null 2>&1 | grep GNU >/dev/null 2>&1
+           then
+           # gnu as, do nothing
+            sleep 1 
+           else
+              if `which as` -V </dev/null 2>&1 | grep GNU >/dev/null 2>&1
+              then
+                 SOLARIS_HACK="$SOLARIS_HACK libc_cv_prog_as_gnu=yes ac_cv_prog_AS=`which as`"
+                 echo SOLARIS_HACK=$SOLARIS_HACK
+              else
+                abort "GNU as not first in PATH"
+              fi
+           fi
+       fi
         libc_cv_ppc_machine=yes \
         CC=gcc \
             ${GLIBC_DIR}/configure --prefix=/usr \
             --build=$BUILD --host=$TARGET \
             --without-cvs --disable-sanity-checks --with-headers=$HEADERDIR \
-            --enable-hacker-mode
+            --enable-hacker-mode $SOLARIS_HACK
     if grep -q GLIBC_2.3 ${GLIBC_DIR}/ChangeLog; then

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]