Solaris and R

This page contains information about getting R running on Solaris. This is sometimes necessary because CRAN tests R packages on the Solaris operating system, and if your R package fails CRAN checks, you'll need a way to debug it. The goal of this page is to document how to recreate a similar environment to the CRAN check server by using a virtual machine.

VirtualBox

VirtualBox seems to be the best way to get Solaris 10 running on a virtual machine. I have tried QEMU (KVM) but haven't had as much success due to some issues with Solaris 10 and QEMU network drivers. You can get VirtualBox from here or through whatever package manager you use.

Solaris 10

CRAN checks supposedly run on Solaris 10. This page seems to indicate that they're running Solaris 10 on a 32-bit CPU. However, I suspect that this is not entirely true. Based on the details page, they are running Solaris 10 on a 64-bit CPU but building a 32-bit version of R. Additionally, Oracle does not provide 32-bit compilers anymore unless you go back to version 12.4 of Solaris Studio (latest is 12.6).

You can download the Solaris 10 installation medium image from the Oracle website. Get the x86 version (it contains x86 and x86_64). As far as I can tell, R doesn't support Solaris on SPARC anymore (and I don't even know if it's possible to emulate a SPARC processor on VirtualBox).

Oracle Developer Studio 12.5

CRAN servers use R that was built using Oracle Developer Studio version 12.5. You can download it here. Get the SVR4 installer on x86 file. You may have to signup for a free Oracle account.

