From khansen at stat.Berkeley.EDU  Tue May  9 19:11:47 2006
From: khansen at stat.Berkeley.EDU (Kasper Daniel Hansen)
Date: Tue, 9 May 2006 10:11:47 -0700
Subject: [Rd] suppressing "global" cppflags in an individual package
In-Reply-To: <4460C819.6090407@cimr.cam.ac.uk>
References: <9294B498-A4DB-47B1-AE99-71C1559EABB3@stat.berkeley.edu>
	<4460C819.6090407@cimr.cam.ac.uk>
Message-ID: <8315342E-192B-4BF4-86BC-8F947769530E@stat.Berkeley.EDU>


On May 9, 2006, at 9:49 AM, Hin-Tak Leung wrote:

> Kasper Daniel Hansen wrote:
>> Hi
>> 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


> HTL



[Rd] suppressing "global" cppflags in an individual package
Kasper Daniel Hansen