Virtual Guru's Blog – Home of Virtualization Workshops

December 9, 2009

C compile enviroment in OpenSolaris JeOS Prototype

Filed under: cloud, jeos, opensolaris, virtualbox, Virtualization — natiku @ 2:24 am

OpenSolaris 200906 JeOS Prototype is PURE CLI enviroment, so its small true command line only enviroment, as such is ideal install BASE for compact porting environment.

OpenSolaris provide a Source Juicer project for porting mainly User Land programs, but what it you want for example play with device drivers written in C ?


General Information – JeOS Prototype OpenSolaris project

Download OpenSolaris 200906 JeOS Prototype VM for one 10+ most popular Virtualization Formats:

JeOS: Just enough OS Project Homepage

OpenSolaris 2009.06 JeOS Prototype VM Images Download

OpenSolaris 2009.06 JeOS Prototype 10 Simple Usage Samples

Discussion jeos-discuss@opensolaris.org (Main page)

Discussion jeos-discuss@opensolaris.org (Archives)

Part 1: Check JeOS readiness as user root

1. Switch to root

pfexec su - root

2a. Check, if PKG will clean download cache on SUCCESS

root@osol-jeos:~# pkg property flush-content-cache-on-success
PROPERTY                       VALUE
flush-content-cache-on-success True

2b. Check, then we increase PKG download patience for slowest networks

root@osol-jeos:~# set | grep PKG
PKG_CLIENT_TIMEOUT=120
PKG_TIMEOUT_MAX=16

2c. Check, then we use right main repository for opensolaris.org

root@osol-jeos:~# pkg publisher
PUBLISHER                             TYPE     STATUS   URI
opensolaris.org          (preferred)  origin   online   http://pkg.opensolaris.org/release/
contrib                               origin   online   http://pkg.opensolaris.org/contrib/

2d. Check, then we can access these repositories

root@osol-jeos:~# pkg refresh --full

2e. Check, opensolaris.org download speed of whole repository catalog

root@osol-jeos:~# curl pkg.opensolaris.org/release/catalog/0 >/dev/null
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100 1333k  100 1333k    0     0  93491      0  0:00:14  0:00:14 --:--:--  126k

2f. Check, if we have enought memory and activated swap (I recommend if possible to have VM with 768MB-1GB RAM configured)

root@osol-jeos:~# top | grep Memory
Memory: 1024M phys mem, 1025M free mem, 512M total swap, 512M free swap

Part2: Install GCC and Sun C compiler

Install latest GCC in install chunks

There is latest developer/gcc/gcc-432 version 4.3.2

root@osol-jeos:~# pkg install "developer/gcc/gcc-runtime-432"
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                    1/1       17/17     5.47/5.47
PHASE                                        ACTIONS
Install Phase                                  43/43
Deleting content cache
root@osol-jeos:~# pkg install "developer/gcc/gcc-432"
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                    6/6   2625/2625   65.15/65.15
PHASE                                        ACTIONS
Install Phase                              3190/3190
Deleting content cache
root@osol-jeos:~# pkg install "developer/gcc/gcc-dev-4"
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                  17/17     997/997     7.73/7.73
PHASE                                        ACTIONS
Install Phase                              1410/1410
Deleting content cache

SUN CC compiler

root@osol-jeos:/~# pkg install -nv sunstudioexpress
Creating Plan / Before evaluation:
UNEVALUATED:
+pkg:/sunstudioexpress@0.2009.3.1,5.11-0.111:20090617T230835Z
After evaluation:
None -> pkg:/sunstudioexpress@0.2009.3.1,5.11-0.111:20090617T230835Z
None -> pkg:/SUNWj6dmo@0.5.11,5.11-0.111:20090508T161117Z
None -> pkg:/SUNWj6rt@0.5.11,5.11-0.111:20090508T161136Z
None -> pkg:/SUNWj6dmx@0.5.11,5.11-0.111:20090508T161130Z
None -> pkg:/SUNWj6rtx@0.5.11,5.11-0.111:20090508T161149Z
None -> pkg:/SUNWj6dev@0.5.11,5.11-0.111:20090508T161108Z
None -> pkg:/SUNWj6dvx@0.5.11,5.11-0.111:20090508T161131Z
None -> pkg:/SUNWj6man@0.5.11,5.11-0.111:20090508T161135Z
None -> pkg:/SUNWj6cfg@0.5.11,5.11-0.111:20090508T161107Z
None -> pkg:/SUNWlibm@0.5.11,5.11-0.111:20090508T161809Z
Actuators:
restart_fmri: svc:/application/font/fc-cache:default
None

Well, it will try to install Java JDK, so I will install only missing SUNWlibm first and after pre-install JDK manually

root@osol-jeos:/~# pkg install SUNWlibm
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                    1/1       16/16     0.04/0.04
PHASE                                        ACTIONS
Install Phase                                  35/35
Deleting content cache

Next install Java runtime

root@osol-jeos:/~# pkg install SUNWj6rt
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                    1/1     686/686   31.77/31.77
PHASE                                        ACTIONS
Install Phase                                880/880
Deleting content cache

Next install Java Dev

root@osol-jeos:/~# pkg install SUNWj6dev
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                    1/1     284/284   33.53/33.53
PHASE                                        ACTIONS
Install Phase                                351/351
Deleting content cache

Next install rest of Java packages

root@osol-jeos:/~# pkg install SUNWj6dmo SUNWj6dmx SUNWj6rtx SUNWj6dvx SUNWj6man SUNWj6cfg
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                    6/6   1960/1960   19.50/19.50
PHASE                                        ACTIONS
Install Phase                              2489/2489
Deleting content cache

Now lets install sunstudioexpress as 219MB download (Yes, its install NetBeans?, but no X/Gnome dependencies and in Sun Studio package), there is nothing I can do about size, but we can setup PKG client to be more network error patient and you can restart installation to continue with download it its fail

Important: If you use a growable virtual disk format be sure then you have in host OS about 2GB free disk space before you will start installation or it will be fail !!”’

root@osol-jeos:~# env| grep PKG
PKG_CLIENT_TIMEOUT=120
PKG_TIMEOUT_MAX=16
root@osol-jeos:~# export PKG_CLIENT_TIMEOUT=60
root@osol-jeos:~# export PKG_TIMEOUT_MAX=99
root@osol-jeos:~# pkg install sunstudioexpress
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                    1/1   5174/5174 219.38/219.38
PHASE                                        ACTIONS
Install Phase                              8104/8104
Deleting content cache

Part 3: Test if we can compile some stuff (Like freeware kernel network driver)

Free NIC drivers for Solaris by Masayuki Murayama

I will use a NI driver needed in Parallels virtualization platform as sample:

Unpack NI driver source

wget http://homepage2.nifty.com/mrym3/taiyodo/ni-0.8.11.tar.gz
root@osol-jeos:/tmp# wget http://homepage2.nifty.com/mrym3/taiyodo/ni-0.8.11.tar.gz
root@osol-jeos:/tmp# gzip -d ni-0.8.11.tar.gz
root@osol-jeos:/tmp# tar xvf ni-0.8.11.tar
root@osol-jeos:/tmp# cd ./ni-0.8.11
root@osol-jeos:/tmp/ni-0.8.11# chmod 0660 Makefile*
root@osol-jeos:/tmp/ni-0.8.11# ls -l | grep Makefile
lrwxrwxrwx 1 111 staff    17 Dec  8 16:07 Makefile -> Makefile.i386_gcc
-rw-rw---- 1 111 staff   853 Jan 22  2006 Makefile.amd64_gcc
-rw-rw---- 1 111 staff   634 Jan 22  2006 Makefile.amd64_suncc
-rw-rw---- 1 111 staff  4059 Jan 22  2006 Makefile.common
-rw-rw---- 1 111 staff   264 Jan 22  2006 Makefile.config
-rw-rw---- 1 111 staff   442 Dec  8 16:13 Makefile.i386_gcc
-rw-rw---- 1 111 staff   397 Jan 22  2006 Makefile.i386_suncc
-rw-rw---- 1 111 staff   630 Jan 22  2006 Makefile.macros

Compiling ni driver with GCC 32bit (default)

root@osol-jeos:/tmp/ni-0.8.11# gsed -i 's\gcc\gcc-4.3.2\g' Makefile.i386_gcc
root@osol-jeos:/tmp/ni-0.8.11# make clean
rm -f i386/*
root@osol-jeos:/tmp/ni-0.8.11# make
gcc-4.3.2 -c -O2 -ffreestanding ....  -DVERSION='"0.8.11"' ni.c -o i386/ni.o
/usr/ccs/bin/ld -r i386/ni.o -o i386/ni
gcc-4.3.2 -c -O2 -ffreestanding ...  -DVERSION='"0.8.11"' pcni.c -o i386/pcni.o
/usr/ccs/bin/ld -r i386/pcni.o -o i386/pcni
gcc-4.3.2 -c -O2 -ffreestanding ...  -DVERSION='"0.8.11"' dp8390.c -o i386/dp8390.o
/usr/ccs/bin/ld -r i386/dp8390.o  -o i386/dp8390

Compiling ni driver with GCC 64bit

root@osol-jeos:/tmp/ni-0.8.11# gsed -i 's\gcc\gcc-4.3.2\g' Makefile.amd64_gcc
root@osol-jeos:/tmp/ni-0.8.11# rm -f Makefile
root@osol-jeos:/tmp/ni-0.8.11# ln -s Makefile.amd64_gcc Makefile
root@osol-jeos:/tmp/ni-0.8.11# make clean
rm -f i386/*
rm -f amd64/*
root@osol-jeos:/tmp/ni-0.8.11# make
gcc-4.3.2 -c -O2 -ffreestanding ...  -DVERSION='"0.8.11"' ni.c -o i386/ni.o
/usr/ccs/bin/ld -r i386/ni.o -o i386/ni
gcc-4.3.2 -c -O2 -ffreestanding ...  -DVERSION='"0.8.11"' pcni.c -o i386/pcni.o
/usr/ccs/bin/ld -r i386/pcni.o -o i386/pcni
gcc-4.3.2 -c -O2 -ffreestanding ...  -DVERSION='"0.8.11"' dp8390.c -o i386/dp8390.o
/usr/ccs/bin/ld -r i386/dp8390.o  -o i386/dp8390
gcc-4.3.2 -c -O2 -ffreestanding ...  -DVERSION='"0.8.11"' ni.c -o amd64/ni.o
/usr/ccs/bin/ld -r amd64/ni.o -o amd64/ni
gcc-4.3.2 -c -O2 -ffreestanding ...  -DVERSION='"0.8.11"' pcni.c -o amd64/pcni.o
/usr/ccs/bin/ld -r amd64/pcni.o -o amd64/pcni
gcc-4.3.2 -c -O2 -ffreestanding ...  -DVERSION='"0.8.11"' dp8390.c -o amd64/dp8390.o
/usr/ccs/bin/ld -r amd64/dp8390.o -o amd64/dp8390

Compiling ni driver with SUN CC in 32 bit

root@osol-jeos:/tmp/ni-0.8.11# rm -f Makefile
root@osol-jeos:/tmp/ni-0.8.11# ln -s Makefile.i386_suncc Makefile
root@osol-jeos:/tmp/ni-0.8.11# make clean
rm -f i386/*
root@osol-jeos:/tmp/ni-0.8.11# export PATH=$PATH:/opt/SunStudioExpress/bin/
root@osol-jeos:/tmp/ni-0.8.11# make
cc -c -O -U_NO_LONGLONG -D_KERNEL ... -DVERSION='"0.8.11"' ni.c -o i386/ni.o
/usr/ccs/bin/ld -r i386/ni.o -o i386/ni
cc -c -O -U_NO_LONGLONG -D_KERNEL ... -DVERSION='"0.8.11"' pcni.c -o i386/pcni.o
/usr/ccs/bin/ld -r i386/pcni.o -o i386/pcni
cc -c -O -U_NO_LONGLONG -D_KERNEL ... -DVERSION='"0.8.11"' dp8390.c -o i386/dp8390.o
/usr/ccs/bin/ld -r i386/dp8390.o  -o i386/dp8390

Compiling ni driver with SUN CC in 32 bit

root@osol-jeos:/tmp/ni-0.8.11# rm -f Makefile
root@osol-jeos:/tmp/ni-0.8.11# ln -s  Makefile.amd64_suncc Makefile
root@osol-jeos:/tmp/ni-0.8.11# make clean
rm -f i386/*
rm -f amd64/*
root@osol-jeos:/tmp/ni-0.8.11# make
cc -c -O -U_NO_LONGLONG -D_KERNEL ...  -DVERSION='"0.8.11"' ni.c -o i386/ni.o
/usr/ccs/bin/ld -r i386/ni.o -o i386/ni
cc -c -O -U_NO_LONGLONG -D_KERNEL ...  -DVERSION='"0.8.11"' pcni.c -o i386/pcni.o
/usr/ccs/bin/ld -r i386/pcni.o -o i386/pcni
cc -c -O -U_NO_LONGLONG -D_KERNEL ... -DVERSION='"0.8.11"' dp8390.c -o i386/dp8390.o
/usr/ccs/bin/ld -r i386/dp8390.o  -o i386/dp8390
cc -c -O -U_NO_LONGLONG -D_KERNEL -xarch=amd64 -Di86pc -Wu,-xmodel=kernel ...  -DVERSION='"0.8.11"' ni.c -o amd64/ni.o
cc: Warning: -xarch=amd64 is deprecated, use -m64 to create 64-bit programs
/usr/ccs/bin/ld -r amd64/ni.o -o amd64/ni
cc -c -O -U_NO_LONGLONG -D_KERNEL -xarch=amd64 -Di86pc -Wu,-xmodel=kernel ...  -DVERSION='"0.8.11"' pcni.c -o amd64/pcni.o
cc: Warning: -xarch=amd64 is deprecated, use -m64 to create 64-bit programs
/usr/ccs/bin/ld -r amd64/pcni.o -o amd64/pcni
cc -c -O -U_NO_LONGLONG -D_KERNEL -xarch=amd64 -Di86pc -Wu,-xmodel=kernel ...  -DVERSION='"0.8.11"' dp8390.c -o amd64/dp8390.o
cc: Warning: -xarch=amd64 is deprecated, use -m64 to create 64-bit programs
/usr/ccs/bin/ld -r amd64/dp8390.o -o amd64/dp8390
About these ads

2 Comments »

  1. [...] C compile enviroment in OpenSolaris JeOS Prototype [...]

    Pingback by OpenSolaris JeOS (Main Page) « Virtual Guru's Blog – Home of Virtualization Workshops — February 7, 2010 @ 3:49 pm

  2. [...] If you like to have full C devel environment for personal Source Juicer in OpenSolaris 200906 JeOS Prototype, see more in C compile enviroment in OpenSolaris JeOS Prototype [...]

    Pingback by Personal SourceJuicer in OpenSolaris JeOS Prototype « Virtual Guru's Blog – Home of Virtualization Workshops — February 7, 2010 @ 5:40 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: