AndriSignorell / DescTools

Tools for Descriptive Statistics and Exploratory Data Analysis
http://andrisignorell.github.io/DescTools/
86 stars 18 forks source link

Error installing from sources on RHEL 8 #135

Closed albertus82 closed 5 months ago

albertus82 commented 8 months ago

Hi, I'm failing to build successfully from sources under Red Hat Enterprise Linux 8:

R version 4.3.2 (2023-10-31) -- "Eye Holes"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)
begin installing package DescTools
make: *** [Makefile:50: DescTools.ts] Error 1
make: Target 'all' not remade because of errors.
* installing *source* package 'DescTools' ...
** package 'DescTools' successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C compiler: 'gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20)'
using Fortran compiler: 'GNU Fortran (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20)'
using C++ compiler: 'g++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20)'
using C++17
make[1]: Entering directory '/tmp/Rtmp8ZZnwK/R.INSTALLe5cb15978f00/DescTools/src'
gcc -I"/usr/include/R" -DNDEBUG  -I'/usr/lib64/R/library/Rcpp/include' -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  -c ADinf.c -o ADinf.o
gcc -I"/usr/include/R" -DNDEBUG  -I'/usr/lib64/R/library/Rcpp/include' -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  -c AnDarl.c -o AnDarl.o
g++ -std=gnu++17 -I"/usr/include/R" -DNDEBUG  -I'/usr/lib64/R/library/Rcpp/include' -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++17 -I"/usr/include/R" -DNDEBUG  -I'/usr/lib64/R/library/Rcpp/include' -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  -c aux_fct.cpp -o aux_fct.o
aux_fct.cpp: In function 'Rcpp::List n_pow_sum(Rcpp::NumericVector)':
aux_fct.cpp:205:23: error: 'reduce' is not a member of 'std'
   double mean =  std::reduce(x.begin(), x.end(), 0.0, std::plus<double>()) / x.size();
                       ^~~~~~
aux_fct.cpp:205:23: note: suggested alternative: 'replace'
   double mean =  std::reduce(x.begin(), x.end(), 0.0, std::plus<double>()) / x.size();
                       ^~~~~~
                       replace
make[1]: *** [/usr/lib64/R/etc/Makeconf:200: aux_fct.o] Error 1
make[1]: Leaving directory '/tmp/Rtmp8ZZnwK/R.INSTALLe5cb15978f00/DescTools/src'
ERROR: compilation failed for package 'DescTools'
* removing '/usr/lib64/R/library/DescTools'

The downloaded source packages are in
    '/tmp/RtmpfBL1md/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' ...> 
> 
 done
Warning message:
In install.packages("DescTools" :
  installation of package 'DescTools' failed

Thank you for your support.

YvesMarieLeDrogoff commented 8 months ago

Hi, I am also running on RHEL8 after we've upgraded our system and we are facing the same issue on R 4.3.0 or R 4.2.0. Regards, Yves-Marie

albertus82 commented 8 months ago

I curcumvented this problem installing an older version of the package, but obviously this cannot be considered a long-term solution:

install.packages("https://cran.r-project.org/src/contrib/Archive/DescTools/DescTools_0.99.52.tar.gz", repos=NULL, type="source")

I see that v0.99.54 was published on 2024-02-03, but compilation keeps failing with the same error.

AndriSignorell commented 8 months ago

Hmm, this is apparently a compiler problem in linux. If this persists, I will go back to "accumulate" instead of "reduce" (which proved to be a little bit faster...). Can you please make sure, that you have the most current compilers available in your environment?

albertus82 commented 7 months ago

Hi, the OS minor version is up-to-date and I applied all the available updates (dnf upgrade), but gcc version is the one you can see in the log. In recent days I have installed hundreds of R packages with this configuration and sadly this is the only one that I cannot compile successfully. I could try installing some Developer Toolset to use a different version of gcc than the system version, but I'm not sure if that's a good idea Thank you for your kind support.

AndriSignorell commented 7 months ago

Hm, the package is compiled on CRAN without any errors: image

I have also checked the function, it is about five times faster than the potential replacement "accumulate". So I will stick to it.

But what you can try is to simply replace the std:reduce function in the function "List n_pow_sum(NumericVector x)" (file aux_fct.cpp) double mean = std::reduce(x.begin(), x.end(), 0.0, std::plus()) / x.size(); by double mean = std::accumulate(x.begin(), x.end(), 0.0, std::plus()) / x.size();

which should work for older versions too. Also try:

library("Rcpp")

cppFunction("
  double SumAccu(NumericVector x) {
     return std::accumulate(x.begin(), x.end(), 0.0, std::plus<double>());
  }")

cppFunction("
  double SumReduce(NumericVector x) {
     return std::reduce(x.begin(), x.end(), 0.0, std::plus<double>());
  }")

x <- runif(100)
SumReduce(x)
SumAccu(x)
AndriSignorell commented 5 months ago

Can we close this issue?

albertus82 commented 5 months ago

I cannot upgrade from RHEL 8 to 9 at this moment, so I must install v0.99.52 manually. I think you can close this as "Won't fix", thanks.

AndriSignorell commented 5 months ago

Ok, good luck anyway!