r-hub / solarischeck

Scripts to R CMD check an R package on Solaris
11 stars 0 forks source link

Is it the same version of GCC? #8

Closed boennecd closed 3 years ago

boennecd commented 3 years ago

Firstly, thank you for putting all of this together. Although I have not reproduced the error on CRAN yet with my package, it would have taken me forever to do.

At https://blog.r-hub.io/2020/05/14/checking-your-r-package-on-solaris/ you state that:

CRAN uses two sets of compilers for their R package checks. Oracle Developer Studio (ODS) is a commercial product that supports Oracle Solaris 10. In addition, OpenCSW packages GCC, version 5.5.0 currently.

But this is not what CRAN state. They write:

Where these compilers cannot be used, use GCC 5.2.0 from OpenCSW, with config.site:

suggesting that CRAN are still using gcc5core-5.2.0,REV=2015.07.31.

The reason I came across this is that my mdgc package works fine with rhub::check("solaris-x86-patched") and on the VirtualBox setup using your guide but some of the tests gives different results but only CRAN's Solaris check. I am linking with Rcpp and thus assume that CRAN are using GCC.

The package works on all other combinations of platforms, compilers, and compiler/config flags.

gaborcsardi commented 3 years ago

You are right, they might not be the same. OTOH, I would be very surprised if it really caused this. TBH I am not even sure that linking to Rcpp still triggers the GCC compilers.

I suggest you go the easy path and skip these tests and this example on Solaris.

boennecd commented 3 years ago

Thank you for the quick reply.

TBH I am not even sure that linking to Rcpp still triggers the GCC compilers.

CRAN still notes that

This is used for packages linking to Rcpp/RcppEigen, rgdal/sf (GDAL is only compilable with g++) and about 40 others.

OTOH, I would be very surprised if it really caused this.

True.

I suggest you go the easy path and skip these tests and this example on Solaris.

This will require that I do not run almost all tests and examples it seems when it is on Solaris. I will have to figure something out.

gaborcsardi commented 3 years ago

This will require that I do not run almost all tests and examples it seems when it is on Solaris.

Which is completely fine.

gaborcsardi commented 3 years ago

@boennecd Let me know if you managed to update your package.

boennecd commented 3 years ago

I will update you. Thank you for the help. I did not know that I could simply disable almost everything in the test and examples.

boennecd commented 3 years ago

I failed to fix the error on CRAN. I have also tried to make a setup closer to that on CRAN. Though, I run into an issue like this one on SO with the using statements in /usr/include/math.h when I attempt to install e.g. Rcpp with install.packages.

Here is the code I used on in the VirtualBox:

sudo pkgrm CSWgcc5g++
sudo pkgrm CSWgcc5gfortran
sudo pkgrm CSWgcc5core

cd /tmp
wget http://mirror.opencsw.org/opencsw/allpkgs/gcc5core-5.2.0%2cREV%3d2015.07.31-SunOS5.10-i386-CSW.pkg.gz
gunzip gcc5core-5.2.0,REV=2015.07.31-SunOS5.10-i386-CSW.pkg.gz
sudo pkgadd -d gcc5core-5.2.0,REV=2015.07.31-SunOS5.10-i386-CSW.pkg

wget http://mirror.opencsw.org/opencsw/allpkgs/gcc5gfortran-5.2.0%2cREV%3d2015.07.31-SunOS5.10-i386-CSW.pkg.gz
gunzip gcc5gfortran-5.2.0,REV=2015.07.31-SunOS5.10-i386-CSW.pkg.gz
sudo pkgadd -d gcc5gfortran-5.2.0,REV=2015.07.31-SunOS5.10-i386-CSW.pkg

wget http://mirror.opencsw.org/opencsw/allpkgs/gcc5g%2b%2b-5.2.0%2cREV%3d2015.07.31-SunOS5.10-i386-CSW.pkg.gz
gunzip gcc5g++-5.2.0,REV=2015.07.31-SunOS5.10-i386-CSW.pkg.gz
sudo pkgadd -d gcc5g++-5.2.0,REV=2015.07.31-SunOS5.10-i386-CSW.pkg

wget http://mirror.opencsw.org/opencsw/allpkgs/libisl10-0.18.2%2cREV%3d2014.03.16-SunOS5.9-i386-CSW.pkg.gz
gunzip libisl10-0.18.2,REV=2014.03.16-SunOS5.9-i386-CSW.pkg.gz
sudo pkgadd -d libisl10-0.18.2,REV=2014.03.16-SunOS5.9-i386-CSW.pkg

sudo pkgutil -y -i libreadline_dev
sudo pkgutil -y -i libz_dev
sudo pkgutil -y -i liblzma_dev 
sudo pkgutil -y -i libpcre_dev 
sudo pkgutil -y -i libpcre2_dev 

sudo mkdir /usr/local
sudo mkdir /usr/local/include

wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
gunzip libiconv-1.16.tar.gz
tar xvf libiconv-1.16.tar

cd libiconv-1.16
./configure --prefix=/usr/local
make
sudo make install

