[Rcpp-devel] Optimization flag may be needed in Makevars.win for 4.9.2 toolchain

Kevin Ushey kevinushey at gmail.com
Wed Aug 26 01:02:26 CEST 2015


Doesn't CRAN R default to using -O2 flags when compiling C++ source
files? (I think the default is -O3 for C source files).

Are you using CRAN R, or a locally built R? You might need to set that
explicitly yourself when configuring R?

On Tue, Aug 25, 2015 at 2:54 PM, Avraham Adler <avraham.adler at gmail.com> wrote:
> The -march is local, of course. The question is should Rcpp always
> enforce at least -O2 or the like? From your answer I guess not.
>
> The reason why not to simply have an optimization flag in the local
> makevars is that, at least in my experience, some code is faster with
> O2 and some with O3, and by having one in makevars, I am overriding
> the cases where the package author (who knows better) is passing a
> different flag. Of course one can just add that flag and install Rcpp
> by itself.
>
> Thanks again,
>
> Avi
>
> On Tue, Aug 25, 2015 at 5:50 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>>
>> On 25 August 2015 at 17:39, Avraham Adler wrote:
>> | I've been testing a GCC 4.9.2-based toolchain for Windows for the last
>> | week or so, and today fell afoul of the error uncovered here
>> | <https://stat.ethz.ch/pipermail/r-devel/2015-March/070814.html>. I've
>> | been passing different optimization flags, and Rcpp compiled properly
>> | under every one EXCEPT when a -march (ivybridge) flag was passed
>> | without an optimization flag. In that case, I received the
>> | "collect2.exe: error: ld returned 5 exit status" error as discussed on
>> | R-devel. Passing a -mtune flag without an -O flag did not cause an
>> | error.
>> |
>> | Downloading the Rcpp source code and manually adding -O2 to Rcpp's
>> | Makevars.win, re-tar/gzipping it and installing the local version
>> | allowed Rcpp to compile properly.
>> |
>> | I don't know if it is better to tell people to change their local
>> | Makevars under HOME/.R to pass -O2 or -O3 (that would probably be a
>> | call by you, Dirk, as you would know best if O3 would help or hinder),
>> | or if it is better to have Rcpp enforce it, but it should be noted
>> | somewhere once a 4.9.2-based Windows is eventually released.
>>
>> CRAN disallows non-portable flags such as -march.
>>
>> So yes, ~/.R/Makevars it is.
>>
>> Dirk
>>
>> --
>> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


More information about the Rcpp-devel mailing list