Skip to content

Commit

Permalink
[R-package] Add version floor of R 3.5 (fixes #3212) (#3216)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored Jul 12, 2020
1 parent 7b93543 commit 2792923
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 48 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R-package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Suggests:
processx,
testthat
Depends:
R (>= 3.4),
R (>= 3.5),
R6 (>= 2.0)
Imports:
data.table (>= 1.9.6),
Expand Down
2 changes: 1 addition & 1 deletion R-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
58 changes: 20 additions & 38 deletions R-package/src/R_object_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions R-package/src/install.libs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2792923

Please sign in to comment.