new_CppObject_xp .. constructor in 2.16; and how to configure TravisCI


#1

I tried to recompile

with 2.16 (after replacing # -> //) which produces the error (under Windows, locally)

Error in new_CppObject_xp(fields$.module, fields$.pointer, …) :
no valid constructor available for the argument list

Under TravisCI (https://travis-ci.org/dmenne/breathteststan, worked ok before)

g++  -I/home/travis/R-bin/lib/R/include -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/home/travis/R-bin/lib/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I"/home/travis/R/Library/Rcpp/include" -I"/home/travis/R/Library/RcppEigen/include" -I"/home/travis/R/Library/BH/include" -I"/home/travis/R/Library/StanHeaders/include" -I/home/travis/R-bin/include   -fpic  -g -O2  -c lang__ast_def.cpp -o lang__ast_def.o

In file included from /home/travis/R/Library/StanHeaders/include/src/stan/lang/ast.hpp:68:0,

                 from /home/travis/R/Library/StanHeaders/include/src/stan/lang/ast_def.cpp:7,

                 from lang__ast_def.cpp:18:

/home/travis/R/Library/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40:23: error: ISO C++ forbids initialization of member ‘has_var_’ [-fpermissive]

/home/travis/R/Library/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40:23: error: making ‘has_var_’ static [-fpermissive]

/home/travis/R/Library/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40:23: error: ISO C++ forbids in-class initialization of non-const static member ‘has_var_’

make: *** [lang__ast_def.o] Error 1

ERROR: compilation failed for package ‘rstan’

* removing ‘/home/travis/R/Library/rstan’

Internal compiler error on TravisCI when compiling Modules.cpp
#2

In tools/make_cpp.R, you need to change line 36 from

constructors = list(c("SEXP", "SEXP")), fields = character(),

to

constructors = list(c("SEXP", "SEXP", "SEXP")), fields = character(),

Error in new_CppObject_xp
#3

Works for the local Windows build. On TravisCI, the other error still exists. Any package with RStan that built before now gives

https://travis-ci.org/dmenne/breathteststan
https://travis-ci.org/dmenne/gastempt

* installing *source* package ‘rstan’ ...
** package ‘rstan’ successfully unpacked and MD5 sums checked
** libs
g++  -I/home/travis/R-bin/lib/R/include -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/home/travis/R-bin/lib/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I"/home/travis/R/Library/Rcpp/include" -I"/home/travis/R/Library/RcppEigen/include" -I"/home/travis/R/Library/BH/include" -I"/home/travis/R/Library/StanHeaders/include" -I/home/travis/R-bin/include   -fpic  -g -O2  -c chains.cpp -o chains.o

g++  -I/home/travis/R-bin/lib/R/include -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/home/travis/R-bin/lib/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I"/home/travis/R/Library/Rcpp/include" -I"/home/travis/R/Library/RcppEigen/include" -I"/home/travis/R/Library/BH/include" -I"/home/travis/R/Library/StanHeaders/include" -I/home/travis/R-bin/include   -fpic  -g -O2  -c init.cpp -o init.o

g++  -I/home/travis/R-bin/lib/R/include -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/home/travis/R-bin/lib/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I"/home/travis/R/Library/Rcpp/include" -I"/home/travis/R/Library/RcppEigen/include" -I"/home/travis/R/Library/BH/include" -I"/home/travis/R/Library/StanHeaders/include" -I/home/travis/R-bin/include   -fpic  -g -O2  -c lang__ast_def.cpp -o lang__ast_def.o

In file included from /home/travis/R/Library/StanHeaders/include/src/stan/lang/ast.hpp:68:0,

                 from /home/travis/R/Library/StanHeaders/include/src/stan/lang/ast_def.cpp:7,

                 from lang__ast_def.cpp:18:

/home/travis/R/Library/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40:23: error: ISO C++ forbids initialization of member ‘has_var_’ [-fpermissive]

/home/travis/R/Library/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40:23: error: making ‘has_var_’ static [-fpermissive]

/home/travis/R/Library/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40:23: error: ISO C++ forbids in-class initialization of non-const static member ‘has_var_’

make: *** [lang__ast_def.o] Error 1

ERROR: compilation failed for package ‘rstan’

#4

I definitely messed up the fix to a so-called bug about uninitialized bools, but I can’t actually replicate this error anywhere. Do you know what version of g++ is being used and what is in ~/.R/Makevars ?


#5

You should have access to the full log on:

https://travis-ci.org/dmenne/breathteststan

In case this should not be accessible, I can send you the file.

gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

A bit oldish, theiy are running Ubuntu 12.04.5

I tried on my own Ubuntu 16.04 server where it also failed with a current version of gcc

gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)


#6

With g++ 4.6, I get a different error from Eigen about AVX stuff. With g+±5 (specifically 5.4.1-11), it is working for me.


#7

To be sure, I tried again on my Ubuntu 16.04 server. On each g++, the error is the same, I show one below.
I reverted to 2.5.2, which worked without problems.
StanHeaders is 2.16.0.1

g++  -I/usr/share/R/include -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/usr/lib/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppEigen/include" -I"/usr/local/lib/R/site-library/BH/include" -I"/usr/local/lib/R/site-library/StanHeaders/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c lang__grammars__functions_grammar_inst.cpp -o lang__grammars__functions_grammar_inst.o
In file included from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/lang/ast.hpp:68:0,
                 from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/lang/grammars/functions_grammar_def.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/lang/grammars/functions_grammar_inst.cpp:1,
                 from lang__grammars__functions_grammar_inst.cpp:18:
/usr/local/lib/R/site-library/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40:23: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
       bool has_var_ = false;

#8

… and it works on Windows because it is still c++11 there.


#9

Okay. I would probably just add CXX_STD = CXX11 to /src/Makevars. Everybody is going to have to do that for the next version of Stan anyway.


#10

Please send me the branch to test tomorrow,.


#11

There is no branch yet. But when there is, CXX_STD = CXX11 will be required so you can go ahead and put it in src/Makevars now. It won’t hurt anything.


#12

CX11 alone in Makevars of my app does not help, since the error turns up when I build rstan on my own server and on TravisCI. So I would have to do my own branch of rstan, which is possible, but messy.

Will rollback to 2.15.2. on the server (https://apps.menne-biomed.de/gastempt/)


#13

You still get the message non-static data member initializers only available with -std=c++11 or -std=gnu++11 even after you compile under the C++11 standard?


#14

On my desktop: no, that’s Windows anyway, so C11 works.
On TravisCI and Ubuntu Server: Yes, because I have not yet made a fork where I can change Makevars.


#15

walker works fine locally and on Travis with OSX and clang, but rstan installation fails with gcc and on linux in general, where it gives the ISO C++ error regarding has_var_ as above. I have CXX_STD = CXX11 in the Makevars, and modified the make_cpp.R as well.

Build logs are here:
https://travis-ci.org/helske/walker/builds/252143579


#16

Good to have it confirmed independently. I checked your log, and it also fails during compile of rstan, not while your package was build. So your job setting of CXX11 is not relevant yet, even if it may be required once your package is created.


#17

Can you try it again after adding USE_CXX11=1 to your .travis.yml file right under CXX=clang++?


#18

USE_CXX11=1 under way. I am using the simplified syntax for yml, hope it works.

I tried to build under r-hub, but build fails because of another minor issue

https://github.com/r-hub/rhub/issues/85#issuecomment-314395550

Added to rstan issues even if it may be in package remotes.


#19

No luck. I am using native R build with the simplified syntax, so this might be a limitation; log file shows that global options are set, but I do not not if these are honored.
My yml: https://github.com/dmenne/breathteststan/blob/master/.travis.yml

env:
- CXX=clang++ USE_CXX11=1

language: r
sudo: false
cache: packages
latex: false

Error Message same a before when building Stan

/node/conditional_op.hpp:40:23: sorry, unimplemented: non-static data member initializers
/home/travis/R/Library/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40:23: error: ISO C++ forbids in-class initialization of non-const static member ‘has_var_’

make: *** [lang__ast_def.o] Error 1

ERROR: compilation failed for package ‘rstan’

* removing ‘/home/travis/R/Library/rstan’

#20

It is strange that it compiles as g++ -std=gnu++0x ... i.e. it picks up the USE_CXX11 flag but does not use clang++ to compile. And this version of g++ seems not to have implemented enough of the C++11 standard to avoid the compiler error.