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 on Windows #3618

Merged
merged 7 commits into from
Feb 26, 2021
Merged
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
55 changes: 41 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ jobs:
# TODO: Fix these broken tests on Windows
ctest_args: --exclude-regex '^AutoDJProcessorTest.*$'
cpack_generator: WIX
compiler_cache: clcache
compiler_cache_path: ${{ github.workspace }}\clcache
compiler_cache: sccache
compiler_cache_path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\cache
uklotzde marked this conversation as resolved.
Show resolved Hide resolved
buildenv_basepath: C:\buildenv
buildenv_script: tools/windows_buildenv.bat
artifacts_name: Windows Installer
Expand All @@ -103,6 +103,26 @@ jobs:
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
steps:

# sccache's handling of the /fp:fast MSVC compiler option is broken, so use our fork with the fix.
# https://github.com/mozilla/sccache/issues/950
- name: "[Windows] Set up cargo cache"
if: runner.os == 'Windows'
uses: actions/cache@v2
id: sccache-build-cache
with:
path: C:\Users\runneradmin\.cargo
uklotzde marked this conversation as resolved.
Show resolved Hide resolved
# hash of commit to build
key: e12434e4db24ccbe52b83fb6e37afcb94fc8d37b

# This needs to be done first because something later messes with $PATH in a way that breaks cargo
# by causing it to find link.exe from Git for Windows instead of MSVC.
- name: "[Windows] Build fixed sccache"
shell: bash
if: runner.os == 'Windows' && steps.sccache-build-cache.outputs.cache-hit != 'true'
# TODO: change this to simply `cargo install sccache` when this branch is merged upstream
run: cargo install --git https://github.com/Be-ing/sccache.git --branch fix_msvc_fp
uklotzde marked this conversation as resolved.
Show resolved Hide resolved

- name: "Check out repository"
uses: actions/checkout@v2
with:
Expand All @@ -115,15 +135,6 @@ jobs:
# our CMakeLists.txt
cmake-version: '3.13.x'

- name: "[Windows] Install additional build tools"
if: runner.os == 'Windows'
# TODO: Add ninja, clcache and rsync to the windows buildenv
run: |
python -m pip install ninja git+https://github.com/frerich/clcache.git
$Env:PATH="C:\msys64\usr\bin;$Env:PATH"
pacman -S --noconfirm coreutils bash rsync openssh
Add-Content -Path "$Env:GITHUB_ENV" -Value "PATH=$Env:PATH"

- name: "[Windows] Set up MSVC Developer Command Prompt"
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-vsdevenv@v3
Expand Down Expand Up @@ -182,9 +193,10 @@ jobs:
env:
BUILDENV_BASEPATH: ${{ matrix.buildenv_basepath }}

- name: "Set compiler cache size limit"
- name: "[Ubuntu/macOS] Set compiler cache size limit"
# Set size to 2 GiB
run: ${{ matrix.compiler_cache }} -M 2097152
if: runner.os != 'windows'

- name: "Set up compiler cache"
uses: actions/cache@v2
Expand Down Expand Up @@ -238,8 +250,7 @@ jobs:
CMAKE_BUILD_PARALLEL_LEVEL: 2
# GitHub Actions automatically zstd compresses caches
CCACHE_NOCOMPRESS: true
CLCACHE_COMPRESS: false
CLCACHE_HARDLINK: true
SCCACHE_CACHE_SIZE: 2G

- name: "Print compiler cache stats"
run: ${{ matrix.compiler_cache }} -s
Expand Down Expand Up @@ -299,6 +310,15 @@ jobs:
run: signtool sign /f $Env:WINDOWS_CODESIGN_CERTIFICATE_PATH /p $Env:WINDOWS_CODESIGN_CERTIFICATE_PASSWORD *.msi
working-directory: build

- name: "[Windows] Install rsync and openssh"
env:
SSH_PASSWORD: ${{ secrets.DOWNLOADS_HOSTGATOR_DOT_MIXXX_DOT_ORG_KEY_PASSWORD }}
if: runner.os == 'Windows' && env.SSH_PASSWORD != null
run: |
$Env:PATH="C:\msys64\usr\bin;$Env:PATH"
pacman -S --noconfirm coreutils bash rsync openssh
Add-Content -Path "$Env:GITHUB_ENV" -Value "PATH=$Env:PATH"

