From 7b68f50e40e79a0f7bdede38090b498a867957e4 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 8 Aug 2021 20:58:57 -0500 Subject: [PATCH 1/6] [R-package] use C++ compiler for pre-compile checks on Windows --- R-package/configure.win | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/R-package/configure.win b/R-package/configure.win index b6f95aaccb24..0b5de700a46d 100755 --- a/R-package/configure.win +++ b/R-package/configure.win @@ -7,7 +7,9 @@ R_SCRIPT="${R_HOME}/bin${R_ARCH_BIN}/Rscript" R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R" -CC=`"${R_EXE}" CMD config CC` +CXX=`"${R_EXE}" CMD config CXX` +CXXFLAGS=`"${R_EXE}" CMD config CXXFLAGS` +CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS` # LightGBM-specific flags LGB_CPPFLAGS="" @@ -24,7 +26,7 @@ LGB_CPPFLAGS="${LGB_CPPFLAGS} -DEIGEN_MPL2_ONLY" ac_mm_prefetch="no" -cat > conftest.c < conftest.cpp < int main() { int a = 0; @@ -33,7 +35,7 @@ int main() { } EOL -${CC} -o conftest conftest.c 2>/dev/null && ./conftest && ac_mm_prefetch="yes" +${CXX} ${CXXFLAGS} ${CPPFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_prefetch="yes" echo "checking whether MM_PREFETCH works...${ac_mm_prefetch}" if test "${ac_mm_prefetch}" = "yes"; @@ -46,7 +48,7 @@ fi ############ ac_mm_malloc="no" -cat > conftest.c < conftest.cpp < int main() { char *a = (char*)_mm_malloc(8, 16); @@ -55,7 +57,7 @@ int main() { } EOL -${CC} -o conftest conftest.c 2>/dev/null && ./conftest && ac_mm_malloc="yes" +${CXX} ${CXXFLAGS} ${CPPFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_malloc="yes" echo "checking whether MM_MALLOC works...${ac_mm_malloc}" if test "${ac_mm_malloc}" = "yes"; From 4884a695355574db9cece6c22ca1fe6806154c35 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 10 Aug 2021 08:47:36 -0500 Subject: [PATCH 2/6] install Matrix in valgrind test --- .ci/test_r_package_valgrind.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/test_r_package_valgrind.sh b/.ci/test_r_package_valgrind.sh index 2a6ce8dc7f9a..80a2830b7422 100755 --- a/.ci/test_r_package_valgrind.sh +++ b/.ci/test_r_package_valgrind.sh @@ -1,6 +1,6 @@ #!/bin/bash -RDscriptvalgrind -e "install.packages(c('R6', 'data.table', 'jsonlite', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" || exit -1 +RDscriptvalgrind -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" || exit -1 sh build-cran-package.sh || exit -1 RDvalgrind CMD INSTALL --preclean --install-tests lightgbm_*.tar.gz || exit -1 From b43b6c71d6b01e738b71aaad44aaa759f026ee7c Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 10 Aug 2021 21:04:31 -0500 Subject: [PATCH 3/6] Add {Matrix} in more places in CI and docs --- .github/workflows/r_package.yml | 4 ++-- .github/workflows/static_analysis.yml | 2 +- R-package/README.md | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 5c151825cde9..4b72ca15f0ce 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -191,7 +191,7 @@ jobs: - name: Install packages shell: bash run: | - Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" + Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" sh build-cran-package.sh Rdevel CMD INSTALL lightgbm_*.tar.gz || exit -1 - name: Run tests with sanitizers @@ -221,7 +221,7 @@ jobs: shell: bash run: | export PATH=/opt/R-devel/bin/:${PATH} - Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" + Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" sh build-cran-package.sh R CMD check --as-cran --run-donttest lightgbm_*.tar.gz || exit -1 if grep -q -E "NOTE|WARNING|ERROR" lightgbm.Rcheck/00check.log; then diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index 851c3f7e56bf..cdc917903f46 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -57,7 +57,7 @@ jobs: - name: Install packages shell: bash run: | - Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'roxygen2', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" + Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'roxygen2', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" sh build-cran-package.sh || exit -1 R CMD INSTALL --with-keep.source lightgbm_*.tar.gz || exit -1 - name: Test documentation diff --git a/R-package/README.md b/R-package/README.md index e4be3c9a5dc2..c30ddcef85af 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -374,7 +374,7 @@ docker run \ -it rhub/rocker-gcc-san \ /bin/bash -Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'testthat'), repos = 'https://cran.rstudio.com', Ncpus = parallel::detectCores())" +Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.rstudio.com', Ncpus = parallel::detectCores())" sh build-cran-package.sh @@ -396,7 +396,7 @@ docker run \ -it \ wch1/r-debug -RDscriptvalgrind -e "install.packages(c('R6', 'data.table', 'jsonlite', 'testthat'), repos = 'https://cran.rstudio.com', Ncpus = parallel::detectCores())" +RDscriptvalgrind -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.rstudio.com', Ncpus = parallel::detectCores())" sh build-cran-package.sh From b576a4f580f6b16f75a77462fb688c5df1b942ca Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 13 Aug 2021 20:42:00 -0500 Subject: [PATCH 4/6] use CXX11 --- R-package/configure.win | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R-package/configure.win b/R-package/configure.win index bbf219ede99b..4859e15962f2 100755 --- a/R-package/configure.win +++ b/R-package/configure.win @@ -6,7 +6,7 @@ ########################### R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R" -CXX=`"${R_EXE}" CMD config CXX` +CXX=`"${R_EXE}" CMD config CXX11` CXXFLAGS=`"${R_EXE}" CMD config CXXFLAGS` CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS` From e06bdf57580465183982378bf9bfb2a88ed65419 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sat, 14 Aug 2021 09:58:40 -0500 Subject: [PATCH 5/6] use flags specific to C++11 --- R-package/configure.win | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R-package/configure.win b/R-package/configure.win index 4859e15962f2..52a2709502e8 100755 --- a/R-package/configure.win +++ b/R-package/configure.win @@ -6,9 +6,11 @@ ########################### R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R" -CXX=`"${R_EXE}" CMD config CXX11` -CXXFLAGS=`"${R_EXE}" CMD config CXXFLAGS` -CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS` +CXX11=`"${R_EXE}" CMD config CXX11` +CXX11STD=`"${R_EXE}" CMD config CXX11STD` +CXX="${CXX11} ${CXX11STD}" +CXXFLAGS=`"${R_EXE}" CMD config CXX11FLAGS` +CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS # LightGBM-specific flags LGB_CPPFLAGS="" From 04799cb06b3afd7c7fffd5dc9283aa65e7e3a8e9 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sat, 14 Aug 2021 11:07:52 -0500 Subject: [PATCH 6/6] missing backtick --- R-package/configure.win | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R-package/configure.win b/R-package/configure.win index 52a2709502e8..dfbaa3fc0377 100755 --- a/R-package/configure.win +++ b/R-package/configure.win @@ -10,7 +10,7 @@ CXX11=`"${R_EXE}" CMD config CXX11` CXX11STD=`"${R_EXE}" CMD config CXX11STD` CXX="${CXX11} ${CXX11STD}" CXXFLAGS=`"${R_EXE}" CMD config CXX11FLAGS` -CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS +CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS` # LightGBM-specific flags LGB_CPPFLAGS=""