Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sccache instead of ccache #25058

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,11 @@ jobs:
echo "DO_PUBLISH=$DO_PUBLISH" | tee -a $GITHUB_ENV
echo "UPLOAD_ARTIFACT_NAME=$UPLOAD_ARTIFACT_NAME" | tee -a $GITHUB_ENV

echo "CCACHE_TIMESTAMP=$(date -u +"%F-%T")" | tee -a $GITHUB_ENV

- name: Restore ccache files
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ${{github.workflow}}-ccache-${{ env.CCACHE_TIMESTAMP }}
restore-keys: ${{github.workflow}}-ccache-
- name: Setup ccache
- name: Install sccache
uses: mozilla-actions/[email protected]
- name: Enable sccache
run: |
sudo apt-get update && sudo apt-get install -y ccache
bash ./buildscripts/ci/tools/setup_ccache_config.sh
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV

- name: Setup environment
run: |
Expand All @@ -168,8 +161,6 @@ jobs:
run: |
C_URL=${SENTRY_URL}; if [ -z "$C_URL" ]; then C_URL="''"; fi
bash ./buildscripts/ci/linux/build.sh -n ${{ env.BUILD_NUMBER }} --crash_log_url $C_URL
echo "============== ccache ==============="
ccache -s
- name: Package
run: |
bash ./buildscripts/ci/linux/package.sh
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,11 @@ jobs:
echo "DO_PUBLISH=$DO_PUBLISH" | tee -a $GITHUB_ENV
echo "UPLOAD_ARTIFACT_NAME=$UPLOAD_ARTIFACT_NAME" | tee -a $GITHUB_ENV

echo "CCACHE_TIMESTAMP=$(date -u +"%F-%T")" | tee -a $GITHUB_ENV

- name: Restore ccache files
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ${{github.workflow}}-ccache-${{ env.CCACHE_TIMESTAMP }}
restore-keys: ${{github.workflow}}-ccache-
- name: Setup ccache
- name: Install sccache
uses: mozilla-actions/[email protected]
- name: Enable sccache
run: |
brew install ccache
bash ./buildscripts/ci/tools/setup_ccache_config.sh
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV

- name: Setup environment
run: |
Expand All @@ -183,8 +176,6 @@ jobs:
run: |
C_URL=${SENTRY_URL}; if [ -z "$C_URL" ]; then C_URL="''"; fi
bash ./buildscripts/ci/macos/build.sh -n ${{ env.BUILD_NUMBER }} --crash_log_url $C_URL
echo "============== ccache ==============="
ccache -s
- name: Package
run: |
S_S="${{ secrets.MAC_SIGN_CERTIFICATE_ENCRYPT_SECRET }}"; if [ -z "$S_S" ]; then S_S="''"; fi
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ jobs:
echo "DO_PUBLISH=$DO_PUBLISH" | tee -a $GITHUB_ENV
echo "UPLOAD_ARTIFACT_NAME=$UPLOAD_ARTIFACT_NAME" | tee -a $GITHUB_ENV

- name: Install sccache
uses: mozilla-actions/[email protected]
- name: Enable sccache
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV

- name: Setup environment
run: |
buildscripts\ci\windows\setup.bat
Expand Down Expand Up @@ -277,6 +283,12 @@ jobs:
echo "DO_PUBLISH=$DO_PUBLISH" | tee -a $GITHUB_ENV
echo "UPLOAD_ARTIFACT_NAME=$UPLOAD_ARTIFACT_NAME" | tee -a $GITHUB_ENV

- name: Install sccache
uses: mozilla-actions/[email protected]
- name: Enable sccache
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV

- name: Setup environment
run: |
buildscripts\ci\windows\setup.bat --portable ON
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/check_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,11 @@ jobs:

echo "BUILD_NUMBER=$BUILD_NUMBER" | tee -a $GITHUB_ENV

echo "CCACHE_TIMESTAMP=$(date -u +"%F-%T")" | tee -a $GITHUB_ENV

