From 255c93b551c13b5d9b0bd8eff83ef828b14b9547 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 16 Jan 2024 21:27:59 -0800 Subject: [PATCH] [R-package] [ci] remove unnecessary include in linear_tree_learner (fixes #6264) (#6265) --- .ci/install-clang-devel.sh | 71 +++++++++++++++++++++++++++ .github/workflows/r_package.yml | 59 +++++++--------------- src/treelearner/linear_tree_learner.h | 1 - 3 files changed, 90 insertions(+), 41 deletions(-) create mode 100755 .ci/install-clang-devel.sh diff --git a/.ci/install-clang-devel.sh b/.ci/install-clang-devel.sh new file mode 100755 index 000000000000..a175617852c7 --- /dev/null +++ b/.ci/install-clang-devel.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# [description] +# +# Installs a development version of clang and the other LLVM tools. +# + +set -e -E -u -o pipefail + +CLANG_VERSION=${1} + +apt-get autoremove -y --purge \ + clang-* \ + libclang-* \ + libunwind-* \ + llvm-* + +apt-get update -y +apt-get install --no-install-recommends -y \ + gnupg \ + lsb-release \ + software-properties-common \ + wget + +wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - + +# ref: https://apt.llvm.org/ +add-apt-repository -y "deb http://apt.llvm.org/unstable/ llvm-toolchain main" +add-apt-repository -y "deb-src http://apt.llvm.org/unstable/ llvm-toolchain main" + +apt-get install -y --no-install-recommends \ + clang-${CLANG_VERSION} \ + clangd-${CLANG_VERSION} \ + clang-format-${CLANG_VERSION} \ + clang-tidy-${CLANG_VERSION} \ + clang-tools-${CLANG_VERSION} \ + lldb-${CLANG_VERSION} \ + lld-${CLANG_VERSION} \ + llvm-${CLANG_VERSION}-dev \ + llvm-${CLANG_VERSION}-tools \ + libomp-${CLANG_VERSION}-dev \ + libc++-${CLANG_VERSION}-dev \ + libc++abi-${CLANG_VERSION}-dev \ + libclang-common-${CLANG_VERSION}-dev \ + libclang-${CLANG_VERSION}-dev \ + libclang-cpp${CLANG_VERSION}-dev \ + libunwind-${CLANG_VERSION}-dev + +# overwriting the stuff in /usr/bin is simpler and more reliable than +# updating PATH, LD_LIBRARY_PATH, etc. +cp --remove-destination /usr/lib/llvm-${CLANG_VERSION}/bin/* /usr/bin/ + +# per https://www.stats.ox.ac.uk/pub/bdr/Rconfig/r-devel-linux-x86_64-fedora-clang +# +# clang was built to use libc++: for a version built to default to libstdc++ +# (as shipped by Fedora/Debian/Ubuntu), add -stdlib=libc++ to CXX +# and install the libcxx-devel/libc++-dev package. +mkdir -p "${HOME}/.R" + +cat << EOF > "${HOME}/.R/Makevars" +CXX += -stdlib=libc++ +CXX11 += -stdlib=libc++ +CXX14 += -stdlib=libc++ +CXX17 += -stdlib=libc++ +CXX20 += -stdlib=libc++ +EOF + +echo "" +echo "done installing clang" +clang --version +echo "" diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 4fa7f2ff8683..f154c822ecc6 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -258,10 +258,21 @@ jobs: cat ./tests.log exit ${exit_code} test-r-debian-clang: - name: r-package (debian, R-devel, clang) + name: r-package (debian, R-devel, clang-${{ matrix.clang-version }}) timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + # list of versions tested in CRAN "Additional Checks": + # https://cran.r-project.org/web/checks/check_issue_kinds.html + clang-version: + - 16 + - 17 + - 18 runs-on: ubuntu-latest container: rhub/debian-clang-devel + env: + DEBIAN_FRONTEND: noninteractive steps: - name: Install Git before checkout shell: bash @@ -276,46 +287,9 @@ jobs: with: fetch-depth: 5 submodules: true - - name: update to clang 15 - shell: bash + - name: install clang run: | - # remove clang stuff that comes installed in the image - apt-get autoremove -y --purge \ - clang-* \ - libclang-* \ - libunwind-* \ - llvm-* - # - # replace it all with clang-15 - apt-get update -y - apt-get install --no-install-recommends -y \ - gnupg \ - lsb-release \ - software-properties-common \ - wget - # - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - - # - add-apt-repository "deb http://apt.llvm.org/unstable/ llvm-toolchain main" - apt-get install -y --no-install-recommends \ - clang-15 \ - clangd-15 \ - clang-format-15 \ - clang-tidy-15 \ - clang-tools-15 \ - lldb-15 \ - lld-15 \ - llvm-15-dev \ - llvm-15-tools \ - libomp-15-dev \ - libc++-15-dev \ - libc++abi-15-dev \ - libclang-common-15-dev \ - libclang-15-dev \ - libclang-cpp15-dev \ - libunwind-15-dev - # overwrite everything in /usr/bin with the new v15 versions - cp --remove-destination /usr/lib/llvm-15/bin/* /usr/bin/ + ./.ci/install-clang-devel.sh ${{ matrix.clang-version }} - name: Install packages and run tests shell: bash run: | @@ -323,6 +297,11 @@ jobs: Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'RhpcBLASctl', 'testthat'), repos = 'https://cran.rstudio.com', Ncpus = parallel::detectCores())" sh build-cran-package.sh R CMD check --as-cran --run-donttest lightgbm_*.tar.gz || exit -1 + echo "" + echo "install logs:" + echo "" + cat lightgbm.Rcheck/00install.out + echo "" if grep -q -E "NOTE|WARNING|ERROR" lightgbm.Rcheck/00check.log; then echo "NOTEs, WARNINGs, or ERRORs have been found by R CMD check" exit -1 diff --git a/src/treelearner/linear_tree_learner.h b/src/treelearner/linear_tree_learner.h index 770b18d133e5..e20a80ad42d3 100644 --- a/src/treelearner/linear_tree_learner.h +++ b/src/treelearner/linear_tree_learner.h @@ -5,7 +5,6 @@ #ifndef LIGHTGBM_TREELEARNER_LINEAR_TREE_LEARNER_H_ #define LIGHTGBM_TREELEARNER_LINEAR_TREE_LEARNER_H_ -#include #include #include #include