From 9621a18b36bc350b10a1e2c83ac10b444fb3c412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sun, 19 Nov 2023 16:32:06 +0100 Subject: [PATCH] CI: Add runners that test building with only static libraries --- .github/workflows/build.yaml | 37 ++++++++++++++++++++------ .github/workflows/root-cmakelists.yaml | 36 +++++++++++++++++++------ 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 324d55ee64..cc761cbca3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -23,7 +23,7 @@ jobs: # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners runs-on: ubuntu-latest - name: ubuntu (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA ${{ matrix.openmp }} OpenMP) + name: ubuntu (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA ${{ matrix.openmp }} OpenMP, ${{ matrix.link }}) strategy: # Allow other runners in the matrix to continue if some fail @@ -33,6 +33,7 @@ jobs: compiler: [gcc, clang] cuda: [with, without] openmp: [with] + link: [both] include: - compiler: gcc compiler-pkgs: "g++ gcc" @@ -61,6 +62,22 @@ jobs: cuda: without openmp: without openmp-cmake-flags: "-DNOPENMP=ON" + - compiler: gcc + compiler-pkgs: "g++ gcc" + cc: "gcc" + cxx: "g++" + ccache-max: 600M + cuda: with + cuda-pkgs: "nvidia-cuda-dev nvidia-cuda-toolkit" + cuda-cmake-flags: + -DENABLE_CUDA=On + -DCUDAToolkit_INCLUDE_DIR="/usr/include" + -DCMAKE_CUDA_COMPILER_LAUNCHER="ccache" + openmp: with + link: static + link-cmake-flags: + -DBUILD_SHARED_LIBS=OFF + -DBUILD_STATIC_LIBS=ON env: CC: ${{ matrix.cc }} @@ -85,7 +102,7 @@ jobs: # used in action/cache/restore and action/cache/save steps id: ccache-prepare run: | - echo "key=ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT + echo "key=ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ matrix.link }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT - name: restore ccache # setup the GitHub cache used to maintain the ccache from one job to the next @@ -95,8 +112,8 @@ jobs: key: ${{ steps.ccache-prepare.outputs.key }} # Prefer caches from the same branch. Fall back to caches from the dev branch. restore-keys: | - ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ github.ref }} - ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}: + ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ matrix.link }}:${{ github.ref }} + ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ matrix.link }}: - name: create empty libraries # This is to work around a bug in nvlink. @@ -138,6 +155,7 @@ jobs: -DBLA_VENDOR="OpenBLAS" \ ${{ matrix.cuda-cmake-flags }} \ ${{ matrix.openmp-cmake-flags }} \ + ${{ matrix.link-cmake-flags }} \ .. echo "::endgroup::" echo "::group::Build $lib" @@ -186,16 +204,19 @@ jobs: -DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/lib/cmake" \ -DBLA_VENDOR="OpenBLAS" \ ${{ matrix.cuda-cmake-flags }} \ + ${{ matrix.link-cmake-flags }} \ .. echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Building example\n" cmake --build . echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Executing example\n" - printf "\033[1;35m C binary with shared libraries\033[0m\n" - LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo - printf "\033[1;35m C++ binary with shared libraries\033[0m\n" - LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo + if [ -f ./my_demo -a -f ./my_cxx_demo ]; then + printf "\033[1;35m C binary with shared libraries\033[0m\n" + LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo + printf "\033[1;35m C++ binary with shared libraries\033[0m\n" + LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo + fi printf "\033[1;35m C binary with statically linked libraries\033[0m\n" ./my_demo_static printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n" diff --git a/.github/workflows/root-cmakelists.yaml b/.github/workflows/root-cmakelists.yaml index 08641f11b9..5fc10ef12b 100644 --- a/.github/workflows/root-cmakelists.yaml +++ b/.github/workflows/root-cmakelists.yaml @@ -19,7 +19,7 @@ jobs: # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners runs-on: ubuntu-latest - name: ubuntu (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA) + name: ubuntu (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA, ${{ matrix.link }}) strategy: # Allow other runners in the matrix to continue if some fail @@ -28,6 +28,7 @@ jobs: matrix: compiler: [gcc, clang] cuda: [with, without] + link: [both] include: - compiler: gcc compiler-pkgs: "g++ gcc" @@ -48,6 +49,21 @@ jobs: -DENABLE_CUDA=ON -DCUDAToolkit_INCLUDE_DIR="/usr/include" -DCMAKE_CUDA_COMPILER_LAUNCHER="ccache" + - compiler: gcc + compiler-pkgs: "g++ gcc" + cc: "gcc" + cxx: "g++" + ccache-max: 600M + cuda: with + cuda-pkgs: "nvidia-cuda-dev nvidia-cuda-toolkit" + cuda-cmake-flags: + -DENABLE_CUDA=ON + -DCUDAToolkit_INCLUDE_DIR="/usr/include" + -DCMAKE_CUDA_COMPILER_LAUNCHER="ccache" + link: static + link-cmake-flags: + -DBUILD_SHARED_LIBS=OFF + -DBUILD_STATIC_LIBS=ON env: CC: ${{ matrix.cc }} @@ -72,7 +88,7 @@ jobs: # used in action/cache/restore and action/cache/save steps id: ccache-prepare run: | - echo "key=ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT + echo "key=ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.link }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT - name: restore ccache # setup the GitHub cache used to maintain the ccache from one job to the next @@ -82,8 +98,8 @@ jobs: key: ${{ steps.ccache-prepare.outputs.key }} # Prefer caches from the same branch. Fall back to caches from the dev branch. restore-keys: | - ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ github.ref }} - ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }} + ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.link }}:${{ github.ref }} + ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.link }} - name: create empty libraries # This is to work around a bug in nvlink. @@ -120,6 +136,7 @@ jobs: -DCMAKE_Fortran_COMPILER_LAUNCHER="ccache" \ -DBLA_VENDOR="OpenBLAS" \ ${{ matrix.cuda-cmake-flags }} \ + ${{ matrix.link-cmake-flags }} \ .. - name: build libraries @@ -170,16 +187,19 @@ jobs: -DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/lib/cmake" \ -DBLA_VENDOR="OpenBLAS" \ ${{ matrix.cuda-cmake-flags }} \ + ${{ matrix.link-cmake-flags }} \ .. echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Building example\n" cmake --build . echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Executing example\n" - printf "\033[1;35m C binary with shared libraries\033[0m\n" - LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo - printf "\033[1;35m C++ binary with shared libraries\033[0m\n" - LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo + if [ -f ./my_demo -a -f ./my_cxx_demo ]; then + printf "\033[1;35m C binary with shared libraries\033[0m\n" + LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo + printf "\033[1;35m C++ binary with shared libraries\033[0m\n" + LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo + fi printf "\033[1;35m C binary with statically linked libraries\033[0m\n" ./my_demo_static printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n"