From 0664249ffc788f672856ce1198b545afa3519388 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 11 Jun 2020 13:18:07 +0200 Subject: [PATCH 1/4] ci: do the compiler-detection magic in the test script so we have all PPA definitions at one place. --- .github/workflows/build_test.yml | 21 ++-------- travis-ci/managers/ubuntu-build-check.sh | 53 +++++++++++++++++------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 2a6f0df9c4..a860092518 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -19,26 +19,11 @@ jobs: fail-fast: false matrix: env: - # As we use postfixed clang/gcc binaries, we need to override $AR - # as well, otherwise meson falls back to ar from binutils which - # doesn't work with LTO - - { CC: "clang-10", CXX: "clang++-10", AR: "llvm-ar-10" } - - { CC: "gcc-10", CXX: "g++-10", AR: "gcc-ar-10" } + - { COMPILER: "gcc", COMPILER_VERSION: "10" } + - { COMPILER: "clang", COMPILER_VERSION: "10" } env: ${{ matrix.env }} steps: - name: Repository checkout uses: actions/checkout@v1 - - name: Configure custom APT repositories for ${{ env.CC }} - run: | - if [[ "$CC" == clang-* ]]; then - # Latest LLVM stack deb packages provided by https://apt.llvm.org/ - sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" - sudo apt-get install clang-10 llvm-10 - else - # Latest gcc stack deb packages provided by - # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo apt-get install gcc-10 - fi - - name: Build check (${{ env.CC }}) + - name: Build check (${{ env.COMPILER }}-${{ env.COMPILER_VERSION }}) run: sudo -E travis-ci/managers/ubuntu-build-check.sh diff --git a/travis-ci/managers/ubuntu-build-check.sh b/travis-ci/managers/ubuntu-build-check.sh index c2a7feee60..a2fade9de3 100755 --- a/travis-ci/managers/ubuntu-build-check.sh +++ b/travis-ci/managers/ubuntu-build-check.sh @@ -1,9 +1,9 @@ #!/bin/bash -set -e +set -ex info() { echo -e "\033[33;1m$1\033[0m"; } -error() { echo >&2 -e "\033[31;1m$1\033[0m"; } +fatal() { echo >&2 -e "\033[31;1m$1\033[0m"; exit 1; } success() { echo >&2 -e "\033[32;1m$1\033[0m"; } ARGS=( @@ -41,7 +41,6 @@ PACKAGES=( libzstd-dev mount net-tools - ninja-build perl python-lxml python3-evdev @@ -55,21 +54,45 @@ PACKAGES=( util-linux zstd ) -CC="${CC:?}" -CXX="${CXX:?}" -AR="${AR:-""}" +COMPILER="${COMPILER:?}" +COMPILER_VERSION="${COMPILER_VERSION:?}" RELEASE="$(lsb_release -cs)" bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse' >>/etc/apt/sources.list" +# Note: As we use postfixed clang/gcc binaries, we need to override $AR +# as well, otherwise meson falls back to ar from binutils which +# doesn't work with LTO +if [[ "$COMPILER" == clang ]]; then + CC="clang-$COMPILER_VERSION" + CXX="clang++-$COMPILER_VERSION" + AR="llvm-ar-$COMPILER_VERSION" + # Latest LLVM stack deb packages provided by https://apt.llvm.org/ + # Following snippet was borrowed from https://apt.llvm.org/llvm.sh + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - + add-apt-repository -y "deb http://apt.llvm.org/$RELEASE/ llvm-toolchain-$RELEASE-$COMPILER_VERSION main" + apt-get -y update + apt-get -y install clang-$COMPILER_VERSION lldb-$COMPILER_VERSION lld-$COMPILER_VERSION clangd-$COMPILER_VERSION +elif [[ "$COMPILER" == gcc ]]; then + CC="gcc-$COMPILER_VERSION" + CXX="g++-$COMPILER_VERSION" + AR="gcc-ar-$COMPILER_VERSION" + # Latest gcc stack deb packages provided by + # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + apt-get -y update + sudo apt-get -y install gcc-$COMPILER_VERSION +else + fatal "Unknown compiler: $COMPILER" +fi + # PPA with some newer build dependencies (like zstd) add-apt-repository -y ppa:upstream-systemd-ci/systemd-ci -apt-get update -apt-get build-dep systemd -y -apt-get install -y "${PACKAGES[@]}" -# Install latest meson from pip, as the distro-one doesn't support -# --optimization= -pip3 install meson +apt-get -y build-dep systemd +apt-get -y install "${PACKAGES[@]}" +# Install latest meson and ninja form pip, since the distro versions don't +# support all the features we need (like --optimization=) +pip3 install meson ninja $CC --version @@ -78,13 +101,11 @@ for args in "${ARGS[@]}"; do info "Checking build with $args" if ! AR="$AR" CC="$CC" CXX="$CXX" meson --werror $args build; then - error "meson failed with $args" - exit 1 + fatal "meson failed with $args" fi if ! ninja -C build; then - error "ninja failed with $args" - exit 1 + fatal "ninja failed with $args" fi git clean -dxf From 4e1a13db899b89272bb4b6d6a51451cdfe2966d5 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 11 Jun 2020 13:29:01 +0200 Subject: [PATCH 2/4] ci: move the build check script to workflows directory --- .github/workflows/build_test.yml | 5 ++--- .../managers => .github/workflows}/ubuntu-build-check.sh | 0 2 files changed, 2 insertions(+), 3 deletions(-) rename {travis-ci/managers => .github/workflows}/ubuntu-build-check.sh (100%) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index a860092518..3b86689d27 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -10,7 +10,6 @@ on: - 'meson_options.txt' - 'src/**' - 'test/fuzz/**' - - 'travis-ci/managers/ubuntu-build-check.sh' jobs: build: @@ -19,11 +18,11 @@ jobs: fail-fast: false matrix: env: - - { COMPILER: "gcc", COMPILER_VERSION: "10" } + - { COMPILER: "gcc", COMPILER_VERSION: "10" } - { COMPILER: "clang", COMPILER_VERSION: "10" } env: ${{ matrix.env }} steps: - name: Repository checkout uses: actions/checkout@v1 - name: Build check (${{ env.COMPILER }}-${{ env.COMPILER_VERSION }}) - run: sudo -E travis-ci/managers/ubuntu-build-check.sh + run: sudo -E .github/workflows/ubuntu-build-check.sh diff --git a/travis-ci/managers/ubuntu-build-check.sh b/.github/workflows/ubuntu-build-check.sh similarity index 100% rename from travis-ci/managers/ubuntu-build-check.sh rename to .github/workflows/ubuntu-build-check.sh From 3d0a45d5dae3945919b48aedc005732bfae2fe3d Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 11 Jun 2020 14:21:02 +0200 Subject: [PATCH 3/4] ci: tweak the compilation options Build each build with tests (slow tests and fuzzer tests as well), and combine the LTO build with -O3. --- .github/workflows/ubuntu-build-check.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ubuntu-build-check.sh b/.github/workflows/ubuntu-build-check.sh index a2fade9de3..4b9f689047 100755 --- a/.github/workflows/ubuntu-build-check.sh +++ b/.github/workflows/ubuntu-build-check.sh @@ -9,9 +9,9 @@ success() { echo >&2 -e "\033[32;1m$1\033[0m"; } ARGS=( "--optimization=0" "--optimization=2" - "--optimization=3" "--optimization=s" - "-Db_lto=true" + "--optimization=3 -Db_lto=true" + "--optimization=3 -Db_lto=false" "-Db_ndebug=true" ) PACKAGES=( @@ -100,7 +100,7 @@ for args in "${ARGS[@]}"; do SECONDS=0 info "Checking build with $args" - if ! AR="$AR" CC="$CC" CXX="$CXX" meson --werror $args build; then + if ! AR="$AR" CC="$CC" CXX="$CXX" meson -Dtests=unsafe -Dslow-tests=true --werror $args build; then fatal "meson failed with $args" fi From 86a23f38abd902e767c1a89696ce98ee19df864c Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 11 Jun 2020 15:00:15 +0200 Subject: [PATCH 4/4] ci: tweak the dependency installation --- .github/workflows/ubuntu-build-check.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ubuntu-build-check.sh b/.github/workflows/ubuntu-build-check.sh index 4b9f689047..fb7c71ecb8 100755 --- a/.github/workflows/ubuntu-build-check.sh +++ b/.github/workflows/ubuntu-build-check.sh @@ -71,8 +71,7 @@ if [[ "$COMPILER" == clang ]]; then # Following snippet was borrowed from https://apt.llvm.org/llvm.sh wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - add-apt-repository -y "deb http://apt.llvm.org/$RELEASE/ llvm-toolchain-$RELEASE-$COMPILER_VERSION main" - apt-get -y update - apt-get -y install clang-$COMPILER_VERSION lldb-$COMPILER_VERSION lld-$COMPILER_VERSION clangd-$COMPILER_VERSION + PACKAGES+=(clang-$COMPILER_VERSION lldb-$COMPILER_VERSION lld-$COMPILER_VERSION clangd-$COMPILER_VERSION) elif [[ "$COMPILER" == gcc ]]; then CC="gcc-$COMPILER_VERSION" CXX="g++-$COMPILER_VERSION" @@ -80,19 +79,22 @@ elif [[ "$COMPILER" == gcc ]]; then # Latest gcc stack deb packages provided by # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - apt-get -y update - sudo apt-get -y install gcc-$COMPILER_VERSION + PACKAGES+=(gcc-$COMPILER_VERSION) else fatal "Unknown compiler: $COMPILER" fi # PPA with some newer build dependencies (like zstd) add-apt-repository -y ppa:upstream-systemd-ci/systemd-ci +apt-get -y update apt-get -y build-dep systemd apt-get -y install "${PACKAGES[@]}" -# Install latest meson and ninja form pip, since the distro versions don't -# support all the features we need (like --optimization=) -pip3 install meson ninja +# Install the latest meson and ninja form pip, since the distro versions don't +# support all the features we need (like --optimization=). Since the build-dep +# command above installs the distro versions, let's install the pip ones just +# locally and add the local bin directory to the $PATH. +pip3 install --user -U meson ninja +export PATH="$HOME/.local/bin:$PATH" $CC --version @@ -104,6 +106,7 @@ for args in "${ARGS[@]}"; do fatal "meson failed with $args" fi + ninja --version if ! ninja -C build; then fatal "ninja failed with $args" fi