Skip to content
Prev 14041 / 21318 Next

[Bioc-devel] package c++ optimization flag

This should be done extremely sparingly, but it is sometimes necessary if
you know that higher optimization breaks the code. But that is the only use
case. Otherwise you should trust the setting of the user who compiles R,
ie. you should for example never force a higher optimization level IMO.

We do this override in affxparser.  The issue with the approach in
affxparser is that it is non-portable, since we just overwrite the users
-O* setting. However, a flag like -O* is complier dependent, so this is
actually not a great solution (although it has worked for 10 years).  The
"right" way to do this - which I think we should have example code for - is
to use autoconfigure to detect that the compiler is GCC or clang and _then_
override.

https://github.com/HenrikBengtsson/affxparser/blob/master/src/Makevars

the relevant part is essentially

MYCXXFLAGS = -Wno-sign-compare -O0

%.o: %.cpp
     $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(MYCXXFLAGS) -c $< -o $@

(remember you need TABS in Makefiles)

On Wed, Sep 19, 2018 at 5:12 AM H?kon Tjeldnes <hauken_heyken at hotmail.com>
wrote:

  
  
Message-ID: <CAC2h7uvmzOvA85d2GmcDSCE1Psd8DnPzrOU6HGKdg3h7STP58Q@mail.gmail.com>
In-Reply-To: <VI1PR03MB4687ACCACA1545093C529789981C0@VI1PR03MB4687.eurprd03.prod.outlook.com>