- name: "[macOS/Windows] Upload build to downloads.mixxx.org"
# skip deploying Ubuntu builds to downloads.mixxx.org because these are deployed to the PPA
if: runner.os != 'Linux' && github.event_name == 'push' && env.SSH_PASSWORD != null
Expand All @@ -312,6 +332,13 @@ jobs:
SSH_USER: mixxx
UPLOAD_ID: ${{ github.run_id }}

# Workaround for https://github.com/actions/cache/issues/531
- name: Use system tar & zstd from Chocolatey for caching
if: runner.os == 'Windows'
shell: bash
run: |
echo "C:/Windows/System32;C:/ProgramData/Chocolatey/bin" >> $GITHUB_PATH

- name: "Upload GitHub Actions artifacts"
uses: actions/upload-artifact@v2
with:
Expand Down
38 changes: 26 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ if(MSVC)
add_compile_definitions("__SSE__" "__SSE2__")
endif()

# Needed for sccache
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endif()

if(NOT OPTIMIZE STREQUAL "off")
# Use the fastest floating point math library
# http://msdn.microsoft.com/en-us/library/e7s85ffb.aspx
Expand Down Expand Up @@ -331,19 +343,18 @@ if(GIT_WORKTREE_DIRTY EQUAL "1")
endif()
message(STATUS "Git commit count: ${GIT_COMMIT_COUNT}")
if(MSVC)
# clcache support
find_program(CLCACHE_EXECUTABLE "clcache")
if(CLCACHE_EXECUTABLE)
message(STATUS "Found clcache: ${CLCACHE_EXECUTABLE}")
# sccache support
find_program(SCCACHE_EXECUTABLE "sccache")
if(SCCACHE_EXECUTABLE)
message(STATUS "Found sccache: ${SCCACHE_EXECUTABLE}")
else()
message(STATUS "Could NOT find clcache (missing executable)")
message(STATUS "Could NOT find sccache (missing executable)")
endif()
cmake_dependent_option(CLCACHE_SUPPORT "Enable clcache support" ON "CLCACHE_EXECUTABLE" OFF)
if(CLCACHE_SUPPORT)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "clcache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "clcache")
cmake_dependent_option(SCCACHE_SUPPORT "Enable sccache support" ON "SCCACHE_EXECUTABLE" OFF)
message(STATUS "Support for sccache: ${SCCACHE_SUPPORT}")
if(SCCACHE_SUPPORT)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "sccache")
endif()
message(STATUS "Support for clcache: ${CLCACHE_SUPPORT}")
else()
# ccache support
find_program(CCACHE_EXECUTABLE "ccache")
Expand Down Expand Up @@ -1121,8 +1132,6 @@ if(WIN32)
target_link_libraries(mixxx-lib PUBLIC shell32)

if(MSVC)
# needed for clcache
target_compile_options(mixxx-lib PUBLIC /c)
if(NOT STATIC_DEPS OR CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_options(mixxx-lib PUBLIC /nodefaultlib:LIBCMT.lib /nodefaultlib:LIBCMTd.lib)
endif()
Expand Down Expand Up @@ -1629,6 +1638,11 @@ if(WIN32)
src/mixxx.rc
"${CMAKE_CURRENT_BINARY_DIR}/src/mixxx.rc.include"
)
# sccache fails with RC files
# https://github.com/mozilla/sccache/issues/947
if(SCCACHE_SUPPORT)
set_target_properties(mixxx PROPERTIES RULE_LAUNCH_COMPILE "")
endif()
target_include_directories(mixxx PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ macro(config_compiler_and_linker)
if (MSVC)
# Newlines inside flags variables break CMake's NMake generator.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
set(cxx_base_flags "-GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi")
set(cxx_base_flags "-GS -W4 -WX -wd4251 -wd4275 -nologo -J")
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
Expand Down