Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dfd3f43

Browse filesBrowse files
StefanStojanovictargos
authored andcommitted
build,win: enable ccache
PR-URL: #56847 Refs: #56705 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 7fd39e3 commit dfd3f43
Copy full SHA for dfd3f43

File tree

Expand file treeCollapse file tree

5 files changed

+48
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+48
-2
lines changed
Open diff view settings
Collapse file

‎BUILDING.md‎

Copy file name to clipboardExpand all lines: BUILDING.md
+18Lines changed: 18 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,24 @@ export CC="ccache cc" # add to ~/.zshrc or other shell config file
573573
export CXX="ccache c++" # add to ~/.zshrc or other shell config file
574574
```
575575

576+
On Windows:
577+
578+
Tips: follow <https://github.com/ccache/ccache/wiki/MS-Visual-Studio>, and you
579+
should notice that obj file will be bigger the normal one.
580+
581+
First, install ccache, assume ccache install to c:\ccache, copy
582+
c:\ccache\ccache.exe to c:\ccache\cl.exe with this command
583+
584+
```powershell
585+
cp c:\ccache\ccache.exe c:\ccache\cl.exe
586+
```
587+
588+
When building Node.js provide a path to your ccache via the option
589+
590+
```powershell
591+
.\vcbuild.bat ccache c:\ccache\
592+
```
593+
576594
This will allow for near-instantaneous rebuilds when switching branches back
577595
and forth that were built with cache.
578596

Collapse file

‎configure.py‎

Copy file name to clipboardExpand all lines: configure.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,11 @@
10181018
default=None,
10191019
help='Configure for clang-cl on Windows. This flag sets the GYP "clang" ' +
10201020
'variable to 1 and "llvm_version" to the specified value.')
1021+
parser.add_argument('--use-ccache-win',
1022+
action='store_true',
1023+
dest='use_ccache_win',
1024+
default=None,
1025+
help='Use ccache for compiling on Windows. ')
10211026

10221027
(options, args) = parser.parse_known_args()
10231028

@@ -1194,6 +1199,8 @@ def get_gas_version(cc):
11941199
# check involves checking the build number against an allowlist. I'm not
11951200
# quite prepared to go that far yet.
11961201
def check_compiler(o):
1202+
o['variables']['use_ccache_win'] = 0
1203+
11971204
if sys.platform == 'win32':
11981205
if options.clang_cl:
11991206
o['variables']['clang'] = 1
@@ -1202,6 +1209,9 @@ def check_compiler(o):
12021209
o['variables']['clang'] = 0
12031210
o['variables']['llvm_version'] = '0.0'
12041211

1212+
if options.use_ccache_win:
1213+
o['variables']['use_ccache_win'] = 1
1214+
12051215
if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'):
12061216
nasm_version = get_nasm_version('nasm')
12071217
o['variables']['nasm_version'] = nasm_version
Collapse file

‎tools/msvs/props_4_ccache.props‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project>
2+
<PropertyGroup>
3+
<UseMultiToolTask>true</UseMultiToolTask>
4+
<TrackFileAccess>false</TrackFileAccess>
5+
</PropertyGroup>
6+
<ItemDefinitionGroup>
7+
<ClCompile>
8+
<!-- /Z7 of cl.exe, ref: https://learn.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format -->
9+
<DebugInformationFormat>OldStyle</DebugInformationFormat>
10+
<ObjectFileName>$(IntDir)%(FileName).obj</ObjectFileName>
11+
</ClCompile>
12+
</ItemDefinitionGroup>
13+
</Project>
Collapse file

‎tools/v8_gypfiles/v8.gyp‎

Copy file name to clipboardExpand all lines: tools/v8_gypfiles/v8.gyp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
'type': 'none',
6262
'toolsets': ['host', 'target'],
6363
'conditions': [
64-
['OS=="win"', {
64+
['OS == "win" and (clang != 1 or use_ccache_win != 1)', {
6565
'direct_dependent_settings': {
6666
'msvs_precompiled_header': '<(V8_ROOT)/../../tools/msvs/pch/v8_pch.h',
6767
'msvs_precompiled_source': '<(V8_ROOT)/../../tools/msvs/pch/v8_pch.cc',
Collapse file

‎vcbuild.bat‎

Copy file name to clipboardExpand all lines: vcbuild.bat
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ set target_env=
2828
set noprojgen=
2929
set projgen=
3030
set clang_cl=
31+
set ccache_path=
3132
set nobuild=
3233
set sign=
3334
set nosnapshot=
@@ -87,6 +88,7 @@ if /i "%1"=="vs2022" set target_env=vs2022&goto arg-ok
8788
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
8889
if /i "%1"=="projgen" set projgen=1&goto arg-ok
8990
if /i "%1"=="clang-cl" set clang_cl=1&goto arg-ok
91+
if /i "%1"=="ccache" set "ccache_path=%2%"&goto arg-ok-2
9092
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
9193
if /i "%1"=="nosign" set "sign="&echo Note: vcbuild no longer signs by default. "nosign" is redundant.&goto arg-ok
9294
if /i "%1"=="sign" set sign=1&goto arg-ok
@@ -206,6 +208,7 @@ if defined debug_nghttp2 set configure_flags=%configure_flags% --debug-nghttp
206208
if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm
207209
if defined no_shared_roheap set configure_flags=%configure_flags% --disable-shared-readonly-heap
208210
if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose
211+
if defined ccache_path set configure_flags=%configure_flags% --use-ccache-win
209212
if defined compile_commands set configure_flags=%configure_flags% -C
210213

211214
if "%target_arch%"=="x86" (
@@ -364,6 +367,7 @@ if "%target%"=="Build" (
364367
if "%target%"=="node" if exist "%config%\cctest.exe" del "%config%\cctest.exe"
365368
if "%target%"=="node" if exist "%config%\embedtest.exe" del "%config%\embedtest.exe"
366369
if defined msbuild_args set "extra_msbuild_args=%extra_msbuild_args% %msbuild_args%"
370+
if defined ccache_path set "extra_msbuild_args=%extra_msbuild_args% /p:TrackFileAccess=false /p:CLToolPath=%ccache_path% /p:ForceImportAfterCppProps=%CD%\tools\msvs\props_4_ccache.props"
367371
@rem Setup env variables to use multiprocessor build
368372
set UseMultiToolTask=True
369373
set EnforceProcessCountAcrossBuilds=True
@@ -800,7 +804,7 @@ set exit_code=1
800804
goto exit
801805

802806
:help
803-
echo vcbuild.bat [debug/release] [msi] [doc] [test/test-all/test-addons/test-doc/test-js-native-api/test-node-api/test-internet/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [clang-cl] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [nonpm] [nocorepack] [ltcg] [licensetf] [sign] [x64/arm64] [vs2022] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-md] [lint-md-build] [format-md] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [cctest] [no-cctest] [openssl-no-asm]
807+
echo vcbuild.bat [debug/release] [msi] [doc] [test/test-all/test-addons/test-doc/test-js-native-api/test-node-api/test-internet/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [clang-cl] [ccache path-to-ccache] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [nonpm] [nocorepack] [ltcg] [licensetf] [sign] [x64/arm64] [vs2022] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-md] [lint-md-build] [format-md] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [cctest] [no-cctest] [openssl-no-asm]
804808
echo Examples:
805809
echo vcbuild.bat : builds release build
806810
echo vcbuild.bat debug : builds debug build
@@ -811,6 +815,7 @@ echo vcbuild.bat enable-vtune : builds Node.js with Intel VTune pr
811815
echo vcbuild.bat link-module my_module.js : bundles my_module as built-in module
812816
echo vcbuild.bat lint : runs the C++, documentation and JavaScript linter
813817
echo vcbuild.bat no-cctest : skip building cctest.exe
818+
echo vcbuild.bat ccache c:\ccache\ : use ccache to speed build
814819
goto exit
815820

816821
:exit

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.