[R] R CMD CHECK warning about registering routines #1910
Description
Overview
Running R CMD CHECK
on the R package on Mac OS yields the following NOTE:
File ‘lightgbm/libs/lib_lightgbm.so’:
Found no calls to: ‘R_registerRoutines’, ‘R_useDynamicSymbols’
It is good practice to register native routines and to disable symbol
search.
See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual.
I attempted to address this in #1499 by adding init.c, but the issue persists.
I have noticed when running R CMD CHECK that at the compilation stage the init.c
step happens outside of compiling lightgbm.so
with cmake
.
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c R_init.c -o R_init.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o lightgbm.so R_init.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
I believe (though have not had time to validate) that this one file is getting compiled and linked to lightgbm.so
created by R's standard process for building projects with compiled code, and then the legit installation with cmake
is both ignoring it AND overwriting lightgbm.so
.
How to run R CMD CHECK
To run R CMD CHECK on the package, clone the repo and install from source per these directions, then build the package and run R CMD CHECK.
On Mac OS, this looks like running the following from your local clone of LightGBM
:
export CXX=/usr/local/bin/g++-8
export CC=/usr/local/bin/gcc-8
# build the package
Rscript build_r.R
# Check
LGB_VERSION=$(cat R-package/DESCRIPTION | grep ^Version | tr -d "Version: ")
R CMD CHECK lightgbm_${LGB_VERSION}.tar.gz --as-cran | tee check.log | cat
How to close this issue
Contributions must pass our existing CI tests to be accepted. A contribution that fixes this issue will additionally result in R CMD CHECK not returning the note above on Mac OS.
Closing this will help with #629