Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package build ignores Makevars flags

Tags:

c++

r

r-package

Question

I'm trying to tell my package to use gcc to compile the C++ code in stead of clang. Why aren't my CXX flags in my Makevars file being used?

(I am expecting/hoping the solution to be something really simple that I've overlooked.)


It's my understanding (see references) that I can specify CXX* flags in either

  1. src/Makevars in the package, or
  2. ~/.R/Makevars

However, I can't get option 1 to work, only option 2.

Example Builds

Here are screenshots showing the build options I'm using. In each case I'm showing both the Makevars and the /.R/Makevars files to show which one I'm using in each case.

Option 1: src/Makevars

Here I specify CXX11 = /usr/local/bin/g++-7 inside src/Makevars. The build messages say it's building with clang

enter image description here

Option 2: ~/.R/Makevars

Here I specify CXX11 = /usr/local/bin/g++-7 inside ~/.R/Makevars. The build message shows it builds with g++

enter image description here

Example package

I've noticed this on a few packages I've built recently using Rcpp, but if you want an example to test my googlePolylines package is here on github.


References

  • Building R packages using Alternate GCC
  • Understanding the contents of Makevars

Session Info

devtools::session_info()
Session info ----------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.3 (2017-11-30)
 system   x86_64, darwin15.6.0        ## Mac OS
 ui       RStudio (1.1.414)           
 language (EN)                        
 collate  en_AU.UTF-8                 
 tz       Australia/Melbourne         
 date     2018-03-11 
like image 510
SymbolixAU Avatar asked Mar 11 '18 07:03

SymbolixAU


1 Answers

Quoting Duncan Murdoch in https://stat.ethz.ch/pipermail/r-package-devel/2017q4/002087.html:

According to section 1.2.1 "Using Makevars" in Writing R Extensions, R_HOME/etcR_ARCH/Makeconf is included after Makevars, so what you're seeing is by design. I believe this is so that packages are built with tools compatible with those that built R. (Remember, packages are designed for distribution to diverse systems.)

So you might change various flags within src/Makevars via for example PKG_CXXFLAGS, but you cannot overwrite CXXFLAGS or CXX itself. And there is no PKG_CXX.

like image 109
Ralf Stubner Avatar answered Oct 18 '22 06:10

Ralf Stubner