[Rcpp-devel] Templates and Debugging Symbols

Dirk Eddelbuettel edd at debian.org
Mon Aug 1 14:06:48 CEST 2016


On 31 July 2016 at 10:42, Dan Dillon wrote:
| I am writing a package that makes heavy use of templates.  Since all R packages
| are compiled with the -g flag (for g++ and clang++ anyhow), this ends up

[ If and only if R itself had been configure with that flag during its
build. And using that flag is a prescribed default for Debian (and hence
Ubuntu) (as we, for just about every binary, very cleverly strip away debug
symbol into a addon-package foo-dbg for each foo). ]

| putting debugging symbols in the resulting library (.so).  The problem is, that
| the size of these symbols bloats the shared library to a ridiculous extent
| (13.0MB with, 54K without).
| 
| I am looking for a portable way to suppress the creation of debugging symbols
| within the libraries.  For gcc/clang it is simple: add -Wl,-S to your PKG_LIBS
| variable, but this is not portable.  Furthermore, since my package is really
| just a set of headers to be used within Rcpp, any user of my package would need
| to be able to easily specify to strip debugging symbols in any file that
| includes my headers.
| 
| My thoughts are these:
| 
| 1) if a portable way of making sure debugging symbols are stripped from the
| shared libraries is available, turn it into an Rcpp plugin (e.g. //
| [[Rcpp::plugins(strip)]]
| 2) conceive of a way to do it portably and expose it.

1) is pretty clever. We should do that.

2) seems pretty hard. I never found a way to override values already set in
/etc/R/Makeconf (or whereever your R stores its Makeconf).  That has been
discussed before (on r-devel, as I recall) without a solution.
 
| I'm looking for any advice or help with this issue.

I'd say let's do the plugin.  That is a good idea.

It would be an equally good idea to dedicate a new DESCRIPTION field (and/or
R CMD ... option) to this, and propose a patch to R Core to strip upon R CMD
INSTALL.  This is a more general issue, and it would useful to trim down all
shared libraries as we don't generally call the debugger on them.  Save those
precious bytes!

Dirk

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


More information about the Rcpp-devel mailing list