Error `file too big`

143 views
Skip to first unread message

James Thorson

unread,
Jan 27, 2023, 5:10:27 PM1/27/23
to us...@tmb-project.org
  Hi all,

I'm building a new package, and encountering an error when compiling a TMB CPP during a call to `devtools::document()` but not when using `compile`.  The error is also avoided when the TMB CPP is already compiled in my local directory (presumably because the compilation is then skipped).  The specific terminal output is below, along with a screengrab in case that's easier to read.

Does anyone have experience with fixing this `devtools::document()` error message?

Thanks,
jim

image.png

> devtools::document()
ℹ Updating phylosem documentation
ℹ Loading phylosem
ℹ Re-compiling phylosem (debug build)
── R CMD INSTALL ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 
─  installing *source* package 'phylosem' ...

 
   ** using staged installation

 
   ** libs

 
   g++ -std=gnu++11  -I"C:/Users/James.Thorson/AppData/Local/Programs/R/R-4.2.2/include" -DNDEBUG  -I'C:/Users/James.Thorson/Desktop/Work files/Software/MRAN/TMB/include' -I'C:/Users/James.Thorson/Desktop/Work files/Software/MRAN/RcppEigen/include'   -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall -gdwarf-2 -mfpmath=sse -msse2 -mstackrealign  -UNDEBUG -Wall -pedantic -g -O0 -c phylosem.cpp -o phylosem.o

 
a
 
   as: phylosem.o: too many sections (52598)
   C:\Users\JAMES~1.THO\AppData\Local\Temp\ccAkjNpi.s: Assembler messages:
   C:\Users\JAMES~1.THO\AppData\Local\Temp\ccAkjNpi.s: Fatal error: can't write 315 bytes to section .text of phylosem.o: 'file too big'

 
a
 
   as: phylosem.o: too many sections (52598)
   C:\Users\JAMES~1.THO\AppData\Local\Temp\ccAkjNpi.s: Fatal error: phylosem.o: file too big

 
   make: *** [C:/Users/James.Thorson/AppData/Local/Programs/R/R-4.2.2/etc/x64/Makeconf:260: phylosem.o] Error 1

 
   ERROR: compilation failed for package 'phylosem'

 
─  removing 'C:/Users/JAMES~1.THO/AppData/Local/Temp/RtmpMxwlMH/devtools_install_48b8b631b20/phylosem'

Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Type .Last.error to see the more details.
Warning message:
roxygen2 requires Encoding: "UTF-8"
ℹ Current encoding is NA 

Andrea Havron

unread,
Jan 27, 2023, 5:54:54 PM1/27/23
to James Thorson, us...@tmb-project.org
Hi Jim,

I've run into this error before with devtools::check(). When looking into the issue, I found that devtools::check() will compile in debugger mode (the -g flag in your compiler output). I have found this resource that recommends adding a g++ compiler flag: -WA, -mbig-obj, but I haven't been able to get this to work. My work around, as you mentioned, is to compile first (which runs gcc without the debugger) and then call devtools::check or document. I am interested in hearing if anyone else has resolved this issue.

Cheers,
Andrea

--
To post to this group, send email to us...@tmb-project.org. Before posting, please check the wiki and issuetracker at https://github.com/kaskr/adcomp/. Please try to create a simple repeatable example to go with your question (e.g issues 154, 134, 51). Use the issuetracker to report bugs.
---
You received this message because you are subscribed to the Google Groups "TMB Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmb-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tmb-users/CAMDbYvYjT9HNeZs9Sw-sRonYcNsEs65ZXw7zH58obWbTyoJ8fA%40mail.gmail.com.

Andrea Havron

unread,
Feb 13, 2023, 8:31:50 AM2/13/23
to James Thorson, us...@tmb-project.org
I've dug into this issue a bit more. It looks like pkgbuild automatically adds the -g -O0 debugger flag on Windows when devtools::load_all() is called (which is called from devtools::document). As Kasper notes in the gdbsource function, an optimization level below -O1 on Windows will cause errors. To test this, I forked the pkgbuild repo and updated the -O0 flags to -O1. When using this new version of pkgbuild, devtools::load_all() recompiles with the -g -O1 flag and successfully completes without the ".o file too big" error.

Another work around is to turn off the debugger using:
withr::local_options(pkg.build_extra_flags = FALSE)
Now when calling devtools::load_all, the debugger flag is not added. The TMB model should compile without the  '.o file too big' error. 

Cheers,
Andrea

James Thorson

unread,
Feb 13, 2023, 12:35:14 PM2/13/23
to Andrea Havron, us...@tmb-project.org
Andrea,

Thanks!  I appreciate the time it must have taken to find these :)

I'm responding to confirm that the second option (using `withr::local_options(pkg.build_extra_flags = FALSE)`) works on my NOAA Windows machine.

Jim


Reply all
Reply to author
Forward
0 new messages