BH 1.69.0-0 pre-releases and three required changes

[This article was first published on Thinking inside the box , and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Our BH package provides a sizeable portion of the Boost C++ libraries as a set of template headers for use by R. It is quite popular, and frequently used together with Rcpp. The BH CRAN page shows e.g. that it is used by rstan, dplyr as well as a few other packages. The current count of reverse dependencies is at 159.

Boost releases every four months. The last release we packaged was 1.66 from February—and a new Boost 1.69 just came out. So I packaged it, being somewhat careful as usual as CRAN insists on suppressing compiler diagnostics #pragma statements and a few other things, see the BH GitHub repo for details.

Given the rather ginormous footprint of BH — in this release about 154mb installed — I am proceeding carefully as usual. I started with two full reverse-depends checks on the weekend which lead to three regressions for which I will contact the two corresponding maintainers (as it affects me for the third package). Details follow. In short, we should be in good shape to release in due course. Details are below on how to access the package now for testing and local use.

Upgrading BH on CRAN from 1.66 to 1.69

We ran two initial reverse-dependency checks, with results pushed to the usual repo. The finally summary is in this file with the moneyline being

141 successes, 10 failures, and 8 skipped packages.

Of the 10 failures, four are due to missing depends or suggests: these packages passed once installed. Of the remaining six, three are recurring issues we also have with e.g. Rcpp. That leaves three new regressions, or as CRAN calls it, ‘change to worse’. We also verified that these packages do indeed pass with the CRAN version of BH, i.e, 1.66.

What follows is a short discussion of each respective package.

First regression: phonics

The package uses

using namespace Rcpp;
using namespace boost;
using namespace std;

which flattens namespaces—and with Boost 1.69 now gets a collision as distance() is no longer unique. Simply prefixing the four or five occurrances with std:: fixes it. The complete (and very short) patch follows.

diff -ru phonics.orig/src/metaphone.cpp phonics/src/metaphone.cpp
--- phonics.orig/src/metaphone.cpp      2018-08-16 19:05:22.000000000 +0000
+++ phonics/src/metaphone.cpp   2018-12-20 03:31:06.325881441 +0000
@@ -151,13 +151,13 @@
         break;
       case 'G':
         if (nc == 'H') {
-          if(!(is("BDH", at(word, distance(word.begin(), i) - 3)) ||
-             at(word, distance(word.begin(), i) - 4) == 'H')) {
+          if(!(is("BDH", at(word, std::distance(word.begin(), i) - 3)) ||
+              at(word, std::distance(word.begin(), i) - 4) == 'H')) {
             meta += 'F';
             i++;
           }
         } else if(nc == 'N') {
-          if (is(alpha, nnc) && substr(word, distance(word.begin(), i) + 1, 3) != "NED") {
+          if (is(alpha, nnc) && substr(word, std::distance(word.begin(), i) + 1, 3) != "NED") {
             meta += 'K';
           }
         } else if(is(soft, nc) && pc != 'G') {
@@ -187,7 +187,7 @@
         } else if(nc == 'H') {
           meta += 'X';
           i += 1;
-        } else if(!traditional && substr(word, distance(word.begin(), i) + 1, 3) == "CHW") {
+        } else if(!traditional && substr(word, std::distance(word.begin(), i) + 1, 3) == "CHW") {
           meta += 'X';
           i += 2;
         } else {
@@ -200,7 +200,7 @@
         } else if(nc == 'H') {
           meta += '0';
           i += 1;
-        } else if(substr(word, distance(word.begin(), i) + 1, 2) != "CH") {
+        } else if(substr(word, std::distance(word.begin(), i) + 1, 2) != "CH") {
           meta += 'T';
         }
         break;

Second regression: RcppStreams

Here we end up with a linking error. The following symbol, expanded with c++filt is coming up as missing:

$ c++filt _ZN5boost5proto6detail17display_expr_implC1ERKS2_
boost::proto::detail::display_expr_impl::display_expr_impl(boost::proto::detail::display_expr_impl const&)
$

I am the upstream author/maintainer here. This looks somewhat tricky, but a quick commenting-out of an optional / verbose display call does the trick. So that is what we may end up doing.

Third regression: TDA

This generated a lot of messages with error: ‘next’ is not a member of ‘boost’ when boost::next(somevar) was invoked. A quick Google search suggests that the declaration moved to another header file and that including boost/next_prior.hpp should fix it — and it does. One-line patch follows.

diff -ru TDA.orig/src/diag.cpp TDA/src/diag.cpp
--- TDA.orig/src/diag.cpp       2018-08-06 00:09:20.000000000 +0000
+++ TDA/src/diag.cpp    2018-12-20 03:48:10.404143947 +0000
@@ -5,6 +5,8 @@
 // for Rcpp
 #include <Rcpp.h>

+#include <boost/next_prior.hpp>
+
 // for Rips
 #include <tdautils/ripsL2.h>
 #include <tdautils/ripsArbit.h>

That may not be the best place for the include but it demonstrated that we simply need to add it somewhere so that diag.cpp compiles.

Package Access

We installed the release candiate package in the ghrr drat repo. To install BH 1.69.0-0, either install the drat package and set the repo as described at the ghrr drat repo, or just do

install.packages("BH", repo="http://ghrr.github.io/drat/")

This will allow for continued testing of BH 1.69.0 before we upload it to CRAN, probably early January.

Comments and suggestions about BH are welcome via the mailing list or the issue tracker at the GitHub repo.

This post by [Dirk Eddelbuettel](http://dirk.eddelbuettel.com) originated on his [Thinking inside the box](http://dirk.eddelbuettel.com/blog/) blog. Please report excessive re-aggregation in third-party for-profit settings.

To leave a comment for the author, please follow the link and comment on their blog: Thinking inside the box .

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)