Compiler Problem (rstan, Win10, 64)

Hi, I just tried for a few hours to install rstan on a new computer (Win10, 64bit). On my old machine everthing worked fine, but now I can’t get the 8school example running.

I get (as obviously quite a lot of people before me) the following error message:

fit ← stan(file = ‘8schools.stan’, data = schools_dat)
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from C:/R/R-3.5.2/library/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from C:/R/R-3.5.2/library/BH/include/boost/random/detail/int_float_pair.hpp:26,
from C:/R/R-3.5.2/library/BH/include/boost/random/exponential_distribution.hpp:27,
from C:/R/R-3.5.2/library/BH/include/boost/random/gamma_distribution.hpp:25,
from C:/R/R-3.5.2/library/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from C:/R/R-3.5.2/library/StanHeaders/include/stan/math/prim/mat.hpp:276,
from C:/R/R-3.5.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
from C:/R/R-3.5.2/library/StanHeaders/include/stan/math.hpp:4,
from C:/R/R-3.5.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file1f081362874.cpp:8:
C:/R/R-3.5.2/library/BH/include/boost
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/R/R-35~1.2/bin/x64/R CMD SHLIB file1f081362874.cpp 2> file1f081362874.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

However I tried all suggested solutions I found (e.g. avoiding folder-names containing spaces, updating BH, …) and still cannot solve this. Any suggestion is highly welcome!

rstan version: 2.18.2
StanHeaders version: 2.18.1
BH version: 1.69.0-1
Rtools version 3.5.0.4

Thanks,
Andreas

Try

sm <- stan_model('8schools.stan', verbose = TRUE)

and then tell us what is the full line that contains error: (with the colon).

Hi,

I got the exactly same problem as Andeas reported above.

I tried
sm <- stan_model('8schools.stan', verbose = TRUE)

and the error is:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/Administrator/Documents/R/win-library/3.5/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from C:/Users/Administrator/Documents/R/win-library/3.5/BH/include/boost/random/detail/int_float_pair.hpp:26,
from C:/Users/Administrator/Documents/R/win-library/3.5/BH/include/boost/random/exponential_distribution.hpp:27,
from C:/Users/Administrator/Documents/R/win-library/3.5/BH/include/boost/random/gamma_distribution.hpp:25,
from C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/stan/math/prim/mat.hpp:276,
from C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:12,
from C:/Users/Administrator/Docum

What would be the next?

Thanks,
Yuxin

That part is just a compiler warning. If you scroll farther up there should be something that contains error:.

This?

Compilation argument:
C:/PROGRA~1/R/R-35~1.2/bin/x64/R CMD SHLIB file2950527516f3.cpp 2> file2950527516f3.cpp.err.txt
c:/Rtools/mingw_64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -I"C:/Users/Administrator/Documents/R/win-library/3.5/Rcpp/include/" -I"C:/Users/Administrator/Documents/R/win-library/3.5/RcppEigen/include/" -I"C:/Users/Administrator/Documents/R/win-library/3.5/RcppEigen/include/unsupported" -I"C:/Users/Administrator/Documents/R/win-library/3.5/BH/include" -I"C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/src/" -I"C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/" -I"C:/Users/Administrator/Documents/R/win-library/3.5/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -std=c++1y -march=core2 -O3 -march=native -mtune=native -c file2950527516f3.cpp -o file2950527516f3.o
In file included from C:/Users/Administrator/Documents/R/win-library/3.5/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from C:/Users/Administrator/Documents/R/win-library/3.5/BH/include/boost/random/detail/int_float_pair.hpp:26,
from C:/Users/Administrator/Documents/R/win-library/3.5/BH/include/boost/random/exponential_distribution.hpp:27,
from C:/Users/Administrator/Documents/R/win-library/3.5/BH/include/boost/random/gamma_distribution.hpp:25,
from C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/stan/math/prim/mat.hpp:276,
from C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:12,
from C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/stan/math.hpp:4,
from C:/Users/Administrator/Documents/R/win-library/3.5/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file2950527516f3.cpp:8:
C:/Users/Administrator/Documents/R/win-library/3.5/BH/include/boost/pending/integer_log2.hpp:7:89: note: #pragma message: This header is deprecated. Use <boost/integer/integer_log2.hpp> instead.
BOOST_HEADER_DEPRECATED(“<boost/integer/integer_log2.hpp>”);
^
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s: Assembler messages:
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:16377: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:81112: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:81114: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:81116: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:106410: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:156074: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:171490: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:171492: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:171494: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:186448: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:186450: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:186452: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:186454: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:186456: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:186458: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:186460: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:204161: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:204163: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:204165: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:204167: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:204169: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:204171: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:204173: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:244941: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:244943: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:244945: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:244947: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:246413: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:246415: Error: invalid register for .seh_savexmm
C:\Users\ADMINI~1\AppData\Local\Temp\ccISY7hp.s:246417: Error: invalid register for .seh_savexmm
make: *** [C:/PROGRA~1/R/R-35~1.2/etc/x64/Makeconf:215: file2950527516f3.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Yeah, that error message. I have no idea what it means but there are only about 25 hits if you Google for “Error: invalid register for .seh_savexmm”.

Hi bgoodri, thanks for your fast response, and sorry for my delay: The flu knocked my out…
So, with verbose I get the following errors:

C:\Users\ANDREA~1.VOS\AppData\Local\Temp\ccI7Mbnb.s: Assembler messages:
C:\Users\ANDREA~1.VOS\AppData\Local\Temp\ccI7Mbnb.s:65088: Error: invalid register for .seh_savexmm
C:\Users\ANDREA~1.VOS\AppData\Local\Temp\ccI7Mbnb.s:65090: Error: invalid register for .seh_savexmm
C:\Users\ANDREA~1.VOS\AppData\Local\Temp\ccI7Mbnb.s:69428: Error: invalid register for .seh_savexmm
C:\Users\ANDREA~1.VOS\AppData\Local\Temp\ccI7Mbnb.s:133071: Error: invalid register for .seh_savexmm
C:\Users\ANDREA~1.VOS\AppData\Local\Temp\ccI7Mbnb.s:148354: Error: invalid register for .seh_savexmm
C:\Users\ANDREA~1.VOS\AppData\Local\Temp\ccI7Mbnb.s:148356: Error: invalid register for .seh_savexmm
make: *** [C:/R/R-35~1.2/etc/x64/Makeconf:215: file6781ce83754.o] Error 1

Can you make sense of it?

No, but it appears to be the same errors as @Yuxin got.

Ok, as far as I understand the comments of other people having this issue, the C-compiler does not work for some processors with some optimization flags in the 64 bit version.

So, a work-around would be to change the compiler flags for optimization, or to go for 32 bit version. Is either possible in rstan?

I would try changing the flags before trying to load a 32 bit shared library on a 64 bit OS. In particular, I would try not doing -march=native.

Great! Leaving out “-march=native” did the trick! Thanks a lot!

1 Like

It also works for me! Thanks, Ben and Andreas.

It does not help me. No matter what I do (including deletion of Makevars.win), I am getting the same error:
Error: invalid register for .seh_savexmm

This is on Windows 10, rstan 2.19.2, R 3.61, rtools 3.5 (64 bit)

That is probably related to setting -mtune=native and / or -march=native by environmental variables and it not working for your processor.

Hi,
But I tried removal of -march=native from my Makevars.win, even deleted this file. No change.
Is this issue with rtools3.5?

Probably not. RTools 3.5 works more reliably than 3.4, etc. You might try adding -fno-asynchronous-unwind-tables to the CXX11FLAGS or any of the other things when you google for “Error: invalid register for .seh_savexmm”.