This is the mail archive of the crossgcc@sourceware.org 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] |
Using Crosstool within a Solaris Container (Zone) Background Utilities like Crosstool, which make the task of creating cross development environments much more tolerable, also happen to make various linux and GNU assumptions which differ from Solaris. By introducing new paths and GNU versions of applications, it is possible to mimic this environment in Solaris. By creating a new Solaris Container (Zone) with this environment, we can isolate these changes without affecting other Solaris system settings. 1. Create a Solaris zone called 'toolzone' Here's the command-line session for creating the zone (as root in the global zone): phoenix://# mkdir /zone phoenix://# zonecfg -z toolzone toolzone: No such zone configured Use 'create' to begin configuring a new zone. zonecfg:toolzone> create zonecfg:toolzone> set zonepath=/zone/toolzone zonecfg:toolzone> set autoboot=true zonecfg:toolzone> add net zonecfg:toolzone:net> set address=toolzone zonecfg:toolzone:net> set physical=iprb0 zonecfg:toolzone:net> end zonecfg:toolzone> info zonepath: /zone/toolzone autoboot: true pool: inherit-pkg-dir: dir: /lib inherit-pkg-dir: dir: /platform inherit-pkg-dir: dir: /sbin inherit-pkg-dir: dir: /usr net: address: toolzone physical: iprb0 zonecfg:toolzone> verify zonecfg:toolzone> commit zonecfg:toolzone> ^D phoenix://# zoneadm list -vc ID NAME STATUS PATH 0 global running / - toolzone configured /zone/toolzone phoenix://# time zoneadm -z toolzone install Preparing to install zone <toolzone>. Creating list of files to copy from the global zone. Copying <6666> files to the zone. Initializing zone product registry. Determining zone package initialization order. Preparing to initialize <945> packages on the zone. Initialized <945> packages on zone. Zone <toolzone> is initialized. Installation of <2> packages was skipped. Installation of these packages generated warnings: <SUNWcsu SUNWsogm> The file </zone/toolzone/root/var/sadm/system/logs/install_log> contains a log of the zone installation. real 13m20.721s user 0m59.799s sys 2m58.030s 2. Configure the zone. 2a. Create a zone-specific /usr/bin directory and copy the contents of the global zone's /usr/bin to this new directory. phoenix://# mkdir -p /zone/toolzone/usr/bin phoenix://# cd /usr/bin phoenix://# tar cf - . | (cd /zone/toolzone/usr/bin; tar xfp -) 2b. Create a loopback mount for the toolzone to this new version of /usr/bin: phoenix://# zonecfg -z toolzone zonecfg:toolzone> addfs zonecfg:toolzone:fs> set dir=/usr/bin zonecfg:toolzone:fs> set special=/zone/toolzone/usr/bin zonecfg:toolzone:fs> set type=lofs zonecfg:toolzone:fs> end zonecfg:toolzone> ^D 2c. Boot and configure the newly created zone: phoenix://# zoneadm -z toolzone boot phoenix://# zlogin -C toolzone 2d. Change the path of the default shell to /usr/bin/bash. This is required for crosstool to operate correctly. toolzone://# cd /usr/bin toolzone:bin/# mv sh sh.ORIG toolzone:bin/# ln -s /usr/bin/bash sh 2e. Create a new user in the toolzone. For this example, we'll use 'cdc'. This exercise is left to the user. toolzone://# grep cdc /etc/passwd cdc:x:600:10:CDC-HI build user:/export/home/cdc:/usr/bin/bash 2f. Create a directoy called /opt/gnulinks and make sure the 'cdc' user owns it. This directory will house versions and links to GNU utilities which differ from their Solaris counterparts. toolzone://# mkdir /opt/gnulinks toolzone://# chown cdc:staff /opt/gnulinks toolzone://# ls -ld /opt/gnulinks drwxr-xr-x 2 cdc staff 512 Jun 19 13:14 /opt/gnulinks 3. As the newly created 'cdc' user, configure the zone to build the crosstool environment 3a. Login to the zone as the 'cdc' user. phoenix://# zlogin -l cdc toolzone [Connected to zone 'toolzone' pts/6] Last login: Mon Jun 19 12:57:05 on pts/6 Sun Microsystems Inc. SunOS 5.10 Generic January 2005 toolzone:~/$ 3b. To get a zone-specific prompt, you might want to have an entry in ~cdc/.bash_profile like: export PS1='\h:\W/\$ ' 3c. Create links in /opt/gnulinks/bin which point to GNU versions of unix utilities toolzone:bin/$ mkdir -p /opt/gnulinks/bin toolzone:bin/$ cd /opt/gnulinks/bin toolzone:bin/$ ln -s /usr/sfw/bin/gar ar toolzone:bin/$ ln -s /usr/sfw/bin/gm4 m4 toolzone:bin/$ ln -s /usr/sfw/bin/gmake make toolzone:bin/$ ln -s /usr/sfw/bin/gnm nm toolzone:bin/$ ln -s /usr/sfw/bin/gobjcopy objcopy toolzone:bin/$ ln -s /usr/sfw/bin/gobjdump objdump toolzone:bin/$ ln -s /usr/sfw/bin/gstrings strings toolzone:bin/$ ln -s /usr/sfw/bin/gstrip strip toolzone:bin/$ ln -s /usr/sfw/bin/gtar tar toolzone:bin/$ ln -s /usr/sfw/bin/gthumb thumb toolzone:bin/$ ls -l /opt/gnulinks/bin total 20 lrwxrwxrwx 1 cdc staff 16 Jun 19 13:33 ar -> /usr/sfw/bin/gar lrwxrwxrwx 1 cdc staff 16 Jun 19 13:33 m4 -> /usr/sfw/bin/gm4 lrwxrwxrwx 1 cdc staff 18 Jun 19 13:33 make -> /usr/sfw/bin/gmake lrwxrwxrwx 1 cdc staff 16 Jun 19 13:34 nm -> /usr/sfw/bin/gnm lrwxrwxrwx 1 cdc staff 21 Jun 19 13:34 objcopy -> /usr/sfw/bin/gobjcopy lrwxrwxrwx 1 cdc staff 21 Jun 19 13:34 objdump -> /usr/sfw/bin/gobjdump lrwxrwxrwx 1 cdc staff 21 Jun 19 13:34 strings -> /usr/sfw/bin/gstrings lrwxrwxrwx 1 cdc staff 19 Jun 19 13:35 strip -> /usr/sfw/bin/gstrip lrwxrwxrwx 1 cdc staff 17 Jun 19 13:35 tar -> /usr/sfw/bin/gtar lrwxrwxrwx 1 cdc staff 19 Jun 19 13:35 thumb -> /usr/sfw/bin/gthumb 3d. Modify PATH of 'cdc' user by putting the following line in ~cdc/.bash_profile: export PATH=/opt/gnulinks/bin:/usr/sfw/bin:$PATH 3e. Build and install GNU specific utilities required for crosstool which are not provided by Solaris. They include fileutils, gawk(1), patch(1) and sed(1). toolzone:~/$ which tar /opt/gnulinks/bin/tar toolzone:~/$ cd toolzone:~/$ mkdir GNU toolzone:~/$ cd ~/GNU toolzone:GNU/$ wget http://ftp.gnu.org/gnu/fileutils/fileutils-4.1.tar.gz toolzone:GNU/$ tar xzf fileutils-4.1.tar.gz toolzone:GNU/$ cd fileutils-4.1 toolzone:fileutils-4.1/$ ./configure --prefix=/opt/gnulinks toolzone:fileutils-4.1/$ make toolzone:fileutils-4.1/$ make install toolzone:~/$ cd ~/GNU toolzone:GNU/$ wget http://ftp.gnu.org/gnu/gawk/gawk-3.1.5.tar.gz toolzone:GNU/$ tar xzf gawk-3.1.5.tar.gz toolzone:GNU/$ cd gawk-3.1.5 toolzone:gawk-3.1.5/$ ./configure --prefix=/opt/gnulinks toolzone:gawk-3.1.5/$ make toolzone:gawk-3.1.5/$ make install toolzone:~/$ cd ~/GNU toolzone:GNU/$ wget ftp://ftp.gnu.org/gnu/patch/patch-2.5.4.tar.gz toolzone:GNU/$ tar xzf patch-2.5.4.tar.gz toolzone:GNU/$ cd patch-2.5.4 toolzone:patch-2.5.4/$ ./configure --prefix=/opt/gnulinks toolzone:patch-2.5.4/$ make toolzone:patch-2.5.4/$ make install toolzone:~/$ cd ~/GNU toolzone:GNU/$ wget http://ftp.gnu.org/pub/gnu/sed/sed-4.1.4.tar.gz toolzone:GNU/$ tar sed-4.1.4.tar.gz toolzone:GNU/$ cd sed-4.1.4 toolzone:sed-4.1.4/$ ./configure --prefix=/opt/gnulinks toolzone:sed-4.1.4/$ make toolzone:sed-4.1.4/$ make install 4. As the 'cdc' user, build a cross development environment using crosstool. These instructions are taken from http://www.kegel.com/crosstool/crosstool-0.42/doc/crosstool-howto.html#quick toolzone:~/$ cd toolzone:~/$ wget http://kegel.com/crosstool/crosstool-0.42.tar.gz toolzone:~/$ tar -xzvf crosstool-0.42.tar.gz toolzone:~/$ su - toolzone://# mkdir /opt/crosstool toolzone://# chown cdc:staff /opt/crosstool toolzone://# exit toolzone:~/$ 4.1 As an example, use these configuration files to build a crosstool for a Sharp Zaurus SL-5000D running OpenZaurus 3.5.1: toolzone:~/$ cd ~/crosstool-0.42 toolzone:crosstool-0.42/$ cat oz-3.5.1.sh #!/bin/sh set -ex TARBALLS_DIR=$HOME/downloads RESULT_TOP=/opt/crosstool export TARBALLS_DIR RESULT_TOP GCC_LANGUAGES="c,c++" export GCC_LANGUAGES # Really, you should do the mkdir before running this, # and chown /opt/crosstool to yourself so you don't need to run as root. mkdir -p $RESULT_TOP # Build the toolchain. Takes a couple hours and a couple gigabytes. eval `cat arm-softfloat.dat oz-3.5.1.dat` sh all.sh --notest echo Done. toolzone:crosstool-0.42/$ cat oz-3.5.1.dat BINUTILS_DIR=binutils-2.15 GCC_DIR=gcc-3.4.2 GLIBC_DIR=glibc-2.3.2 LINUX_DIR=linux-2.4.18 GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.2 GDB_DIR=gdb-6.4 4.2 Build the toolchain toolzone:crosstool-0.42/$ time sh oz-3.5.1.sh > OUT.oz-3.5.1 2>&1 & [1] 4136 real 67m0.915s user 29m31.539s sys 15m13.665s 19 June 2006
-- For unsubscribe information see http://sourceware.org/lists.html#faq
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |