From 2792923d35e7f3d392474ceffe2185c661047b2e Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sat, 11 Jul 2020 22:37:31 -0500 Subject: [PATCH] [R-package] Add version floor of R 3.5 (fixes #3212) (#3216) --- CMakeLists.txt | 5 --- R-package/DESCRIPTION | 2 +- R-package/README.md | 2 +- R-package/src/R_object_helper.h | 58 ++++++++++++--------------------- R-package/src/install.libs.R | 3 -- 5 files changed, 22 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7659017386a0..78c6c0d18efb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,6 @@ OPTION(USE_OPENMP "Enable OpenMP" ON) OPTION(USE_GPU "Enable GPU-accelerated training" OFF) OPTION(USE_SWIG "Enable SWIG to generate Java API" OFF) OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF) -OPTION(USE_R35 "Set to ON if your R version is not earlier than 3.5" OFF) OPTION(USE_TIMETAG "Set to ON to output time costs" OFF) OPTION(USE_DEBUG "Set to ON for Debug mode" OFF) OPTION(BUILD_STATIC_LIB "Build static library" OFF) @@ -68,10 +67,6 @@ if(USE_SWIG) endif() endif(USE_SWIG) -if(USE_R35) - ADD_DEFINITIONS(-DR_VER_ABOVE_35) -endif(USE_R35) - if(BUILD_FOR_R) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") find_package(LibR REQUIRED) diff --git a/R-package/DESCRIPTION b/R-package/DESCRIPTION index b33ce2a376ac..d7c7ab94f413 100755 --- a/R-package/DESCRIPTION +++ b/R-package/DESCRIPTION @@ -29,7 +29,7 @@ Suggests: processx, testthat Depends: - R (>= 3.4), + R (>= 3.5), R6 (>= 2.0) Imports: data.table (>= 1.9.6), diff --git a/R-package/README.md b/R-package/README.md index 166f32501aa0..b1b307324c74 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -94,7 +94,7 @@ Windows users may need to run with administrator rights (either R or the command Set `use_gpu` to `TRUE` in `R-package/src/install.libs.R` to enable the build with GPU support. You will need to install Boost and OpenCL first: details for installation can be found in [Installation-Guide](https://github.com/microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#build-gpu-version). -If you are using a precompiled dll/lib locally, you can move the dll/lib into LightGBM root folder, modify `LightGBM/R-package/src/install.libs.R`'s 2nd line (change `use_precompile <- FALSE` to `use_precompile <- TRUE`), and install R-package as usual. **NOTE: If your R version is not smaller than 3.5.0, you should set `DUSE_R35=ON` in cmake options when build precompiled dll/lib**. +If you are using a precompiled dll/lib locally, you can move the dll/lib into LightGBM root folder, modify `LightGBM/R-package/src/install.libs.R`'s 2nd line (change `use_precompile <- FALSE` to `use_precompile <- TRUE`), and install R-package as usual. When your package installation is done, you can check quickly if your LightGBM R-package is working by running the following: diff --git a/R-package/src/R_object_helper.h b/R-package/src/R_object_helper.h index 5be578e957f2..b603bdfce1e1 100644 --- a/R-package/src/R_object_helper.h +++ b/R-package/src/R_object_helper.h @@ -18,47 +18,29 @@ // use .Internal(internalsID()) to uuid #define R_INTERNALS_UUID "2fdf6c18-697a-4ba7-b8ef-11c0d92f1327" -#ifdef R_VER_ABOVE_35 - #define NAMED_BITS 16 - struct lgbm_sxpinfo { - unsigned int type : 5; - unsigned int scalar : 1; - unsigned int obj : 1; - unsigned int alt : 1; - unsigned int gp : 16; - unsigned int mark : 1; - unsigned int debug : 1; - unsigned int trace : 1; - unsigned int spare : 1; - unsigned int gcgen : 1; - unsigned int gccls : 3; - unsigned int named : NAMED_BITS; - unsigned int extra : 32 - NAMED_BITS; - }; - - // 64bit pointer - #if INTPTR_MAX == INT64_MAX - typedef int64_t xlen_t; - #else - typedef int xlen_t; - #endif +#define NAMED_BITS 16 +struct lgbm_sxpinfo { + unsigned int type : 5; + unsigned int scalar : 1; + unsigned int obj : 1; + unsigned int alt : 1; + unsigned int gp : 16; + unsigned int mark : 1; + unsigned int debug : 1; + unsigned int trace : 1; + unsigned int spare : 1; + unsigned int gcgen : 1; + unsigned int gccls : 3; + unsigned int named : NAMED_BITS; + unsigned int extra : 32 - NAMED_BITS; +}; +// 64bit pointer +#if INTPTR_MAX == INT64_MAX + typedef int64_t xlen_t; #else - struct lgbm_sxpinfo { - unsigned int type : 5; - unsigned int obj : 1; - unsigned int named : 2; - unsigned int gp : 16; - unsigned int mark : 1; - unsigned int debug : 1; - unsigned int trace : 1; - unsigned int spare : 1; - unsigned int gcgen : 1; - unsigned int gccls : 3; - }; - typedef int xlen_t; -#endif // R_VER_ABOVE_35 +#endif struct lgbm_primsxp { int offset; diff --git a/R-package/src/install.libs.R b/R-package/src/install.libs.R index a2dc2018764c..994d940efda6 100644 --- a/R-package/src/install.libs.R +++ b/R-package/src/install.libs.R @@ -170,9 +170,6 @@ if (!use_precompile) { if (use_gpu) { cmake_args <- c(cmake_args, "-DUSE_GPU=ON") } - if (R_ver >= 3.5) { - cmake_args <- c(cmake_args, "-DUSE_R35=ON") - } cmake_args <- c(cmake_args, "-DBUILD_FOR_R=ON") # Pass in R version, used to help find R executable for linking