[Rcpp-devel] Stripping symbols and Cran

Dirk Eddelbuettel edd at debian.org
Mon Sep 18 17:19:17 CEST 2017


Michael,

On 18 September 2017 at 16:55, Michaël BENESTY wrote:
| Because of (the great) Rcpp, the size of my package was over 5Mb, which was
| an issue for a Cran release.

Are you the OP behind the StackOverflow question here:
https://stackoverflow.com/questions/46280628/object-files-in-r-package-too-large-rcpp

If so we already tried to answer. This is NOT an issue for CRAN but merely a
warning.  Do yourself a quick favour and run

  file.info( system.file("libs", "dplyr.so", package="dplyr") )$size

and you see that some well-known and widely used packages are MUCH bigger.

| I read with interest this article
| http://dirk.eddelbuettel.com/blog/2017/08/14/#009_compact_shared_libraries
| 
| In particular, I was interested in the Makevars modification:
| 
| strippedLib: $(SHLIB)
|         if test -e "/usr/bin/strip"; then /usr/bin/strip --strip-debug
| $(SHLIB); fi
| 
| Unfortunately it crashed compilation on Mac OS because for some reason
| --strip-debug doesn't exist.

Interesting.

It so happens that I just shipped a use of `strip --strip-unneeded` in
RcppClassic, see https://github.com/eddelbuettel/rcppclassic/blob/7cc5c626952d38cc97a99363131fe7ac9d0a7b28/src/Makevars#L33
Does --strip-unneeded work on macOS ?
 
| But this small modification works:
| strippedLib: $(SHLIB)
|         if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[
| `uname` == "Linux" ]] ; then /usr/bin/strip --strip-debug $(SHLIB); fi

Maybe --strip-unneeded is for preferable. Otherwise, yes, one needs to check
for Linux here.

But that is the crux of these Makefile / Makevars tweaks. They get
non-portable real quickly.

The easiest may just be to NOT worry, and just use -W,-S in the local
~/.R/Makevars.  That is what I now do.

| May be there is a way to make strip works correctly on Mac, but as I
| have no size issue on both Windows and Mac OS... I don't care.
| 
| I thought it was useful enough to share it with you.

It is useful.  Dan worked quite a bit on this too. See his repo at

   https://github.com/dcdillon/r-stripper

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list