[Rd] suppressing "global" cppflags in an individual package
Kasper Daniel Hansen
khansen at stat.Berkeley.EDU
Tue May 9 19:11:47 CEST 2006
On May 9, 2006, at 9:49 AM, Hin-Tak Leung wrote:
> Kasper Daniel Hansen wrote:
>> I can use PKG_CPPFLAGS in a Makevars file to add additional flags
>> to the c++ compiler for a given package. Is it possible to remove
>> flags passed to the packages from R. Eg: say R have been compiled
>> with -O2 and I want the package to be compiled with another
>> optimization level?
> Do you mean the flags passed to the c++ compiler (CXXFLAGS) or
> to the C proprocessor (CPPFLAGS)? Do not confuse the two.
Hmm good point. I think I have indeed confused the two.
> I think the "proper" way would be to write a full makefile.
> (there are plenty of examples on CRAN).
I would like to avoid this, see below.
> Now, out of curiosity - why would you want to do that? The actual
> difference in CPU time usage is often small (10%?), so unless the
> package triggers a compiler bug at specific optimization level and
> gets mis-compiled, it is probably not worth the trouble. And if
> the package is that sensitive to optimization level and can get mis-
> compiled, one of them (the package or the compiler) needs fixing.
It is indeed the case that after updating to GCC 4 the package gets
broken using -O2. I agree this needs to be fixed, but the error
(which I believe I have kind of localized, but not really understood)
stems from a C++ library we have little control over, so it would be
nice to have a fix for the time being that does not require a
reinstallation of R - especially since we actually have users who
currently (or soon will be) testing it. I was thus looking for a
temporary quick fix allowing me to disable the optimization level,
while I take the time to fix it properly.
Kurt Hornik have replied of-list that it is possible to do so using a
~/.R/Makevars file (which I have not had the time to test
unfortunately), but reading your comment about CPPFLAGS and CXXFLAGS
makes me think I can indeed override it using the package Makevars
file. The flags I was passing to the compiler were library locations
anyway which was for the preprocessor.
Thanks for the help, Kasper
More information about the R-devel