jwood000 / RcppAlgos

Tool for Solving Problems in Combinatorics and Computational Mathematics
GNU General Public License v2.0
44 stars 5 forks source link

Travis-CI "ERROR: compilation failed for package ‘RcppAlgos’" #6

Closed jdreyf closed 5 years ago

jdreyf commented 5 years ago

My R package jdreyf/PANTS uses RcppAlgos and R CMD check passess, but I'm getting Travis-CI errors. I have already debugged Travis-CI issues with "Error in .shlib_internal(args): C++14 standard requested but CXX14 is not defined" (http://dirk.eddelbuettel.com/blog/2017/06/13/) but am now getting:

* installing *source* package ‘RcppAlgos’ ...
** package ‘RcppAlgos’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=c++1y -fPIC  -I"/home/travis/R-bin/lib/R/include" -DNDEBUG -I../inst/include/ -I"/home/travis/R/Library/Rcpp/include" -I"/home/travis/R/Library/RcppThread/include" -I/home/travis/R-bin/include    -O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function  -Wno-macro-redefined -c CombPermUtils.cpp -o CombPermUtils.o
g++ -std=c++1y -fPIC  -I"/home/travis/R-bin/lib/R/include" -DNDEBUG -I../inst/include/ -I"/home/travis/R/Library/Rcpp/include" -I"/home/travis/R/Library/RcppThread/include" -I/home/travis/R-bin/include    -O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function  -Wno-macro-redefined -c Combinatorics.cpp -o Combinatorics.o
In file included from ../inst/include/Combinatorics.h:5:0,
                 from Combinatorics.cpp:1:
../inst/include/Permutations.h: In function ‘void PermuteGeneral(int, int, typeVector&, bool, int, std::vector<int>&, int, bool, typeMatrix&)’:
../inst/include/Permutations.h:40:24: error: ‘make_unique’ is not a member of ‘std’
         auto arrPerm = std::make_unique<int[]>(uN);
                        ^
../inst/include/Permutations.h:40:41: error: expected primary-expression before ‘int’
         auto arrPerm = std::make_unique<int[]>(uN);
                                         ^
../inst/include/Permutations.h:72:29: error: ‘make_unique’ is not a member of ‘std’
             auto indexMat = std::make_unique<int[]>(phaseOne * uR);
                             ^
../inst/include/Permutations.h:72:46: error: expected primary-expression before ‘int’
             auto indexMat = std::make_unique<int[]>(phaseOne * uR);
                                              ^
../inst/include/Permutations.h:73:28: error: ‘make_unique’ is not a member of ‘std’
             auto arrPerm = std::make_unique<int[]>(uN);
                            ^
../inst/include/Permutations.h:73:45: error: expected primary-expression before ‘int’
             auto arrPerm = std::make_unique<int[]>(uN);
                                             ^
../inst/include/Permutations.h: In function ‘void MultisetPermutation(int, int, typeVector&, int, std::vector<int>&, int, typeMatrix&)’:
../inst/include/Permutations.h:131:20: error: ‘make_unique’ is not a member of ‘std’
     auto arrPerm = std::make_unique<int[]>(lenFreqs);
                    ^
../inst/include/Permutations.h:131:37: error: expected primary-expression before ‘int’
     auto arrPerm = std::make_unique<int[]>(lenFreqs);
                                     ^
../inst/include/Permutations.h: In function ‘void PermutationApplyFun(int, int, typeVector&, bool, int, bool, std::vector<int>&, int, SEXP, SEXP, SEXPREC*&)’:
../inst/include/Permutations.h:203:24: error: ‘make_unique’ is not a member of ‘std’
         auto arrPerm = std::make_unique<int[]>(arrLength);
                        ^
../inst/include/Permutations.h:203:41: error: expected primary-expression before ‘int’
         auto arrPerm = std::make_unique<int[]>(arrLength);
                                         ^
In file included from ../inst/include/Combinatorics.h:8:0,
                 from Combinatorics.cpp:1:
../inst/include/PermuteResults.h: In function ‘void PermuteGenRes(int, int, std::vector<typeVector>&, bool, int, std::vector<int>&, long unsigned int, bool, typeMatrix&, funcPtr<typeVector>)’:
../inst/include/PermuteResults.h:45:24: error: ‘make_unique’ is not a member of ‘std’
         auto arrPerm = std::make_unique<int[]>(uN);
                        ^
../inst/include/PermuteResults.h:45:41: error: expected primary-expression before ‘int’
         auto arrPerm = std::make_unique<int[]>(uN);
                                         ^
../inst/include/PermuteResults.h:87:29: error: ‘make_unique’ is not a member of ‘std’
             auto indexMat = std::make_unique<int[]>(phaseOne * uR);
                             ^
../inst/include/PermuteResults.h:87:46: error: expected primary-expression before ‘int’
             auto indexMat = std::make_unique<int[]>(phaseOne * uR);
                                              ^
../inst/include/PermuteResults.h:88:28: error: ‘make_unique’ is not a member of ‘std’
             auto arrPerm = std::make_unique<int[]>(uN);
                            ^
../inst/include/PermuteResults.h:88:45: error: expected primary-expression before ‘int’
             auto arrPerm = std::make_unique<int[]>(uN);
                                             ^
../inst/include/PermuteResults.h: In function ‘void MultisetPermRes(int, int, std::vector<typeVector>&, int, long unsigned int, std::vector<int>&, typeMatrix&, funcPtr<typeVector>)’:
../inst/include/PermuteResults.h:150:20: error: ‘make_unique’ is not a member of ‘std’
     auto arrPerm = std::make_unique<int[]>(lenFreqs);
                    ^
../inst/include/PermuteResults.h:150:37: error: expected primary-expression before ‘int’
     auto arrPerm = std::make_unique<int[]>(lenFreqs);
                                     ^
In file included from Combinatorics.cpp:2:0:
../inst/include/CleanConvert.h: In function ‘void CleanConvert::convertVector(SEXP, std::vector<_RealType>&, std::string, bool, bool, bool)’:
../inst/include/CleanConvert.h:161:29: error: ‘make_unique’ is not a member of ‘std’
                 auto temp = std::make_unique<mpz_t[]>(total);
                             ^
../inst/include/CleanConvert.h:161:51: error: expected primary-expression before ‘[’ token
                 auto temp = std::make_unique<mpz_t[]>(total);
                                                   ^
../inst/include/CleanConvert.h:161:52: error: expected primary-expression before ‘]’ token
                 auto temp = std::make_unique<mpz_t[]>(total);
                                                    ^
In file included from /home/travis/R/Library/RcppThread/include/RcppThread.h:11:0,
                 from Combinatorics.cpp:4:
/home/travis/R/Library/RcppThread/include/RcppThread/Thread.hpp: In lambda function:
/home/travis/R/Library/RcppThread/include/RcppThread/Thread.hpp:42:19: error: parameter packs not expanded with ‘...’:
                 f(args...);
                   ^
/home/travis/R/Library/RcppThread/include/RcppThread/Thread.hpp:42:19: note:         ‘args’
/home/travis/R/Library/RcppThread/include/RcppThread/Thread.hpp:42:23: error: expansion pattern ‘args’ contains no argument packs
                 f(args...);
                       ^
In file included from /home/travis/R/Library/RcppThread/include/RcppThread.h:13:0,
                 from Combinatorics.cpp:4:
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp: In member function ‘void RcppThread::ThreadPool::push(F&&, Args&& ...)’:
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:127:31: error: expected ‘,’ before ‘...’ token
         jobs_.emplace([f, args...] { f(args...); });
                               ^
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:127:31: error: expected identifier before ‘...’ token
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:127:34: error: parameter packs not expanded with ‘...’:
         jobs_.emplace([f, args...] { f(args...); });
                                  ^
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:127:34: note:         ‘args’
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp: In lambda function:
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:127:44: error: expansion pattern ‘args’ contains no argument packs
         jobs_.emplace([f, args...] { f(args...); });
                                            ^
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp: In member function ‘std::future<decltype (f(args ...))> RcppThread::ThreadPool::pushReturn(F&&, Args&& ...)’:
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:144:54: error: expected ‘,’ before ‘...’ token
     auto job = std::make_shared<jobPackage>([&f, args...] {
                                                      ^
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:144:54: error: expected identifier before ‘...’ token
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:144:57: error: parameter packs not expanded with ‘...’:
     auto job = std::make_shared<jobPackage>([&f, args...] {
                                                         ^
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:144:57: note:         ‘args’
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp: In lambda function:
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:145:22: error: expansion pattern ‘args’ contains no argument packs
         return f(args...);
                      ^
Combinatorics.cpp: In function ‘typeRcpp CombinatoricsConstraints(int, int, std::vector<typeVector>&, bool, std::string, std::vector<std::basic_string<char> >, std::vector<typeVector>, int, bool, bool, std::vector<int>&, bool)’:
Combinatorics.cpp:313:32: error: ‘make_unique’ is not a member of ‘std’
             auto indexMatrix = std::make_unique<int[]>(indexRows * r);
                                ^
Combinatorics.cpp:313:49: error: expected primary-expression before ‘int’
             auto indexMatrix = std::make_unique<int[]>(indexRows * r);
                                                 ^
In file included from /home/travis/R/Library/RcppThread/include/RcppThread.h:13:0,
                 from Combinatorics.cpp:4:
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp: In instantiation of ‘struct RcppThread::ThreadPool::push(F&&, Args&& ...) [with F = std::reference_wrapper<void(int, int, std::vector<int>, bool, int, bool, std::vector<int>, std::vector<int>, std::vector<int>, bool, bool, int (*)(const std::vector<int>&, long unsigned int), bool, RcppParallel::RMatrix<int>&, int)>; Args = {int&, int&, std::vector<int, std::allocator<int> >&, bool&, int&, bool&, std::vector<int, std::allocator<int> >&, std::vector<int, std::allocator<int> >&, std::vector<int, std::allocator<int> >&, bool&, bool&, int (*&)(const std::vector<int, std::allocator<int> >&, long unsigned int), bool&, std::reference_wrapper<RcppParallel::RMatrix<int> >, int&}]::__lambda5’:
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:127:9:   required from ‘void RcppThread::ThreadPool::push(F&&, Args&& ...) [with F = std::reference_wrapper<void(int, int, std::vector<int>, bool, int, bool, std::vector<int>, std::vector<int>, std::vector<int>, bool, bool, int (*)(const std::vector<int>&, long unsigned int), bool, RcppParallel::RMatrix<int>&, int)>; Args = {int&, int&, std::vector<int, std::allocator<int> >&, bool&, int&, bool&, std::vector<int, std::allocator<int> >&, std::vector<int, std::allocator<int> >&, std::vector<int, std::allocator<int> >&, bool&, bool&, int (*&)(const std::vector<int, std::allocator<int> >&, long unsigned int), bool&, std::reference_wrapper<RcppParallel::RMatrix<int> >, int&}]’
Combinatorics.cpp:974:106:   required from here
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:127:27: error: using invalid field ‘RcppThread::ThreadPool::push(F&&, Args&& ...)::__lambda5::__args’
         jobs_.emplace([f, args...] { f(args...); });
                           ^
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp: In instantiation of ‘struct RcppThread::ThreadPool::push(F&&, Args&& ...) [with F = std::reference_wrapper<void(int, int, std::vector<double>, bool, int, bool, std::vector<int>, std::vector<int>, std::vector<int>, bool, bool, double (*)(const std::vector<double>&, long unsigned int), bool, RcppParallel::RMatrix<double>&, int)>; Args = {int&, int&, std::vector<double, std::allocator<double> >&, bool&, int&, bool&, std::vector<int, std::allocator<int> >&, std::vector<int, std::allocator<int> >&, std::vector<int, std::allocator<int> >&, bool&, bool&, double (*&)(const std::vector<double, std::allocator<double> >&, long unsigned int), bool&, std::reference_wrapper<RcppParallel::RMatrix<double> >, int&}]::__lambda5’:
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:127:9:   required from ‘void RcppThread::ThreadPool::push(F&&, Args&& ...) [with F = std::reference_wrapper<void(int, int, std::vector<double>, bool, int, bool, std::vector<int>, std::vector<int>, std::vector<int>, bool, bool, double (*)(const std::vector<double>&, long unsigned int), bool, RcppParallel::RMatrix<double>&, int)>; Args = {int&, int&, std::vector<double, std::allocator<double> >&, bool&, int&, bool&, std::vector<int, std::allocator<int> >&, std::vector<int, std::allocator<int> >&, std::vector<int, std::allocator<int> >&, bool&, bool&, double (*&)(const std::vector<double, std::allocator<double> >&, long unsigned int), bool&, std::reference_wrapper<RcppParallel::RMatrix<double> >, int&}]’
Combinatorics.cpp:1023:105:   required from here
/home/travis/R/Library/RcppThread/include/RcppThread/ThreadPool.hpp:127:27: error: using invalid field ‘RcppThread::ThreadPool::push(F&&, Args&& ...)::__lambda5::__args’
At global scope:
cc1plus: warning: unrecognized command line option "-Wno-macro-redefined" [enabled by default]
make: *** [Combinatorics.o] Error 1
ERROR: compilation failed for package ‘RcppAlgos’
* removing ‘/home/travis/R/Library/RcppAlgos’
Error in i.p(...) : 
  (converted from warning) installation of package ‘RcppAlgos’ had non-zero exit status
Calls: <Anonymous> ... with_rprofile_user -> with_envvar -> force -> force -> i.p
Execution halted
The command "Rscript -e 'deps <- remotes::dev_package_deps(dependencies = NA);remotes::install_deps(dependencies = TRUE);if (!all(deps$package %in% installed.packages())) { message("missing: ", paste(setdiff(deps$package, installed.packages()), collapse=", ")); q(status = 1, save = "no")}'" failed and exited with 1 during .
Your build has been stopped.

My Travis YML file is:

language: r
script: ./travis-config.bash
sudo: false
warnings_are_errors: false
cache: packages
r_github_packages: jdreyf/ezlimma
bioc_packages: limma
# from https://github.com/stan-dev/rstan/issues/569
before_install:
  - mkdir -p ~/.R
  - echo "CXX14FLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function  -Wno-macro-redefined" >> ~/.R/Makevars
  - echo "CXX14=g++ -std=c++1y -fPIC" >> ~/.R/Makevars
  - Rscript -e 'update.packages(ask = FALSE)'
output:
    pdf_document:
        latex_engine: xelatex
after_success:
- Rscript -e 'covr::codecov()'

Thanks for this valuable package.

jwood000 commented 5 years ago

@jdreyf,

First off, thanks for the feedback. Secondly, those errors signify that >= C++14 is not being utilized. As cppreference states, std::make_unique was not available until C++14.

The downstream errors that occur in RcppThread are probably not really errors and shouldn't concern you. They will probably disappear after the first errors are corrected. Generally, you should start debugging C++ code from the top as mentioned here cprogramming.

As you have already pointed out, Travis CI doesn't play well with anything requiring C++14. In the article you linked it recommended using at least g++-6 which uses C++14 by default (N.B. you have only specified g++).

I haven't tried this yet, but I think if you correct the compiler, these errors should go away.

When I get a chance, I will try to implement this fix and let you know what happens.

Thanks, Joseph Wood

jdreyf commented 5 years ago

Turns out it was better to remove the script from http://dirk.eddelbuettel.com/blog/2017/06/13/ & instead add instruction to install g++-6 in the Travis YML (I hadn't known how to do this before; https://thecoatlessprofessor.com/programming/selecting-an-alternative-compiler-for-r-package-testing-on-travis-ci), and now my package passes Travis-CI. Here's the new Travis YML:

language: r
sudo: required
warnings_are_errors: false
cache: packages
r_github_packages: jdreyf/ezlimma
bioc_packages: limma
# https://thecoatlessprofessor.com/programming/selecting-an-alternative-compiler-for-r-package-testing-on-travis-ci/
# makevars: https://github.com/stan-dev/rstan/issues/569
before_install:
  - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6
  - Rscript -e 'update.packages(ask = FALSE)'
  - mkdir -p ~/.R
  - echo "CXX14FLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function  -Wno-macro-redefined" >> ~/.R/Makevars
  - echo "CXX14=g++ -std=c++1y -fPIC" >> ~/.R/Makevars
addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-6
output:
    pdf_document:
        latex_engine: xelatex
after_success:
- Rscript -e 'covr::codecov()'

Thanks again for your response & excellent package!