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