Welcome to the 21th post in the reasonably relevant R ramblings series, or R4 for short.
Back in August of 2017, we wrote two posts #9: Compating your Share Libraries and #10: Compacting your Shared Libraries, After The Build about “stripping” shared libraries. This involves removing auxiliary information (such as debug symbols and more) from the shared libraries which can greatly reduce the installed size (on suitable platforms – it mostly matters where I work, i.e. on Linux). As an illustration we included this chart:
Two items this week made me think of these posts. First was that a few days ago I noticed the following
src/Makefile of the precrec package I was starting to use more:
# copied from https://github.com/vinecopulib/rvinecopulib # strip debug symbols for smaller Linux binaries strippedLib: $(SHLIB) if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[ `uname` == "Linux" ]] ; \ then /usr/bin/strip --strip-debug $(SHLIB); fi .phony: strippedLib
And lo and behold, the quoted package rvinecopulib
has the same
CXX_STD = CXX11 PKG_CPPFLAGS = -I../inst/include -pthread # strip debug symbols for smaller Linux binaries strippedLib: $(SHLIB) if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[ `uname` == "Linux" ]] ; \ then /usr/bin/strip --strip-debug $(SHLIB); fi .phony: strippedLib
I was intrigued and googled a little. To my surprise I found one related reference … in a stone-old
src/Makevars of mine in RcppClassic and probably written in 2007 or 2008. But more astonishing, the actual reference to the “phony target” trick is in … the #9 post from August 2017 referenced above. Doh. Younger me knew this, current me did not, and as those two packages didn’t reference my earlier use I had to re-find it. Oh well.
But the topic is still a very important one. The two blog posts show how to deal with this locally as a user and “consumer” of packages (as well as via the “phony trick” as a producer of packages) as well as an admin of a system with such packages. Personally I had been using this trick since August 2017 via my
And we were still missing such a tool for the more general deployment. Well, until today, or rather, until R 3.6.0 comes out offically on April 26. The (excellent) R-devel Daily ‘NEWS’ feed – which itself was the topic of post #3: Follow R-devel – will likely show tomorrow something about this commit I spotted by following Winston’s mirror of the R-devel sources:
And indeed, we now can now do this with
R-devel (rebuilt from today’s sources):
edd@rob:~$ RD CMD INSTALL --help | grep strip --strip strip shared object(s) edd@rob:~$
As a quick check, installing the (small, C-only) digest package without / with the
--strip options gets us, respectively, 425kb and 123kb. So the ratios from the chart above should now be achievable directly from
R CMD INSTALL --strip with R 3.6.0. (And for what it is worth, it still works with the older tricks mentioned above.)
And as occupying disk space with unused debugging symbols is wasteful, the new extension to
R CMD INSTALL is most welcome.
Last but not least: It is this type of relentless small improvements to R, its innards, its installations and support by R Core that make this system for Programming with Data such an excellent tool and joy to use and follow. A big Thank You! to R Core for all they do, and do quietly yet relentlessly. It is immensely appreciated.