- name: Restore ccache files
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ${{github.workflow}}-ccache-${{ env.CCACHE_TIMESTAMP }}
restore-keys: ${{github.workflow}}-ccache-
- name: Setup ccache
- name: Install sccache
uses: mozilla-actions/[email protected]
- name: Enable sccache
run: |
sudo apt-get update && sudo apt-get install -y ccache
bash ./buildscripts/ci/tools/setup_ccache_config.sh
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV

- name: Setup environment
run: |
Expand All @@ -41,8 +34,6 @@ jobs:
run: |
mkdir -p build.artifacts/env
bash ./buildscripts/ci/linux/build_utest.sh -n ${{ env.BUILD_NUMBER }}
echo "============== ccache ==============="
ccache -s
- name: Free up disk space
# After building, too little disk space is left. Remove unnecessary tools to free up disk space.
run: |
Expand Down
34 changes: 8 additions & 26 deletions .github/workflows/check_visual_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,18 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Get ccache timestamp
run: echo "CCACHE_TIMESTAMP=$(date -u +"%F-%T")" | tee -a $GITHUB_ENV
- name: Restore ccache files
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ${{github.workflow}}-ccache-${{ env.CCACHE_TIMESTAMP }}
restore-keys: ${{github.workflow}}-ccache-
- name: Setup ccache
- name: Install sccache
uses: mozilla-actions/[email protected]
- name: Enable sccache
run: |
sudo apt-get update && sudo apt-get install -y ccache
bash ./buildscripts/ci/tools/setup_ccache_config.sh
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV

- name: Setup environment
run: |
bash ./buildscripts/ci/linux/setup.sh
- name: Build and Pack
run: |
bash ./buildscripts/ci/vtests/build_and_pack.sh
echo "============== ccache ==============="
ccache -s
- name: Upload
uses: actions/upload-artifact@v4
with:
Expand All @@ -104,27 +95,18 @@ jobs:
with:
ref: ${{ needs.setup.outputs.reference_sha }}

- name: Get ccache timestamp
run: echo "CCACHE_TIMESTAMP=$(date -u +"%F-%T")" | tee -a $GITHUB_ENV
- name: Restore ccache files
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ${{github.workflow}}-ccache-${{ env.CCACHE_TIMESTAMP }}
restore-keys: ${{github.workflow}}-ccache-
- name: Setup ccache
- name: Install sccache
uses: mozilla-actions/[email protected]
- name: Enable sccache
run: |
sudo apt-get update && sudo apt-get install -y ccache
bash ./buildscripts/ci/tools/setup_ccache_config.sh
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV

- name: Setup environment
run: |
bash ./buildscripts/ci/linux/setup.sh
- name: Build and Pack
run: |
bash ./buildscripts/ci/vtests/build_and_pack.sh
echo "============== ccache ==============="
ccache -s
- name: Upload
uses: actions/upload-artifact@v4
with:
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ set(MUE_VTEST_MSCORE_REF_BIN "${CMAKE_CURRENT_LIST_DIR}/../MU_ORIGIN/MuseScore/b
# === Compile ===
option(MUE_COMPILE_INSTALL_QTQML_FILES "Whether to bundle qml files along with the installation (relevant on macOS only)" ON)
option(MUE_COMPILE_USE_UNITY "Use unity build." ON)
option(MUE_COMPILE_USE_CCACHE "Try use ccache" ON)
option(MUE_COMPILE_USE_COMPILER_CACHE "Try to use compiler cache: tries sccache, ccache, buildcache in that order. Use COMPILER_CACHE_PROGRAM to specify a specific compiler cache program." ON)
option(MUE_COMPILE_USE_SHARED_LIBS_IN_DEBUG "Build shared libs if possible in debug" OFF)
option(MUE_COMPILE_MACOS_PRECOMPILED_DEPS_PATH "Path to precompiled dependencies (macOS only; optional: if not specified, some libraries will be used from the system and others will be built from source)" "")

Expand Down Expand Up @@ -134,9 +134,10 @@ set(THIRDPARTY_DIR ${PROJECT_SOURCE_DIR}/thirdparty)

include(SetupBuildEnvironment)
include(GetPlatformInfo)
if (MUE_COMPILE_USE_CCACHE)
include(TryUseCcache)
endif(MUE_COMPILE_USE_CCACHE)

if (MUE_COMPILE_USE_COMPILER_CACHE)
include(SetupCompilerCache)
endif(MUE_COMPILE_USE_COMPILER_CACHE)


###########################################
Expand Down
36 changes: 0 additions & 36 deletions buildscripts/ci/tools/setup_ccache_config.sh

This file was deleted.

63 changes: 63 additions & 0 deletions buildscripts/cmake/SetupCompilerCache.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# SPDX-License-Identifier: GPL-3.0-only
# MuseScore-Studio-CLA-applies
#
# MuseScore Studio
# Music Composition & Notation
#
# Copyright (C) 2024 MuseScore Limited
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

if (CMAKE_C_COMPILER_LAUNCHER OR CMAKE_CXX_COMPILER_LAUNCHER)
message(WARNING "CMAKE_C_COMPILER_LAUNCHER or CMAKE_CXX_COMPILER_LAUNCHER have already been set; not setting up compiler cache in order not to override them.")
return()
endif()

find_program(COMPILER_CACHE_PROGRAM sccache ccache buildcache)
if (NOT COMPILER_CACHE_PROGRAM)
message(STATUS "No compiler cache program found")
return()
endif()

if (CMAKE_GENERATOR MATCHES "Make" OR CMAKE_GENERATOR MATCHES "Ninja")
set(CMAKE_C_COMPILER_LAUNCHER "${COMPILER_CACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${COMPILER_CACHE_PROGRAM}")

set(ENV{CCACHE_CPP2} true)
set(ENV{CCACHE_SLOPPINESS} "pch_defines,time_macros")

message(STATUS "Using compiler cache program ${COMPILER_CACHE_PROGRAM} via CMAKE_C_COMPILER_LAUNCHER and CMAKE_CXX_COMPILER_LAUNCHER")
return()
endif()

if (CMAKE_GENERATOR STREQUAL "Xcode")
set(C_LAUNCHER "${COMPILER_CACHE_PROGRAM}")
set(CXX_LAUNCHER "${COMPILER_CACHE_PROGRAM}")
configure_file(${PROJECT_SOURCE_DIR}/buildscripts/tools/launch-c.in launch-c)
configure_file(${PROJECT_SOURCE_DIR}/buildscripts/tools/launch-cxx.in launch-cxx)
execute_process(COMMAND chmod a+rx
"${CMAKE_BINARY_DIR}/launch-c"
"${CMAKE_BINARY_DIR}/launch-cxx"
)

set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")

set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES "NO")
set(CMAKE_XCODE_ATTRIBUTE_COMPILER_INDEX_STORE_ENABLE "NO")

message(STATUS "Using compiler cache program ${COMPILER_CACHE_PROGRAM} with Xcode via wrapper scripts")
return()
endif()
56 changes: 0 additions & 56 deletions buildscripts/cmake/TryUseCcache.cmake

This file was deleted.

3 changes: 2 additions & 1 deletion buildscripts/tools/launch-c.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ if [ "$1" = "${CMAKE_C_COMPILER}" ] ; then
fi

export CCACHE_CPP2=true
exec "${C_LAUNCHER}" "${CMAKE_C_COMPILER}" "$@"
export CCACHE_SLOPPINESS="pch_defines,time_macros"
exec "${C_LAUNCHER}" "${CMAKE_C_COMPILER}" "$@"
3 changes: 2 additions & 1 deletion buildscripts/tools/launch-cxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ if [ "$1" = "${CMAKE_CXX_COMPILER}" ] ; then
fi

export CCACHE_CPP2=true
exec "${CXX_LAUNCHER}" "${CMAKE_CXX_COMPILER}" "$@"
export CCACHE_SLOPPINESS="pch_defines,time_macros"
exec "${CXX_LAUNCHER}" "${CMAKE_CXX_COMPILER}" "$@"
Loading