- Title:
- pkgsrc on Solaris 11.4 CBE
- Authors:
- Paolo Vincenzo Olivo
- Date:
- Topics:
- Pkgsrc, Solaris
- Id:
- dxta77
■ pkgsrc and SunOS
As I'm slowly becoming well-versed in running pkgsrc outside of NetBSD, I couldn't help falling for the challenge of deploying a pkgsrc-based desktop on my Solaris VM. All things considered, this was one of the main purposes which drove me to install Oracle Solaris in the first place.
Few years ago, I was running OpenIndiana on desktop and getting additional software from either OpenCSW or pkgsrc. In my experience, after NetBSD, Illumos is possibly the best platform where to run pkgsrc, reflecting the effort put by Joyent and the SmartOS folks in delivering a reliable product. Prior to that, J.Perkin had already done extensive work on pkgsrc and Solaris 10, with the intent of getting a unified framework to manage third-party opensource software on Sun's UNIX.
Looking at pkgsrc packages, and skimming through patches and platform- -dependent flags, it's not hard to deduce how most of the work done to adapt pkgsrc to SunOS was carried out on either Sun Solaris or Illumos.
But what about Solaris 11?
By the time it came out, Solaris 11 represented a huge step forward (or sometimes, behind) Solaris 10, in spite of the fact it kept backward binary compatibility with its parent version. Solaris 11 has diverged a lot from illumos over the course of the last decade, and this is all the more evident in Solaris 11.4, which presumably backported and merged some of the things which were scheduled to come to light only in 12, the lost version.
This is to say that was I not expecting to have a smooth experience by attempting to deploy pkgsrc on 11.4. In retrospect, I won't deny I've been at least partially proven wrong. pkgsrc bootstrapped fine at the first attempt and several packages built flawlessly. Many other, however, required minor fixes and adjustements, and some were broken beyond my capabilitites. My suggestion is: do this only if you have time to spare, for learning, for fun, for testing / bug-reporting, and if you want to contribute patches.
■ dependencies
In order to bootstrap pkgsrc on Solaris 11, common requirements are:
pkg:/system/header pkg:/system/linker pkg:/system/library/math pkg:/library/glib2 pkg:/library/libxml2 pkg:/library/zlib pkg:/developer/library/lint pkg:/developer/object-file
And naturally, a compiler.
On Solaris, you usually have two choices when it comes to toolchains: Solaris Studio (formerly known as SUNPro and SUN Studio, now known as Oracle Developer Studio) and GCC (historically available via third-party repositories like sunfreeware and CSW, now included in the official repo). Spoiler: 11.4 also supports and provides LLVM.
Plenty of choices then, so what to use? According to my own -limited- experience, it is advisable to get both Studio and GCC, regardless of OS version.
Noticeably,Solaris Studio is designed from the ground up to play nicely with the only OS it runs upon. Whenever a piece of software is built with portability in mind - especially if it officially supports Solaris - you can be almost sure it's going to build just fine with Solaris Studio.
[EDIT: it would appear that newer versions also run on Oracle Linux]
However, some software will still expect GCC, so it's good to keep a well supported version of the GNU compiler always at hand. Also, GCC is visibly faster: this may be partially due to Solaris Studio not enabling any optimization by default and/or open-source projects catering their compiler flags to GCC.
■ GCC
Installing GCC-7 on Solaris 11.4 is as easy as:
$ pkg install gcc-7
This will install the compiler at /usr/gcc/$(GCC_VERSION)/bin and synmlink it to /usr/bin, so that it will be automatically made available in users's $PATH. Many other versions are available (from 5 to 11, skipping few versions in between). When bootstrapping with GCC, GNU binutiles should be also installed (available as pkg:/developer/gnu-binutils).
If you want to bootstrap pkgsrc using any version of GCC but that associated with /usr/bin/gcc, then the CC environmental variable should be pointed to the correct executable, and GCCBASE set to the corresponding version's dir under /usr/gcc (i.e. GCCBASE=/usr/gcc/7).
■ Solaris Studio
In order to install Solaris Studio some other dependencies need to be satisfied:
pkg:/system/library/c++-runtime pkg:/system/library/libv12n pkg:/system/library/mmheap pkg:/system/library/openmp pkg:/library/c++/stdcxx pkg:/developer/library/xprofile pkg:/developer/base-developer-utilities
Then, providing I downloaded my personal key and certificate files from <pkg-register.oracle.com> and stored them inside /var/ssl, the solarisstudio repository can be added with:
$ pkg set-publisher \ -k /var/pkg/ssl/pkg.oracle.com.key.pem \ -c /var/pkg/ssl/pkg.oracle.com.certificate.pem \ -G '*' -g https://pkg.oracle.com/solarisstudio/release solarisstudio
As of the time of writing this, the repo offers versions 12.[4-6] of Solaris Studio. Version 12.6 is the only to support the C++14 language standard.
The IPS package for Studio 12.6 can be installed with:
$ pkg install --accept developerstudio-126
This will install the whole toolchain, along with the observability tools, dbx, the distributed make and the NetBeans-based studio IDE. If you want to choose individual packages, have a look at:
$ pkg list -af 'pkg://solarisstudio/developer/developerstudio-126/*'
Finally it should be checked that also the following packages are installed:
pkg:/consolidation/sunpro/sunpro-incorporation pkg:/group/feature/developer-studio-utilities pkg:/system/library/studio-runtime
The entire suite can be found at /opt/developerstudio12.6. Should be appended to the standard user's PATH.
■ bootstrapping with Solaris Studio
Since pkgsrc by default searches for Solaris Studio in /opt/SUNWspro whenever the compiler is set to sunpro, SUNWPROBASE needs to be declared.
Assuming pkgsrc was extracted to /opt/pkgsrc and that /opt/pkg is the preferred PREFIX to use, pkgsrc can be bootstrapped with:
env CC=/opt/developerstudio12.6/bin/cc \ SUNWSPROBASE=/opt/developerstudio12.6 \ PKGSRC_COMPILER=sunpro \ ./bootstrap --abi=64 --prefix /opt/pkg
A mk.conf will be generated inside inside $PREFIX/etc, to store the settings relative to compiler and destdirs.
■ additional notes
I added some more tweaks which can prove useful on SunOS systems: (at the very least PREFER.xorgproto=pkgsrc should be set, or libXfixes will fail to build)
.ifdef BSD_PKG_MK # begin pkgsrc settings
ABI= 64 CC= cc CXX= CC CPP= cc -E CXXCPP= CC -E CFLAGS+= -fast -xarch=sse3a -xopenmp=parallel PKGSRC_COMPILER= sunpro SUNWSPROBASE= /opt/developerstudio12.6
_OPSYS_SUPPORTS_SSP= no PKG_DBDIR= /opt/pkg/pkgdb LOCALBASE= /opt/pkg SYSCONFBASE= /opt/pkg/etc VARBASE= /opt/pkg/var PKG_TOOLS_BIN= /opt/pkg/sbin PKGINFODIR= info PKGMANDIR= man
PREFER_PKGSRC= yes PREFER_NATIVE?= oracle-jre8 zlib bzip2 motif JAVA_BINPREFIX= /usr/bin PKG_DEFAULT_OPTIONS= dtrace unicode PREFER_NATIVE_PTHREADS= yes
TOOLS_PLATFORM.install= /opt/local/bin/bsdinstall TOOLS_PLATFORM.awk= /opt/local/bin/nawk TOOLS_PLATFORM.sed= /opt/local/bin/nbsed TOOLS_PLATFORM.sh= /usr/bin/bash
PKG_OPTIONS.fvwm3= -svg
.endif # end pkgsrc settings
At this point all that's left to do is adding $PREFIX/{bin,sbin} to PATH and $PREFIX/man to MANPATH. The runtime linking enviroment for 64-bit objects whould be reconfigured accordingly, so as to include $PREFIX/lib. For example:
$ crle -64 -c /var/ld/64/ld.config -l /lib/64:/usr/lib/64:/opt/pkg/lib
Always take into account that on Solaris any LD_LIBRARY_PATH is prepended to the list of directories stored in the crle database.
Realistically, regardless of the compiler used during the bootstrap process, it is good practicw to fall back to a standard GCC version provided by pkgsrc. This can be done by adding:
USE_PKGSRC_GCC=YES
to $PREFIX/mk.conf. This will make pkgsrc include lang/gcc* among build dependencies and compile it with Solaris Studio before attempting to build any more packages. The internal version of the GNU Compiler will be used as preferred compiler from this moment on. The desired GCC version to use can be forced by specifying GCC_REQD in mk.conf.
At this point any former compiler setting should be commented. If libtool-base was compiled before switching compiler, it should be rebuilt in order to prevent libtool from complaining about missing '--tag=CC' flags while building packages.