diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 926eab462df..ec8eec275e9 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -5,7 +5,7 @@ \title{R News} \encoding{UTF-8} -\section{\Rlogo CHANGES IN R-devel}{ +\section{\Rlogo CHANGES IN R 3.6.0}{ \subsection{SIGNIFICANT USER-VISIBLE CHANGES}{ \itemize{ @@ -442,14 +442,16 @@ \item The make macro \samp{F_VISIBILITY} is now preferred for both fixed-form and free-form Fortran. - \item \command{R CMD INSTALL} gains a new flag \option{--strip} + \item \command{R CMD INSTALL} gains a new option \option{--strip} which strips installed shared object(s): this can also be achieved by setting the environment variable \env{_R_SHLIB_STRIP_} to a true value. - This is most useful on platforms using GNU \code{binutils} (such - as Linux) and compiling with \option{-g} flags: it has negligible - effect on macOS. + The new option \option{--strip-lib} attempts stripping of + static and shared libraries installed under \file{lib}. + + These are most useful on platforms using GNU \code{binutils} (such + as Linux) and compiling with \option{-g} flags. \item There is more support for installing UTF-8-encoded packages in a strict Latin-1 locale (and probably for other Latin locales): diff --git a/src/library/tools/R/install.R b/src/library/tools/R/install.R index 42bcc056971..c7c621cf259 100644 --- a/src/library/tools/R/install.R +++ b/src/library/tools/R/install.R @@ -226,6 +226,7 @@ if(FALSE) { " --configure-vars=VARS", " set variables for the configure scripts (if any)", " --strip strip shared object(s)", + " --strip-lib strip static/dynamic libraries under lib/", " --dsym (macOS only) generate dSYM directory", " --built-timestamp=STAMP", " set timestamp for Built: entry in DESCRIPTION", @@ -1682,6 +1683,27 @@ if(FALSE) { sQuote("--no-staged-install")) } } + + if (do_strip_lib && + nzchar(strip_cmd <- Sys.getenv("R_STRIP_STATIC_LIB")) && + length(a_s <- Sys.glob(file.path(file.path(lib, curPkg), + "lib", "*.a")))) { + if(length(a_s) > 1L) + starsmsg(stars, "stripping static libraries under lib") + else + starsmsg(stars, "stripping static library under lib") + system(paste(c(strip_cmd, shQuote(a_s)), collapse = " ")) + } + if (do_strip_lib && + nzchar(strip_cmd <- Sys.getenv("R_STRIP_SHARED_LIB")) && + length(so_s <- Sys.glob(file.path(file.path(lib, curPkg), "lib", + paste0("*", SHLIB_EXT))))) { + if(length(so_s) > 1L) + starsmsg(stars, "stripping dynamic libraries under lib") + else + starsmsg(stars, "stripping dynamic library under lib") + system(paste(c(strip_cmd, shQuote(so_s)), collapse = " ")) + } } options(showErrorCalls = FALSE) @@ -1741,7 +1763,7 @@ if(FALSE) { install_inst <- TRUE install_help <- TRUE install_tests <- FALSE - do_strip <- FALSE + do_strip <- do_strip_lib <- FALSE while(length(args)) { a <- args[1L] @@ -1870,6 +1892,8 @@ if(FALSE) { dsym <- TRUE } else if (a == "--strip") { do_strip <- TRUE + } else if (a == "--strip-lib") { + do_strip_lib <- TRUE } else if (substr(a, 1, 18) == "--built-timestamp=") { built_stamp <- substr(a, 19, 1000) } else if (startsWith(a, "-")) {