Pkgsrc and Solaris10-amd64

The target is to build only 64bit packages on Solaris10. The build architecture is
amd64 but may work on sparcv9 too (initial tests are positive :) )
I use only the gcc 3.4.3 compiler found in /usr/sfw.

1) The Problem.

Please excuse my english, :(

I patch Solaris to shadow all 32bit flags and to correct some solaris bugs when compiling
in 64bits. I patch pkgsrc to create two new ARCH: x86_64 and sparc64,
Because Solaris runing on a 64bit kernel say it runs on a 32bits processor (uname -p, return i386 or sparc) and misconfigures some packages (often multimedia packages).
That was also a challenge from Joerg ;)

I think the result of this work is not bad. The number of Solaris10-x86_64 is over 4000 packages.
See the bulk build for Solaris10.

2) Patch for Solaris10.

You need a wrapper as describe in pkgsrc-guide Buildling 64-bit binaries with SunPro but for gcc. Do :
cd /usr/sfw/bin
mv gcc gcc.orig
mv g++ g++.orig
cp gcc.64.patch.i86pc gcc # for amd64
cp gcc.64.patch.sun4u gcc # for sparc64
cp g++.64.patch.i86pc g++ # amd64
cp g++.64.patch.sun4u g++ # sparc64
chmod 755 gcc g++
have a look to those scripts and notice the modified answer of '--print-search-dirs' and
forced option -m64. The library part must point to the right place. This bug exists also in gcc4.
The specs file of gcc is also buggy.

cp usr_sfw_lib_gcc_i386-pc-solaris2.10_3.4.3_specs   /usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/specs    # amd
cp usr_sfw_lib_gcc_sparc-sun-solaris2.10_3.4.3_specs /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/specs  # sparc

Misc. other patch:

(cd /usr/lib/64 ; ln -s libcrypt_i.so libcrypt.so)
cp  usr_lib_64_pkgconfig_xproto.pc  /usr/lib/64/pkgconfig/xproto.pc
cp  usr_lib_pkgconfig_xproto.pc     /usr/lib/pkgconfig/xproto.pc

If you have an old Solaris10 (before 06/06) do:
cp  libstdc++.la.32         libstdc++.la.32         #amd/sparc
cp libsupc++.la.32 libsupc++.la.32 #amd/sparc
cp libstdc++.la.64 libstdc++.la.64 #amd
cp libsupc++.la.64 libsupc++.la.64 #amd
cp libstdc++.la.64.sparcv9 libstdc++.la.64.sparcv9 #sparc
cp libsupc++.la.64.sparcv9 libsupc++.la.64.sparcv9 #sparc

Save your work before making a copy.

3) Patch for Pkgsrc.

The most important patch is the bootstrap-patch.  Apply it and make the boostrap like this:

cd ${pkgsrcdir}/bootstrap

ABI=64
GCC_ABI=64
CC=gcc
export ABI GCC_ABI CC
unset PKG_PATH

./bootstrap --workdir=/pkg/obj

ln -s $HOME/mk.conf /usr/pkg/etc/mk.conf

# xproto.pc is missing on Solaris, which is a bug.
# some packages test xproto.pc
mkdir -p /usr/pkg/lib/pkgconfig
cp -p /usr/lib/${ABI}/pkgconfig/xproto.pc /usr/pkg/lib/pkgconfig/xproto.pc

Create an account for pkgsrc. Some pkgsrc environment are here. And now try :

[pkgsrc] pwd
/usr/pkgsrc/pkgtools/pkglint
[pkgsrc] bmake show-var VARNAME=MACHINE_ARCH
x86_64
[pkgsrc] bmake show-var VARNAME=MACHINE_GNU_PLATFORM
x86_64-sun-solaris2


This is useful when bmakeing multimedia packages. The configure option '--host' is set correctly and uses the right assembler files . (or a 'C' file).
The downside is you can not compile gcc without a heavy patch (I have it for gcc3.4.3 ;) ..
but not for pkgsrc :( ).
Also some packages compile correctly but crash (x11/xflame) . I think it is a 64bits problem.


For a year now, I have been a lot experimenting with playing (?) a lot with pkgsrc. I maintain a cvs HEAD line in parallel whith my work.
I have installed over 500 packages on a computer room for students. Seems work OK...
I have made too many patches to remember them all.
You can find the diff between my work and pkgsrc HEAD (both are 2006Q4).
Have a look at pkgtools/x11-links for openwin in the diff.

4) Miscellaneous patches.

4.1) mandoc for Solaris. Formating doc in /usr/pkg/man/cat*

Some manual in packages are  of type -mandoc. Strange results are output when using
the man of Solaris. This patch is valid for package that are NOT part of bootstrap.
First create the mandatory files on solaris:
/usr/ucb/install -c -o bin -g bin -m 444 tmac.andoc /usr/share/lib/tmac
mkdir -p /usr/share/tmac
cd /usr/share/tmac
tar xfp mdoc.tar
alias mandoc='man -T/usr/share/lib/tmac/tmac.andoc'
MANPATH=/usr/pkg/man:/usr/pkg/share/man:$MANPATH
Second adjust file for pkgsrc:
cp SunOS.bsd.man.mk pkgtools/bootstrap-mk-files/files/mods/SunOS.bsd.man.mk
This file is the brother of NetBSD.bsd.man.mk. Now the man of some packages is readable with Solaris nroff's with the command: "mandoc rxterm".

4.2) libusb.so for Solaris 64bit API. Compile it with gcc.

/usr/sfw/lib/libusb.so is a 32bit library. There is no 64bit libusb for Solaris. But source
is available in /usr/sfw/src (need SUNWlibusbS and SUNWlibusbugenS) or download it from http://dlc.sun.com/osol/sfw/downloads/current/
Work in progress...

Comments are welcome.
Thanks to pkgsrc developper.