[Rcpp-devel] R CMD check not happy about -std=c++0x
francoisromain at free.fr
Sat Jan 16 09:39:22 CET 2010
Yes it is fairly tricky.
What I could not understand was why would R CMD check not complain about
Rcpp because we also set the non portable flags in Rcpp. It turns out it
works for Rcpp because the way R CMD check checks for these variables is
buggy and it appears that Rcpp takes advantage of this bug.
Eventually R CMD check calls this from the root directory of the package :
make -f 'src/Makevars' -f '/usr/local/lib/R/share/make/check.mk'
which is supposed to print out the flags. This is what gets printed for
the CPP package :
PKG_CXXFLAGS: -I/usr/local/lib/R/library/Rcpp/lib -std=c++0x
This is what gets printed in Rcpp:
make: o: Command not found
make: [libRcpp] Error 127 (ignored)
cp libRcpp ../inst/lib
cp: cannot stat `libRcpp': No such file or directory
make: *** [userLibrary] Error 1
So the PKG_CXXFLAGS does not get printed, so it cannot be identified as
wrong, which is why Rcpp passes check.
I can take advantage of this by using this Makevars in CPP:
all: $(SHLIB) hack
cp vector_int_.o tmp
rm -fr tmp
where the "hack" target works when R CMD INSTALL, but not when R CMD check.
or I can do the right thing and report this as a bug to R, which means
we'll have to find another way to compile Rcpp.
On 01/15/2010 09:55 PM, Dirk Eddelbuettel wrote:
> On 15 January 2010 at 14:26, Romain François wrote:
> | On 01/15/2010 02:15 PM, Dirk Eddelbuettel wrote:
> |> On 15 January 2010 at 08:27, Romain François wrote:
> |> | I'm getting a warning when I try to build my CPP package that depends on
> |> | Rcpp and uses the classic Makevars :
> |> |
> |> | PKG_CXXFLAGS=`Rcpp:::CxxFlags()` -I.
> |> | PKG_LIBS=`Rcpp:::LdFlags()`
> |> |
> |> |
> |> | I get this warning from R CMD check :
> |> |
> |> | * checking for portable compilation flags in Makevars ... WARNING
> |> | Non-portable flags in variable 'PKG_CXXFLAGS':
> |> | -std=c++0x
> |> I also noticed that yesterday working on another package using Rcpp. I think
> |> we need to fix this.
> | Rcpp:::CxxFlags() will only include "-std=c++0x" when we know we can use
> | it : GCC>= 4.3
> | but there is no way to tell R CMD that "this is alright, go on".
> It is tricky. I think there are 'two GCCs' here, if not three:
> a) when we build Rcpp we can query what compiler it sees; that is how we
> started -- but there is the rub: the compiler that 'g++ --version' shows
> may not be the one that is used to build the package!!
> That we learn via R CMD config CXX and I think I adjusted configure
> for that.
> So this govern how Rcpp is built.
> b) But here is the sticky bit. Rcpp is used by other packages, and we no
> longer control what compiler they use !!
> In that sense I fear that your tests of 'can use C++0x' may be too
> optimistic and I am wondering if we should make it a simple user control,
> just like the one for static links.
> Simple because we don't know how we may be called.
> Does this make sense to you?
> | We can subvert the test if we explicitely define how to compile and
> | link, i.e something like this (although it does not work)
> | RCPP_CXXFLAGS=`Rcpp:::CxxFlags()` -I.
> | PKG_LIBS=`Rcpp:::LdFlags()`
> | # this tricks R CMD SHLIB so that it does not compile
> | # anything
> | OBJECTS=
> | all: compile link
> | compile:
> | $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(RCPP_CXXFLAGS) .....
> | link:
> | $(SHLIB_CXXLD) -o $(pkg)$(DYLIB_EXT) $^ $(SHLIB_CXXLDFLAGS) $(PKG_LIBS)
> I don't follow. Who now sets which flags differently?
> | I've played with this, but since I don't understand Makefile, this does
> | not work. Someone with makefile skills would make sense of it I suppose.
> | Too dumb here.
> | Romain
> |> Recall that 'can use Cxx0x' should be based on the compiler used to build R
> |> (!!) not Rcpp or the current package. So we need to query 'R CMD config CXX'
> |> at build time and somehow remember that.
> |> | Is there a workaround ? We probably would then have to update the new
> |> | skeleton generator to use it.
> |> Right.
Professional R Enthusiast
+33(0) 6 28 91 30 30
|- http://tr.im/KfKn : Rcpp 0.7.2
|- http://tr.im/JOlc : External pointers with Rcpp
`- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009
More information about the Rcpp-devel