Getting stuck with ld.exe on Windows 10 using rstantools in a package

Dear all,

I am working on a package using rstantools. It compiles perfectly fine and fast enough (~1min) on linux but gets stuck on Windows (10) when linking (aborted ld.exe after 30 min). The Windows toolchain is set up correctly. I can compile the very same stan model using rstan::stan_model() directly.

There seems to be an MD5 mismatch for my RCppParallel, installation it from source fails. I wonder whether that can be the issue if compiling directly from an interactive session works though.

Any ideas what could be the issue?

Thanks!

  • OS Win10/CentOS
  • RStan Version 2.21.15, rstantools: 2.2.0

src/Makevars.win:

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_STD = CXX14

CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2

devtools::session_info("rstan")

- Session info -------------------------------------------------------------------------------------------------------------
 setting  value
 version  R version 4.1.2 (2021-11-01)
 os       Windows 10 x64 (build 19042)
 system   x86_64, mingw32
 ui       RStudio
 language en_US.utf8
 collate  English_United States.1252
 ctype    English_United States.1252
 tz       -----------
 date     2022-07-24
 rstudio  2021.09.1+372 Ghost Orchid (desktop)
 pandoc   NA

- Packages -----------------------------------------------------------------------------------------------------------------
 ! package      * version   date (UTC) lib source
   backports      1.4.1     2021-12-13 [1] CRAN (R 4.1.2)
   BH             1.78.0-0  2021-12-15 [1] CRAN (R 4.1.2)
   callr          3.7.0     2021-04-20 [1] CRAN (R 4.1.2)
   checkmate      2.1.0     2022-04-21 [1] CRAN (R 4.1.3)
   cli            3.2.0     2022-02-14 [1] CRAN (R 4.1.2)
   colorspace     2.0-3     2022-02-21 [1] CRAN (R 4.1.3)
   crayon         1.5.1     2022-03-26 [1] CRAN (R 4.1.3)
   desc           1.4.1     2022-03-06 [1] CRAN (R 4.1.3)
   digest         0.6.29    2021-12-01 [1] CRAN (R 4.1.2)
   ellipsis       0.3.2     2021-04-29 [1] CRAN (R 4.1.2)
   fansi          1.0.3     2022-03-24 [1] CRAN (R 4.1.3)
   farver         2.1.0     2021-02-28 [1] CRAN (R 4.1.2)
   ggplot2      * 3.3.6     2022-05-03 [1] CRAN (R 4.1.2)
   glue           1.6.2     2022-02-24 [1] CRAN (R 4.1.3)
   gridExtra      2.3       2017-09-09 [1] CRAN (R 4.1.2)
   gtable         0.3.0     2019-03-25 [1] CRAN (R 4.1.2)
   inline         0.3.19    2021-05-31 [1] CRAN (R 4.1.2)
   isoband        0.2.5     2021-07-13 [1] CRAN (R 4.1.2)
   labeling       0.4.2     2020-10-20 [1] CRAN (R 4.1.1)
   lattice        0.20-41   2020-04-02 [1] CRAN (R 4.1.2)
   lifecycle      1.0.1     2021-09-24 [1] CRAN (R 4.1.2)
   loo            2.5.1     2022-03-24 [1] CRAN (R 4.1.3)
   magrittr       2.0.3     2022-03-30 [1] CRAN (R 4.1.3)
   MASS           7.3-54    2021-05-03 [2] CRAN (R 4.1.2)
   Matrix         1.4-1     2022-03-23 [1] CRAN (R 4.1.3)
   matrixStats    0.62.0    2022-04-19 [1] CRAN (R 4.1.3)
   mgcv           1.8-38    2021-10-06 [2] CRAN (R 4.1.2)
   munsell        0.5.0     2018-06-12 [1] CRAN (R 4.1.2)
   nlme           3.1-153   2021-09-07 [2] CRAN (R 4.1.2)
   pillar         1.7.0     2022-02-01 [1] CRAN (R 4.1.2)
   pkgbuild       1.3.1     2021-12-20 [1] CRAN (R 4.1.2)
   pkgconfig      2.0.3     2019-09-22 [1] CRAN (R 4.1.2)
   prettyunits    1.1.1     2020-01-24 [1] CRAN (R 4.1.2)
   processx       3.5.2     2021-04-30 [1] CRAN (R 4.1.2)
   ps             1.6.0     2021-02-28 [1] CRAN (R 4.1.2)
   R6             2.5.1     2021-08-19 [1] CRAN (R 4.1.3)
   RColorBrewer   1.1-3     2022-04-03 [1] CRAN (R 4.1.3)
   Rcpp           1.0.8.3   2022-03-17 [1] CRAN (R 4.1.3)
   RcppEigen      0.3.3.9.2 2022-04-08 [1] CRAN (R 4.1.3)
 D RcppParallel   5.1.5     2022-01-05 [1] CRAN (R 4.1.3)
   rlang          1.0.2     2022-03-04 [1] CRAN (R 4.1.3)
   rprojroot      2.0.3     2022-04-02 [1] CRAN (R 4.1.3)
   rstan        * 2.21.5    2022-04-11 [1] CRAN (R 4.1.3)
   scales         1.2.0     2022-04-13 [1] CRAN (R 4.1.3)
   StanHeaders  * 2.21.0-7  2020-12-17 [1] CRAN (R 4.1.2)
   tibble         3.1.6     2021-11-07 [1] CRAN (R 4.1.2)
   utf8           1.2.2     2021-07-24 [1] CRAN (R 4.1.2)
   vctrs          0.4.1     2022-04-13 [1] CRAN (R 4.1.3)
   viridisLite    0.4.0     2021-04-13 [1] CRAN (R 4.1.2)
   withr          2.5.0     2022-03-03 [1] CRAN (R 4.1.3)

 [1] C:/Users/------/Documents/R/4.1.2
 [2] C:/Program Files/R/R-4.1.2/library

 D -- DLL MD5 mismatch, broken installation.

----------------------------------------------------------------------------------------------------------------------------

Do you have the package source available somewhere (github or similar) that I can have a look at to debug?