From bca2bcfec92d34947e40c03a3cf0af1ef4ce35b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michel=20D=C3=A4nzer?= Date: Tue, 14 Mar 2023 09:38:18 +0100 Subject: [PATCH] ci: Make ccache optional Part-of: --- .gitlab-ci/build/g++-link-werror.sh | 15 ++++++++ .gitlab-ci/build/gcc-link-werror.sh | 15 ++++++++ .gitlab-ci/build/gitlab-ci.yml | 12 ++++--- .../build/meson-native-lto-wrappers-ccache.txt | 3 ++ .gitlab-ci/build/meson-native-lto-wrappers.txt | 4 +-- .gitlab-ci/container/container_post_build.sh | 4 ++- .gitlab-ci/container/container_pre_build.sh | 40 ++++++++++++---------- 7 files changed, 66 insertions(+), 27 deletions(-) create mode 100755 .gitlab-ci/build/g++-link-werror.sh create mode 100755 .gitlab-ci/build/gcc-link-werror.sh create mode 100644 .gitlab-ci/build/meson-native-lto-wrappers-ccache.txt diff --git a/.gitlab-ci/build/g++-link-werror.sh b/.gitlab-ci/build/g++-link-werror.sh new file mode 100755 index 0000000..5aa9f84 --- /dev/null +++ b/.gitlab-ci/build/g++-link-werror.sh @@ -0,0 +1,15 @@ +#!/bin/sh -e + +if [ "$(ps -p $(ps -p $PPID -o ppid --no-headers) -o comm --no-headers)" != ninja ]; then + # Not invoked by ninja (e.g. for a meson feature check) + exec g++ "$@" +fi + +if [ "$(eval printf "'%s'" "\"\${$(($#-1))}\"")" = "-c" ]; then + # Not invoked for linking + exec g++ "$@" +fi + +# Compiler invoked by ninja for linking. Add -Werror to turn compiler warnings into errors +# with LTO. (meson's werror should arguably do this, but meanwhile we need to) +exec g++ "$@" -Werror diff --git a/.gitlab-ci/build/gcc-link-werror.sh b/.gitlab-ci/build/gcc-link-werror.sh new file mode 100755 index 0000000..aa92a41 --- /dev/null +++ b/.gitlab-ci/build/gcc-link-werror.sh @@ -0,0 +1,15 @@ +#!/bin/sh -e + +if [ "$(ps -p $(ps -p $PPID -o ppid --no-headers) -o comm --no-headers)" != ninja ]; then + # Not invoked by ninja (e.g. for a meson feature check) + exec gcc "$@" +fi + +if [ "$(eval printf "'%s'" "\"\${$(($#-1))}\"")" = "-c" ]; then + # Not invoked for linking + exec gcc "$@" +fi + +# Compiler invoked by ninja for linking. Add -Werror to turn compiler warnings into errors +# with LTO. (meson's werror should arguably do this, but meanwhile we need to) +exec gcc "$@" -Werror diff --git a/.gitlab-ci/build/gitlab-ci.yml b/.gitlab-ci/build/gitlab-ci.yml index fd799eb..2b107d1 100644 --- a/.gitlab-ci/build/gitlab-ci.yml +++ b/.gitlab-ci/build/gitlab-ci.yml @@ -25,11 +25,13 @@ - | export PATH="/usr/lib/ccache:$PATH" export CCACHE_BASEDIR="$PWD" - section_start ccache_before "ccache stats before build" - ccache --show-stats - section_end ccache_before + if test -x /usr/bin/ccache; then + section_start ccache_before "ccache stats before build" + ccache --show-stats + section_end ccache_before + fi after_script: - - ccache --show-stats | grep "cache hit rate" + - if test -x /usr/bin/ccache; then ccache --show-stats | grep "cache hit rate"; fi - !reference [default, after_script] .build-windows: @@ -182,7 +184,7 @@ debian-build-testing: GALLIUM_DRIVERS: "iris,nouveau,kmsro,r300,r600,freedreno,swrast,svga,v3d,vc4,virgl,etnaviv,panfrost,lima,zink,d3d12,asahi,crocus" VULKAN_DRIVERS: swrast EXTRA_OPTION: > - --native-file .gitlab-ci/build/meson-native-lto-wrappers.txt + --native-file .gitlab-ci/build/meson-native-lto-wrappers-ccache.txt -D spirv-to-dxil=true -D osmesa=true -D tools=drm-shim,etnaviv,freedreno,glsl,intel,intel-ui,nir,nouveau,lima,panfrost,asahi diff --git a/.gitlab-ci/build/meson-native-lto-wrappers-ccache.txt b/.gitlab-ci/build/meson-native-lto-wrappers-ccache.txt new file mode 100644 index 0000000..e17f64f --- /dev/null +++ b/.gitlab-ci/build/meson-native-lto-wrappers-ccache.txt @@ -0,0 +1,3 @@ +[binaries] +c = 'ccache-gcc-link-werror.sh' +cpp = 'ccache-g++-link-werror.sh' diff --git a/.gitlab-ci/build/meson-native-lto-wrappers.txt b/.gitlab-ci/build/meson-native-lto-wrappers.txt index e17f64f..7bdd293 100644 --- a/.gitlab-ci/build/meson-native-lto-wrappers.txt +++ b/.gitlab-ci/build/meson-native-lto-wrappers.txt @@ -1,3 +1,3 @@ [binaries] -c = 'ccache-gcc-link-werror.sh' -cpp = 'ccache-g++-link-werror.sh' +c = 'gcc-link-werror.sh' +cpp = 'g++-link-werror.sh' diff --git a/.gitlab-ci/container/container_post_build.sh b/.gitlab-ci/container/container_post_build.sh index 818dc1e..498274f 100755 --- a/.gitlab-ci/container/container_post_build.sh +++ b/.gitlab-ci/container/container_post_build.sh @@ -7,4 +7,6 @@ fi # Clean up any build cache for rust. rm -rf /.cargo -ccache --show-stats +if test -x /usr/bin/ccache; then + ccache --show-stats +fi diff --git a/.gitlab-ci/container/container_pre_build.sh b/.gitlab-ci/container/container_pre_build.sh index 5490e5f..7df5ebf 100755 --- a/.gitlab-ci/container/container_pre_build.sh +++ b/.gitlab-ci/container/container_pre_build.sh @@ -1,24 +1,28 @@ #!/bin/sh -if test -f /etc/debian_version; then - CCACHE_PATH=/usr/lib/ccache -elif test -f /etc/alpine-release; then - CCACHE_PATH=/usr/lib/ccache/bin -else - CCACHE_PATH=/usr/lib64/ccache +if test -x /usr/bin/ccache; then + if test -f /etc/debian_version; then + CCACHE_PATH=/usr/lib/ccache + elif test -f /etc/alpine-release; then + CCACHE_PATH=/usr/lib/ccache/bin + else + CCACHE_PATH=/usr/lib64/ccache + fi + + # Common setup among container builds before we get to building code. + + export CCACHE_COMPILERCHECK=content + export CCACHE_COMPRESS=true + export CCACHE_DIR=/cache/$CI_PROJECT_NAME/ccache + export PATH=$CCACHE_PATH:$PATH + + # CMake ignores $PATH, so we have to force CC/GCC to the ccache versions. + export CC="${CCACHE_PATH}/gcc" + export CXX="${CCACHE_PATH}/g++" + + ccache --show-stats fi -# Common setup among container builds before we get to building code. - -export CCACHE_COMPILERCHECK=content -export CCACHE_COMPRESS=true -export CCACHE_DIR=/cache/$CI_PROJECT_NAME/ccache -export PATH=$CCACHE_PATH:$PATH - -# CMake ignores $PATH, so we have to force CC/GCC to the ccache versions. -export CC="${CCACHE_PATH}/gcc" -export CXX="${CCACHE_PATH}/g++" - # When not using the mold linker (e.g. unsupported architecture), force # linkers to gold, since it's so much faster for building. We can't use # lld because we're on old debian and it's buggy. ming fails meson builds @@ -27,8 +31,6 @@ find /usr/bin -name \*-ld -o -name ld | \ grep -v mingw | \ xargs -n 1 -I '{}' ln -sf '{}.gold' '{}' -ccache --show-stats - # Make a wrapper script for ninja to always include the -j flags { echo '#!/bin/sh -x' -- 2.7.4