C++ compile error "too many sections" only in Rstudio

I developed a package with Rcpp and RcppEigen C++ code. The C++ backend is not large maybe 2500 lines split into 7 .cpp files. I use R 4.3.3 and R 4.6.0 (but it was checked on R latest release on GitHub, as well).

When compiling the package inside Rstudio I get a compiler error (Rtools 4.3/44 MinGW-w64) because of "too many sections". I tried different options (pkgbuild::compile_dll, pkgbuild::build, devtools::install, etc) and always had the same error.
Each file had a low section count (about 100 sections each), so nowhere near the 32,000 per .o file limit (without flag).
The only way i found to get the code compiled is adding a compiler flag -Wa -- big-object. This is a windows only flag and CRAN check fails because of it.

However, when I removed the flag and compiled the code from the shell with "R CMD build ."
It compiled without errors or warnings.

Because of this, I am beginning to think that somehow Rstudio is responsible (I can't imagine that both pckgbuild and devTools are responsible).

No web search or AI advice could give me a solution.

Any comments or suggestions?

Thanks, Marco

1 Like