Sebastian Martin Krantz
2022-Jun-07 18:44 UTC
[Rd] R CMD Check should allow packages with C and C++ and OpenMP without generating a NOTE
Dear Developers, I have the following issue with my package collapse: https://github.com/SebKrantz/collapse, whose code base is 34.5% C code and 28.3% C++, and to which I now want to add OpenMP multithreading and send it to CRAN. For this I have set up a Makevars file with PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS) PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) as linking is through C++ via Rcpp. The problem is that this generates a NOTE on R CMD Check: src/Makevars: SHLIB_OPENMP_CFLAGS is included in PKG_CFLAGS but not in PKG_LIBS If I alternatively put PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(SHLIB_OPENMP_CFLAGS) I get another NOTE stating that this is not portable. Finally putting PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) gives a note (or warning) that linking is through C++. CRAN maintainers have not engaged constructively with me on the issue, but I do believe this is an issue requiring constructive engagement i.e. I believe R CMD Check should be adjusted to allow for such a configuration, and possibly some instructions should be added to the Writing R Extensions Manual. I have also asked Dirk Eddelbuettel ( https://github.com/SebKrantz/collapse/issues/258) who agrees that this is an upstream issue. I am happy for any proactive comments or suggestions. Best regards, Sebastian Krantz [[alternative HTML version deleted]]
Sebastian Martin Krantz
2022-Jun-08 12:00 UTC
[Rd] R CMD Check should allow packages with C and C++ and OpenMP without generating a NOTE
For the record: it seems a simple text-substitution approach in the Makevars file solves the issue, e.g. to have a package combining C, C++ and OpenMP, your Makevars file could look like this: PKG_CFLAGS = $($(subst OPENMP,OPENMP_CFLAGS,SHLIB_OPENMP)) PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) where $($(subst OPENMP,OPENMP_CFLAGS,SHLIB_OPENMP)) substitutes OPENMP_CFLAGS for OPENMP, thus reconstructing SHLIB_OPENMP_CFLAGS and avoiding errors from static code analysis on R CMD Check. Needless to say this is not very elegant and it would be great if R CMD Check could be adjusted. Best regards, Sebastian On Tue, 7 Jun 2022 at 20:44, Sebastian Martin Krantz < sebastian.krantz at graduateinstitute.ch> wrote:> Dear Developers, > > I have the following issue with my package collapse: > https://github.com/SebKrantz/collapse, > whose code base is 34.5% C code and 28.3% C++, and to which I now want to > add OpenMP multithreading and send it to CRAN. For this I have set up a > Makevars file with > > PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS) > PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) > PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) > > as linking is through C++ via Rcpp. The problem is that this generates a > NOTE on R CMD Check: > > src/Makevars: SHLIB_OPENMP_CFLAGS is included in PKG_CFLAGS but not in > PKG_LIBS > > If I alternatively put > > PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(SHLIB_OPENMP_CFLAGS) > > I get another NOTE stating that this is not portable. Finally putting > > PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) > > gives a note (or warning) that linking is through C++. CRAN maintainers > have not engaged constructively with me on the issue, but I do believe this > is an issue requiring constructive engagement i.e. I believe R CMD Check > should be adjusted to allow for such a configuration, and possibly some > instructions should be added to the Writing R Extensions Manual. I have > also asked Dirk Eddelbuettel ( > https://github.com/SebKrantz/collapse/issues/258) who agrees that this is > an upstream issue. I am happy for any proactive comments or suggestions. > > Best regards, > > Sebastian Krantz > > > > >[[alternative HTML version deleted]]