How To

  1. Create a VirtualBox virtual machine for Solaris 10 on a 64-bit CPU. I created one with 8 GB of memory and a 32 GB hard drive (probably overkill). For networking, I set up a bridged network so that the virtual machine would get a real IP address and be accessible from other devices on the network, but the NAT network might work, too.
  2. Boot the virtual machine. VirtualBox should ask you for an installation medium. Select the Solaris 10 DVD ISO image you downloaded from the Oracle website.
  3. Follow the instructions from the installer to install Solaris 10. I selected Yes for networking as well as DHCP. I selected None for naming services. Choose whatever timezone you're in. If you have the opportunity to pick a locale, I recommend a UTF-8 one. Otherwise I used the default installation options, except for registering the system with Oracle.
  4. When you reboot, remove the installation medium using the VirtualBox menus or it will try to boot into the installation DVD again.
  5. Choose a console session from the login menu and login as root. From there, you can create a user account if you want by running the following command: useradd -d /export/home/foo -m -s /usr/bin/bash foo, then set a password via passwd foo. Afterwards you can SSH into the Solaris 10 machine as the user you created.
  6. Install the pkgutil package from OpenCSW as root by following these instructions. You'll need to install a lot of packages from OpenCSW later. Add /opt/csw/bin to the main PATH to make things easier by editing the /etc/default/login file.
  7. Install sudo if you want. I like sudo because being root all the time is generally Not Good. You can do that by running pkgutil -y -i sudo. Create a wheel group by running groupadd wheel, then run usermod -G wheel foo to add your user to the wheel group. Edit the /etc/opt/csw/sudoers file and uncomment the line that enables users in the wheel group to run sudo.
  8. Copy the Oracle Developer Studio 12.5 tarball you downloaded to the VM (by using scp or something similar). Extract the tarball (bzcat filename | tar xvf -), then run the installation script as root: ./developerstudio.sh --non-interactive. Install the patches via the following command (as root): ./install_patches.sh
  9. Put the Oracle Developer Studio directory (/opt/developerstudio12.5/bin) in your PATH by editing the /etc/default/login file. You'll also need to put this directory in your PATH so that R will build properly: /usr/ccs/bin. Logout and back in so that the new PATH takes effect (or just export it in your current session if you want).
  10. Install all the dependencies for R by running this command as root (it will take a while):
    pkgutil -y -i CSWalternatives CSWbash CSWbdb48 CSWcacertificates CSWcas-etcservices CSWcas-etcshells CSWcas-migrateconf CSWcas-preserveconf CSWcas-texinfo CSWcommon CSWggettext-data CSWgit CSWgmake CSWiconv CSWless CSWlibassuan0 CSWlibbrotli-dev CSWlibbrotlicommon1 CSWlibbrotlidec1 CSWlibbrotlienc1 CSWlibbz2-1-0 CSWlibcairo-dev CSWlibcairo-gobject2 CSWlibcairo-script-interpreter2 CSWlibcairo2 CSWlibcares-dev CSWlibcares2 CSWlibcharset1 CSWlibcom-err3 CSWlibcurl-dev CSWlibcurl4 CSWlibcurl4-feature CSWlibevent2-0-5 CSWlibexpat1 CSWlibffi6 CSWlibfontconfig1 CSWlibfreetype6 CSWlibgcc-s1 CSWlibgdbm4 CSWlibglib2-0-0 CSWlibgobject2-0-0 CSWlibgpg-error0 CSWlibgpgme11 CSWlibhistory7 CSWlibiconv-dev CSWlibiconv2 CSWlibicudata57 CSWlibicuuc57 CSWlibidn2-0 CSWlibidn2-dev CSWlibintl8 CSWlibintl9 CSWlibk5crypto3 CSWlibkrb5-3 CSWlibkrb5-dev CSWlibkrb5support0 CSWliblber2-4-2 CSWlibldap2-4-2 CSWliblzma-dev CSWliblzma5 CSWliblzo2-2 CSWlibmetalink3 CSWlibncurses6 CSWlibncursesw6 CSWlibnghttp2-14 CSWlibnghttp2-dev CSWlibpcre-dev CSWlibpcre1 CSWlibpcre16-0 CSWlibpcre32-0 CSWlibpcrecpp0 CSWlibpcreposix0 CSWlibpixman-dev CSWlibpixman1-0 CSWlibpng15-15 CSWlibpng16-16 CSWlibpopt0 CSWlibpsl-dev CSWlibpsl5 CSWlibpython2-7-1-0 CSWlibreadline-dev CSWlibreadline7 CSWlibrtmp-dev CSWlibrtmp0 CSWlibsasl2-2 CSWlibssh2-1 CSWlibssh2-dev CSWlibssl-dev CSWlibssl1-0-0 CSWlibunistring2 CSWlibuuid1 CSWlibverto0 CSWlibxrender CSWlibz-dev CSWlibz1 CSWopenssh-client CSWperl CSWpkgutil CSWpm-error CSWpm-io-socket-ssl CSWpm-net-smtp-ssl CSWpm-net-ssleay CSWpm-term-readkey CSWpmnetsmtpssl CSWpublic-suffix-list CSWrsync CSWsudo CSWterminfo CSWterminfo-rxvt-unicode CSWtmux CSWvim CSWvimrt CSWwget CSWgcc5core CSWgcc5g++ CSWlibgcc-s1
    
    Some of these are duplicate packages. I got this list from listing all of the packages I had installed using pkgutil -l. You can optionally install the texlive package if you want (via pkgutil -y -i texlive).
  11. Run this command as root so that the R configure script can find the liblber library: ln -s /opt/csw/lib/liblber-2.4.so.2.10.3 /opt/csw/lib/liblber.so. The version of liblber you have may be different from mine. This was needed for me because the R configure script complained about not being able to find libcurl. After checking the config.log file, I discovered that the configure script failed because it couldn't find the liblber library. Fun times.
  12. Download the R source tarball from CRAN. I used wget from OpenCSW to do this, but you can also just download it to your host machine and copy the file over to the VM if you want. Extract the tarball by running: gzip -dc filename | tar xvf -
  13. Move the config.site file in the R source directory to config.site.orig. Create a new config.site file and put the following in it:
    CC="cc -xc99"
    CFLAGS="-O -xlibmieee"
    CPPFLAGS="-I/opt/csw/include"
    LDFLAGS="-L/opt/csw/lib"
    F77="f95"
    FFLAGS="-O"
    CXX="CC -library=stlport4"
    CXXFLAGS="-O"
    CXX1X="/opt/csw/bin/g++"
    CXX1XFLAGS="-O2"
    CXX1XPICFLAGS="-fPIC"
    FC="$F77"
    FCFLAGS="$FFLAGS"
    SAFE_FFLAGS="-O"
    FCLIBS="-lfsu"
    R_LD_LIBRARY_PATH="/opt/developerstudio12.5/lib:/opt/csw/lib"
    
  14. Cross your fingers and run ./configure --with-internal-tzcode (the tzcode flag is used because that's what CRAN used). If it works, run make. If that works, go and buy a lottery ticket right now because your luck is amazing.

Other notes

Texlive

To install texlive, I ended up having to resize my virtual disk to around ~50 GB as well as resize the Solaris partition (related article: Resizing Solaris Partitions).

Debugging

To build R with debugging symbols, use this config.site:

CC="cc -xc99"
CFLAGS="-g3 -xopenmp=noopt -xlibmieee"
CPPFLAGS="-I/opt/csw/include"
LDFLAGS="-L/opt/csw/lib"
F77="f95"
FFLAGS="-g3 -xopenmp=noopt"
CXX="CC -library=stlport4"
CXXFLAGS="-g3 -xopenmp=noopt"
CXX1X="/opt/csw/bin/g++"
CXX1XFLAGS="-g3"
CXX1XPICFLAGS="-fPIC"
FC="$F77"
FCFLAGS="$FFLAGS"
SAFE_FFLAGS="-g3 -xopenmp=noopt"
FCLIBS="-lfsu"
R_LD_LIBRARY_PATH="/opt/developerstudio12.5/lib:/opt/csw/lib"

Oracle Developer Studio has a debugger called xdb. It's somewhat similar to gdb. To use it with R, run: R -d xdb. Check out the xdb manual for help on xdb commands.

Package quirks

The stringi R package needs a special configuration to build on Solaris (see this Github issue). Download the package with the download.packages() R function, then install it by running:

R CMD INSTALL --configure-args=--disable-cxx11 <package-tarball>

The Rcpp R package won't compile on Solaris using the Oracle compilers (reference). You have to use g++. Hopefully the config.site above is setup to use g++ though.

-- JeremyStephens - 05 Apr 2018
Topic revision: r4 - 27 Apr 2018, JeremyStephens
 

This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback