Package build ignores Makevars flags

别来无恙 提交于 2019-12-10 13:23:41

问题


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

Option 2: ~/.R/Makevars

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

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 

回答1:


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.



来源:https://stackoverflow.com/questions/49217539/package-build-ignores-makevars-flags

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!