[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:
When I put this line in makevars:
PKG_CXXFLAGS = -O3
This is the output of the cpp precompiler:
-O3 -fpic -g -O2
I read the cpp doc, and it states:
"If you use multiple -O options, with or without level numbers, the last
such option is the one that is effective."
Since, system wide R optimization -O2 always comes last, how can I make my
package overwrite the system wide optimization ?
And should I do this at all, since debugging could get more difficult ?
[[alternative HTML version deleted]]
_______________________________________________ Bioc-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel