Home > OS >  Compiling F77 with R CMD SHLIB for use in R package. Changing `-fmax-stack-var-size=`
Compiling F77 with R CMD SHLIB for use in R package. Changing `-fmax-stack-var-size=`

Time:11-11

I've inherited some F77 code from the 1980s that I'd like to eventually use in an R package that is on CRAN. Basically I'll be substituting a slow function written in straight R with a .Call to a F77 subroutine that runs 100x faster. I've done similar heavy lifting with C in the past. However, when I compile the fortran subroutine via R CMD SHLIB I get a warning about one of the arrays being "larger than limit set by '-fmax-stack-var-size='". I can fix this by compiling explicitly with gfortran and setting -fmax-stack-var-size appropriately. However, how can I set the flag when running R CMD SHLIB? In a Makevars file? Eventually, I'll include this in a new release and submit to CRAN and I want to head off any issues. Many thanks.

CodePudding user response:

Yes, in ~/.R/Makevars for your compilations, in src/Makevars for all builds of the package. CRAN has views on which options are portable so you may not be able to ship with the option in src/Makevars.

Here is what I have:

edd@rob:~$ grep ^F .R/Makevars 
FLAGS=-Wall -O3 -g -pipe $(PEDANTIC) $(XTRAFLAGS)
FFLAGS=-O3 -g0 -Wall -pipe
FCFLAGS=-O3 -g0 -Wall -pipe
FC=$(CCACHE) gfortran
F77=$(CCACHE) gfortran
F95=$(CCACHE) gfortran
edd@rob:~$ 

where some of the other values are previoysly set as you can surmise. Note that there are several Fortran compiler variables, details as usual in Writing R Extensions.

  • Related