[R-SIG-Mac] Help on reducing size of shared libraries on MacOS on CRAN

Gilberto Camara g||berto@c@m@r@@|npe @end|ng |rom gm@||@com
Sat Mar 18 19:02:08 CET 2023


Dear R-SIG-MAC members

We are the developers of R package sits and would like to ask for your help in solving a problem with library size on R macOS binaries. 

Before submission to CRAN, version 1.3.0 of sits (https://cran.r-project.org/web/packages/sits/index.html) has been tested in various environments, including Ubuntu, Fedora, CRAN winbuilder (all flavors). We have tested sits-1.3.0 on r-release-mac-x86_64 and r-release-macos-arm64 with the following configurations:

- r-release-macos-x86_64: R 4.2.2, MacMini 3.2GHz, 6 cores, 32 MB RAM, macOS Ventura 3.2.1, Apple clang version 14.0.3 (clang-1403.0.22.14.1).

- r-release-macos-arm64: R 4.2.2, MacBookAir, chip ARM M1, 8 cores, 16 MB RAM, macOS Monterrey 12.6,  Apple clang version 14.0.0 (clang-1400.0.29.201). 

In our configuration of r-release-macos-x86_64, the installed size is 3.8 MB, and the libs directory size is 436 KB. On r-release-macos-arm64, the installed size is 5.4 MB and the libs directory size is 1.6 MB. 

The current CRAN check on sits version 1.3.0 reports a NOTE on r-release-macos-arm64 and r-oldrel-macos-arm64, with an installation size of 7.3Mb with the libs directory size reported as 4.8Mb. CRAN is using Apple clang version 13.0.0 ((clang-1300.0.29.30) on r-release-macos-arm64 and Apple clang version 12.0.0 (clang-1200.0.32.29) on r-oldrel-macos-arm64. 

There is a 3.2 MB difference in size between what CRAN reports and what we obtain in our tests for r-release-macos-arm64. We would appreciate your guidance on how to address this problem and, if possible, point to a reliable way to reduce package size in macOS. 

Note that our package links to RCpp and RCppArmadillo.

Our current Makevars configuration is given below
==========================================
# suggestion by Dirk Eddelbuettel
SHLIB_CXXLDFLAGS = -Wlto,-S -shared
SHLIB_CXX11LDFLAGS = -Wlto,-S -shared
SHLIB_CXX14LDFLAGS = -Wlto,-S -shared
SHLIB_FCLDFLAGS = -Wlto,-S -shared
SHLIB_LDFLAGS = -Wlto,-S -shared

## suggestion by Dirk Eddelbuettel
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

strippedLib: $(SHLIB)
		if test -e "/usr/bin/strip" & test -e "/bin/uname" & [[ `uname` == "Linux" ]] ; then /usr/bin/strip --strip-debug $(SHLIB); fi

clean:
	rm -f $(OBJECTS)

.phony: strippedLib clean
===========================================

Any help would be much appreciated. 

Best regards
Gilberto
============================
Prof Dr Gilberto Camara
Senior Researcher
National Institute for Space Research (INPE), Brazil
https://gilbertocamara.org/
=============================



More information about the R-SIG-Mac mailing list