From 340c96fd56e779be75cc384d6d74311b847c5ee3 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sun, 21 Jan 2024 11:49:23 +0100 Subject: [PATCH] build: also build static binaries with -O2 --- .docker/build-linux.sh | 68 ++++++++++++++++++++----------------- .github/workflows/build.yml | 2 ++ 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/.docker/build-linux.sh b/.docker/build-linux.sh index 86ab8d6b..ea3960fc 100644 --- a/.docker/build-linux.sh +++ b/.docker/build-linux.sh @@ -77,6 +77,10 @@ case "-$BUILD_TYPE-" in exit 1 esac +if [[ "-$BUILD_TYPE-" == *-O2-* ]]; then + CMAKE_ARGS="${CMAKE_ARGS} -DDWARFS_OPTIMIZE=2" +fi + if [[ "-$BUILD_TYPE-" == *-nojemalloc-* ]]; then CMAKE_ARGS="${CMAKE_ARGS} -DUSE_JEMALLOC=0" fi @@ -117,40 +121,42 @@ if [[ "-$BUILD_TYPE-" == *-coverage-* ]]; then fi if [[ "-$BUILD_TYPE-" == *-static-* ]]; then - # in the clang-release-static case, we also try to build from the source tarball - if [[ "-$BUILD_TYPE-" == *-release-* ]] && [[ "-$BUILD_TYPE-" == *-clang-* ]]; then - $BUILD_TOOL package_source + if [[ "-$BUILD_TYPE-" == *-release-* ]]; then + # in the clang-release-static case, we also try to build from the source tarball + if [[ "-$BUILD_TYPE-" == *-clang-* ]] && [[ "-$BUILD_TYPE-" != *-O2-* ]]; then + $BUILD_TOOL package_source - if [[ "$BUILD_ARCH" == "amd64" ]]; then - $BUILD_TOOL copy_source_artifacts + if [[ "$BUILD_ARCH" == "amd64" ]]; then + $BUILD_TOOL copy_source_artifacts + fi + + $BUILD_TOOL realclean + + cd "$HOME" + + VERSION=$(git -C /workspace describe --tags --match "v*" --dirty --abbrev=10) + VERSION=${VERSION:1} + + rm -rf dwarfs-* + rm -f dwarfs + + mv "build/dwarfs-${VERSION}.tar.zst" . + rm -rf build + + tar xvf "dwarfs-${VERSION}.tar.zst" + mv "dwarfs-${VERSION}" dwarfs + + mkdir build + cd build + + # shellcheck disable=SC2086 + cmake ../dwarfs/ $CMAKE_ARGS + + $BUILD_TOOL + + ctest --output-on-failure -j$(nproc) fi - $BUILD_TOOL realclean - - cd "$HOME" - - VERSION=$(git -C /workspace describe --tags --match "v*" --dirty --abbrev=10) - VERSION=${VERSION:1} - - rm -rf dwarfs-* - rm -f dwarfs - - mv "build/dwarfs-${VERSION}.tar.zst" . - rm -rf build - - tar xvf "dwarfs-${VERSION}.tar.zst" - mv "dwarfs-${VERSION}" dwarfs - - mkdir build - cd build - - # shellcheck disable=SC2086 - cmake ../dwarfs/ $CMAKE_ARGS - - $BUILD_TOOL - - ctest --output-on-failure -j$(nproc) - $BUILD_TOOL strip fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a7c19c4..8398fdfd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -106,7 +106,9 @@ jobs: - oldgcc-debug-make - clang-release-ninja - gcc-release-ninja-static + - gcc-release-ninja-O2-static - clang-release-ninja-static + - clang-release-ninja-O2-static - clang-reldbg-ninja-static - clang-debug-ninja-static include: