Speed up Windows CI with ccache (#308)

Use https://github.com/cristianadam/ccache/releases/ to speed up windows
compilation.

Remove /Zi as it is unsupported by ccache at the moment. This is a debug
flag that was removed in upstream marian-dev
https://github.com/browsermt/marian-dev/pull/43. However, the bergamot
CMakeLists.txt which was originally taken from
marian maintained this under MSCV.
This commit is contained in:
Jerin Philip 2022-01-22 18:41:04 +00:00 committed by GitHub
parent aef76c03a4
commit 495f98dd0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 3 deletions

View File

@ -8,6 +8,13 @@ on:
env:
MKL_URL: "https://romang.blob.core.windows.net/mariandev/ci/mkl-2020.1-windows-static.zip"
CCACHE_BASEDIR: "${{ github.workspace }}"
CCACHE_DIR: "${{ github.workspace }}\\ccache"
CCACHE_COMPILERCHECK: content
CCACHE_COMPRESS: 'true'
CCACHE_COMPRESSLEVEL: 9
CCACHE_MAXSIZE: 200M
ccache_version: '4.5'
jobs:
build-windows:
@ -16,7 +23,7 @@ jobs:
include:
# Windows CPU-only build
- name: "Windows CPU-only"
cuda: ""
identifier: "windows-x64"
runs-on: windows-2019
name: ${{ matrix.name }}
@ -27,6 +34,40 @@ jobs:
with:
submodules: recursive
- name: Download ccache
shell: cmake -P {0}
run: |
set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v${{ env.ccache_version }}/${{ runner.os }}.tar.xz")
file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz)
if(ret AND NOT ret EQUAL 0)
message( FATAL_ERROR "Bad exit status")
endif()
- name: Generate ccache_vars for ccache based on machine
shell: cmake -P {0}
id: ccache_vars
run: |-
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
message("::set-output name=hash::${{ env.ccache_compilercheck }}")
- name: Cache-op for build-cache through ccache
uses: actions/cache@v2
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ matrix.identifier }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}-${{ steps.ccache_vars.outputs.timestamp }}
restore-keys: |-
ccache-${{ matrix.identifier }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}
ccache-${{ matrix.identifier }}-${{ steps.ccache_vars.outputs.hash }}
ccache-${{ matrix.identifier }}
- name: ccache prolog
run: |-
${{github.workspace}}\ccache.exe -sv # Print current cache stats
${{github.workspace}}\ccache.exe -z # Print current cache stats
- name: Download MKL
run: |
# Wget retries downloading files and is faster than Invoke-WebRequest
@ -52,7 +93,10 @@ jobs:
cmakeAppendedArgs: '-G Ninja
-DCMAKE_BUILD_TYPE="Release"
-DUSE_WASM_COMPATIBLE_SOURCE="OFF"
-DUSE_STATIC_LIBS="TRUE"'
-DUSE_STATIC_LIBS="TRUE"
-DCMAKE_CXX_COMPILER_LAUNCHER=${{github.workspace}}\ccache.exe
-DCMAKE_C_COMPILER_LAUNCHER=${{github.workspace}}\ccache.exe
'
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: ${{ github.workspace }}/CMakeLists.txt
useVcpkgToolchainFile: true
@ -64,3 +108,7 @@ jobs:
run: |
.\app\bergamot.exe --version
shell: cmd
- name: ccache epilog
run: |-
${{github.workspace}}\\ccache.exe -sv # Print current cache stats

View File

@ -55,7 +55,7 @@ if(MSVC)
set(INTRINSICS ${MSVC_BUILD_ARCH}) # ARCH we're targetting on win32. @TODO variable
set(CMAKE_CXX_FLAGS "/EHsc /DWIN32 /D_WINDOWS /DUNICODE /D_UNICODE /D_CRT_NONSTDC_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /bigobj")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MT /O2 ${INTRINSICS} /Zi /MP /GL /DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MT /O2 ${INTRINSICS} /MP /GL /DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /MTd /Od /Ob0 ${INTRINSICS} /RTC1 /Zi /D_DEBUG")
# ignores warning LNK4049: locally defined symbol free imported - this comes from zlib