cd /tmp
wget https://stat.ethz.ch/R/daily/R-patched.tar.gz
gunzip R-patched.tar.gz
tar xvf R-patched.tar
cd R-patched
tools/rsync-recommended
./configure \
  CC="/opt/csw/bin/gcc-5.2" \
  CXX="/opt/csw/bin/g++-5.2" \
  CPPFLAGS="-I/opt/csw/include -I/usr/local/include" \
  FC="/opt/csw/bin/gfortran-5.2" \
  CFLAGS="-O2" \
  FFLAGS="-O2" \
  CXXFLAGS="-O2" \
  LDFLAGS="-L/usr/local/lib -L/opt/csw/lib" \
  --with-internal-tzcode \
  R_LD_LIBRARY_PATH="/usr/local/lib:/opt/csw/lib:/opt/developerstudio12.6/lib:/usr/openwin/lib" \
  --prefix=/opt/R-gcc-5-2
make
sudo make install

cd ~
mkdir ~/R-user-lib
export R_LIBS_USER="~/R-user-lib"
git clone https://github.com/boennecd/mdgc

/opt/R-gcc-5-2/bin/R -e "install.packages(c('Rcpp', 'RcppArmadillo', 'testthat', 'BH', 'psqn', 'catdata'))"

I, of course, fully understand that this has nothing to do with this repository. I state it for the record.

gaborcsardi commented 3 years ago

:(

boennecd commented 3 years ago

The issue is that the gcc5@@@-5.2.0,REV=2015.07.31-SunOS5.10-i386-CSW is build with an old version of the math.h header which is updated on 27/02/16. See this discussion. The solution is to build gcc on the same machine.

Thus, I took the .ovf file from packer and ran the following to

  1. build gcc-5.2.0 as on CRAN.
  2. build R as close as possible to what is described at https://www.stats.ox.ac.uk/pub/bdr/Rconfig/r-patched-solaris-x86.
  3. R CMD checked the package.

and I still get no ERRORs. Now, I give up and disable all examples and tests on Solaris having wasted some +2 days trying to reproduce the results and having received a series of annoyed messages from CRAN.

Thank you again for the tools you are providing! It would have taken even longer if I had to do this from scratch.

For the record, here is what I did:

sudo pkgutil -y -i gtar vim git

cd /tmp
wget http://ftp.gnu.org/gnu/gcc/gcc-5.2.0/gcc-5.2.0.tar.gz
gtar -xzvf gcc-5.2.0.tar.gz

cd gcc-5.2.0
# adjust the download_prerequisites script replacing tar with gtar
vim ./contrib/download_prerequisites
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
../gcc-5.2.0/configure --prefix=/opt/gcc-5.2.0 --enable-languages=c,c++,fortran 
# I increased the number of processors I can use
gmake -j 6
sudo gmake install

cd /tmp

# check if C++ works
cat > tmp.cpp << EOF
#include <iostream>
#include <cmath>
int main()
{
    std::cout << "exp2(4) = " << std::exp2(4) << '\n';
    return 0;
}
EOF
/opt/gcc-5.2.0/bin/g++ -std=c++11 -Wall tmp.cpp

sudo pkgutil -y -i libreadline_dev libz_dev liblzma_dev libpcre_dev libpcre2_dev libcurl_dev texlive_base texlive_binaries texlive_common texlive_fonts_extra texlive_fonts_recommended texlive_latex_base texlive_latex_base_binaries texlive_latex_extra texlive_latex_extra_binaries

wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
gtar -xzvf libiconv-1.16.tar.gz
cd libiconv-1.16
./configure --prefix=/usr/local
make 
sudo make install

cd /tmp
wget https://stat.ethz.ch/R/daily/R-patched.tar.gz
gtar -xzvf R-patched.tar.gz
cd R-patched
tools/rsync-recommended
./configure \
  CC="/opt/gcc-5.2.0/bin/gcc" \
  CXX="/opt/gcc-5.2.0/bin/g++" \
  CPPFLAGS="-I/opt/gcc-5.2.0/include -I/opt/csw/include -I/usr/local/include" \
  FC="/opt/gcc-5.2.0/bin/gfortran" \
  CFLAGS="-O2" \
  FFLAGS="-O2" \
  CXXFLAGS="-O2" \
  LDFLAGS="-L/opt/gcc-5.2.0/lib -L/usr/local/lib -L/opt/csw/lib" \
  --with-internal-tzcode \
  R_LD_LIBRARY_PATH="/opt/gcc-5.2.0/lib:/usr/local/lib:/opt/csw/lib:/opt/developerstudio12.6/lib:/usr/openwin/lib" \
  --prefix=/opt/R-gcc-5-2
gmake -j 6
sudo gmake install

cd ~
mkdir ~/R-user-lib
export R_LIBS_USER="~/R-user-lib"
/opt/R-gcc-5-2/bin/R -e "install.packages(c('Rcpp', 'RcppArmadillo', 'testthat', 'BH', 'psqn', 'catdata'))"

wget https://github.com/boennecd/mdgc/archive/d131cdb45c38f2ec796fab217464deeebecf6d24.zip
unzip d131cdb45c38f2ec796fab217464deeebecf6d24.zip
mv mdgc-d131cdb45c38f2ec796fab217464deeebecf6d24 mdgc
/opt/R-gcc-5-2/bin/R CMD build mdgc
/opt/R-gcc-5-2/bin/R CMD check --as-cran --run-donttest mdgc_0.1.4.tar.gz
gaborcsardi commented 3 years ago

😞 Really sorry to hear this, so much work for nothing. But I am glad that you at least stopped trying to repro their error.