I have an R-package that used to be up on CRAN that I want to resubmit. I haven’t changed any stan code, however, when I reran devtools::document()
I could not install the package.
My current error is:
C:\Users\phili\AppData\Local\Temp\ccFDqzEG.s: Assembler messages:
C:\Users\phili\AppData\Local\Temp\ccFDqzEG.s: Fatal error: can't write 87 bytes to section .text of stanExports_Exponential_expert.o: 'file too big'
as: stanExports_Exponential_expert.o: too many sections (41201)
As per this post the error is often caused by not having -O3 in the CXX14FLAGS/ CXX17FLAGS, however, I’m not sure how to add this to the Makevars files.
Below is my Makevars file where I tried a number of approaches to specify the O3, however, when I run R CMD config --all | grep CXX17
in the terminal the Flag is still O2.
STANHEADERS_SRC = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "message()" -e "cat(system.file('include', 'src', package = 'StanHeaders', mustWork = TRUE))" -e "message()" | grep "StanHeaders")
STANC_FLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "cat(ifelse(utils::packageVersion('rstan') >= 2.26, '-DUSE_STANC3',''))")
PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DRCPP_PARALLEL_USE_TBB=1 $(STANC_FLAGS)
PKG_CXXFLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::CxxFlags()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::CxxFlags()") -g -O3
PKG_LIBS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::RcppParallelLibs()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::LdFlags()")
CXX_STD = CXX17
PKG_CPPFLAGS += -D_HAS_AUTO_PTR_ETC=0
CXX11FLAGS = -g -O3
CXX14FLAGS = -g -O3
CXX17FLAGS = -g -O3
Thanks so much,
Philip
By way of update, I was able to stop the too large file error,however, it has been replaced by a new error. There still seems to be an issue with the.o file.
make: *** [C:/PROGRA~1/R/R-42~1.2/etc/x64/Makeconf:258: stanExports_Exponential_expert.o] Error 1
ERROR: compilation failed for package 'expertsurv'
─ removing 'C:/Users/phili/AppData/Local/Temp/RtmpYl3ZLP/devtools_install_4bd075716298/expertsurv'
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
My Makevar.win is now (however, I still get CXX17FLAGS = -O2 -Wall -mfpmath=sse -msse2 -mstackrealign
when I run R CMD config --all | grep CXX17
.
# Generated by rstantools. Do not edit by hand.
STANHEADERS_SRC = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "message()" -e "cat(system.file('include', 'src', package = 'StanHeaders', mustWork = TRUE))" -e "message()" | grep "StanHeaders")
STANC_FLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "cat(ifelse(utils::packageVersion('rstan') >= 2.26, '-DUSE_STANC3',''))")
PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DRCPP_PARALLEL_USE_TBB=1 $(STANC_FLAGS)
PKG_CXXFLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::CxxFlags()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::CxxFlags()")
PKG_LIBS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::RcppParallelLibs()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::LdFlags()")
CXX_STD17 = CXX17
PKG_CPPFLAGS += -D_HAS_AUTO_PTR_ETC=0 -O3
I just saw this now, but it should be something that @bgoodri or @jgabry can help with.
@Bob_Carpenter Hi Bob, no worries. I ended up compiling and saving the compiled models as “data” in my R-package. It’s obviously a bit of a hack but I think it will pass CRAN checks. Still odd that the models failed to install when nothing changed.
Philip