Change R C ++ C / C ++ Compiler on Kubuntu Linux

If you install the R package, which requires compilation with

R CMD INSTALL package.tar.gz

from bash, R uses the gcc compiler by default. It happened that my R-package gives a warning about Cran with the installation of the "clang" compiler, which does not appear with the gcc compiler.

To reproduce the warning on my local computer, I would like to configure the local compiler options to those used on the Cran check servers.

I found out that it is possible to change the default R compiler by creating the Makevars.in file somewhere in the home folder, but I can’t find where it should be located and what needs to be written there to make R to use "clang" with specific warning flags, not "gcc".

Has anyone already turned on their Linux default R compiler system from gcc to clang and can give me a hint how to do this?

+4
source share
1 answer

My favorite method (and I think I described in detail what was here before) is to use the file ~/.R/Makevarswhere I installed

CFLAGS +=             -O3 -Wall -pipe -pedantic -std=gnu99
CXXFLAGS +=           -O3 -Wall -pipe -Wno-unused -pedantic 

#VER=-4.6
#VER=-4.7
VER=-4.8
CC=ccache gcc$(VER)
CXX=ccache g++$(VER)
SHLIB_CXXLD=g++$(VER)
FC=ccache gfortran
F77=ccache gfortran
MAKE=make -j8

#CXX=clang++
#CC=clang

and more, since it also allows you to switch to clang++instead g++and more.

I use it ccachehere to speed up reassembly - very useful for R packages where you can change the package code but not the files src/.

script, CC, CXX , .

+17

Source: https://habr.com/ru/post/1542518/


All Articles