Unverified Commit 86ead205 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] use C++ compiler for pre-compile checks on Windows (#4504)



* [R-package] use C++ compiler for pre-compile checks on Windows

* install Matrix in valgrind test

* Add {Matrix} in more places in CI and docs

* use CXX11

* use flags specific to C++11

* missing backtick
Co-authored-by: default avatarNikita Titov <nekit94-12@hotmail.com>
parent 3c781ba0
#!/bin/bash #!/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 sh build-cran-package.sh || exit -1
RDvalgrind CMD INSTALL --preclean --install-tests lightgbm_*.tar.gz || exit -1 RDvalgrind CMD INSTALL --preclean --install-tests lightgbm_*.tar.gz || exit -1
......
...@@ -191,7 +191,7 @@ jobs: ...@@ -191,7 +191,7 @@ jobs:
- name: Install packages - name: Install packages
shell: bash shell: bash
run: | 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 sh build-cran-package.sh
Rdevel CMD INSTALL lightgbm_*.tar.gz || exit -1 Rdevel CMD INSTALL lightgbm_*.tar.gz || exit -1
- name: Run tests with sanitizers - name: Run tests with sanitizers
...@@ -221,7 +221,7 @@ jobs: ...@@ -221,7 +221,7 @@ jobs:
shell: bash shell: bash
run: | run: |
export PATH=/opt/R-devel/bin/:${PATH} 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 sh build-cran-package.sh
R CMD check --as-cran --run-donttest lightgbm_*.tar.gz || exit -1 R CMD check --as-cran --run-donttest lightgbm_*.tar.gz || exit -1
if grep -q -E "NOTE|WARNING|ERROR" lightgbm.Rcheck/00check.log; then if grep -q -E "NOTE|WARNING|ERROR" lightgbm.Rcheck/00check.log; then
......
...@@ -57,7 +57,7 @@ jobs: ...@@ -57,7 +57,7 @@ jobs:
- name: Install packages - name: Install packages
shell: bash shell: bash
run: | 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 sh build-cran-package.sh || exit -1
R CMD INSTALL --with-keep.source lightgbm_*.tar.gz || exit -1 R CMD INSTALL --with-keep.source lightgbm_*.tar.gz || exit -1
- name: Test documentation - name: Test documentation
......
...@@ -374,7 +374,7 @@ docker run \ ...@@ -374,7 +374,7 @@ docker run \
-it rhub/rocker-gcc-san \ -it rhub/rocker-gcc-san \
/bin/bash /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 sh build-cran-package.sh
...@@ -396,7 +396,7 @@ docker run \ ...@@ -396,7 +396,7 @@ docker run \
-it \ -it \
wch1/r-debug 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 sh build-cran-package.sh
......
...@@ -6,7 +6,11 @@ ...@@ -6,7 +6,11 @@
########################### ###########################
R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R" R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R"
CC=`"${R_EXE}" CMD config CC` 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 # LightGBM-specific flags
LGB_CPPFLAGS="" LGB_CPPFLAGS=""
...@@ -23,7 +27,7 @@ LGB_CPPFLAGS="${LGB_CPPFLAGS} -DEIGEN_MPL2_ONLY" ...@@ -23,7 +27,7 @@ LGB_CPPFLAGS="${LGB_CPPFLAGS} -DEIGEN_MPL2_ONLY"
ac_mm_prefetch="no" ac_mm_prefetch="no"
cat > conftest.c <<EOL cat > conftest.cpp <<EOL
#include <xmmintrin.h> #include <xmmintrin.h>
int main() { int main() {
int a = 0; int a = 0;
...@@ -32,7 +36,7 @@ int main() { ...@@ -32,7 +36,7 @@ int main() {
} }
EOL 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}" echo "checking whether MM_PREFETCH works...${ac_mm_prefetch}"
if test "${ac_mm_prefetch}" = "yes"; if test "${ac_mm_prefetch}" = "yes";
...@@ -45,7 +49,7 @@ fi ...@@ -45,7 +49,7 @@ fi
############ ############
ac_mm_malloc="no" ac_mm_malloc="no"
cat > conftest.c <<EOL cat > conftest.cpp <<EOL
#include <mm_malloc.h> #include <mm_malloc.h>
int main() { int main() {
char *a = (char*)_mm_malloc(8, 16); char *a = (char*)_mm_malloc(8, 16);
...@@ -54,7 +58,7 @@ int main() { ...@@ -54,7 +58,7 @@ int main() {
} }
EOL 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}" echo "checking whether MM_MALLOC works...${ac_mm_malloc}"
if test "${ac_mm_malloc}" = "yes"; if test "${ac_mm_malloc}" = "yes";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment