[Rd] suppressing "global" cppflags in an individual package

Simon Urbanek simon.urbanek at r-project.org
Thu May 11 09:21:59 CEST 2006


Kasper,

On May 11, 2006, at 12:37 AM, Kasper Daniel Hansen wrote:

> Thank you Simon, a little comment below
>
> On May 9, 2006, at 2:49 PM, Simon Urbanek wrote:
>
>> On May 9, 2006, at 1:11 PM, Kasper Daniel Hansen wrote:
>>
>>> 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
>>> [...]
>>> 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.
>>>
>>
>> AFAIR you cannot override CPPFLAGS/CXXFLAGS in Makevars, because  
>> it gets included first. You can, however, use something like this:
>>
>> all: $(SHLIB)
>>
>> MYCFLAGS=-O0
>>
>> %.o: %.c
>>         $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(MYCFLAGS) -c $< -o $@
>>
>> for C, or for C++ accordingly:
>>
>> %.o: %.cc
>>         $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(MYCXXFLAGS) -c $<  
>> -o $@
>
> Actually you do not need the all: line, and since I use .cpp as C++  
> extension, all I needed was
>
> %.o: %.cpp
> <TAB>$(CXX) $(ALL_CPPFLAGS) -O0 -c $< -o $@
>

If it worked for you, fine ... but it doesn't for me (using plain  
SHLIB), because you're replacing the first target, the .so doesn't  
get built.

> Note that I needed to delete the $(ALL_CXXFLAGS) which basically  
> reads R's flags.
>

Well actually the point was that you *don't* need to do that and you  
should not. Most compilers (including gcc) ignore preceding  
conflicting flags, so -O3 -O0 will give you simply -O0 and that's  
what you wanted.

> Now, is there any way to (in the Makevars file) operate on $ 
> (ALL_CXXFLAGS), since all I want is to delete any -O* flag? Or is  
> defining rules and variables all I can do?
>

Yes. Again, I'm talking GNU make now, so I suspect this is not  
portable (so kids, don't do this at home), but you should be able to use

MYCXXFLAGS=$(filter-out -O3,$(ALL_CXXFLAGS))

However as stated above I don't think you want to do that - just  
append -O0 and you're safe.

Cheers,
Simon



More information about the R-devel mailing list