Skip to content
Prev Previous commit
Next Next commit
doc: speed building on windows platform
  • Loading branch information
congzhangzh authored Mar 30, 2024
commit 512436f235242397e8896cb9bfc0a4f79787c03e
31 changes: 8 additions & 23 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -559,32 +559,17 @@ export LDFLAGS="-fuse-ld=mold" # add to ~/.zshrc or other shell config file

On Windows:

Tips: follow <https://github.com/ccache/ccache/wiki/MS-Visual-Studio>
Tips: follow <https://github.com/ccache/ccache/wiki/MS-Visual-Studio>, and you should
notice that obj file will be bigger the normal one.

First, create props\_4\_ccache.props, which is a props to force using old
debug format needed by ccache

```bash
tee props_4_ccache.props <<'EOF'
<Project>
<ItemDefinitionGroup>
<ClCompile>
<!-- /Z7 of cl.exe, ref: https://learn.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format -->
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<ObjectFileName>$(IntDir)%(FileName).obj</ObjectFileName>
</ClCompile>
</ItemDefinitionGroup>
</Project>
EOF
```

Second, set msbuild\_args to enable ccache, assume ccache install on c:\ccache,
and copy c:\ccache\ccache.exe to c:\ccache\cl.exe
First, install ccache, assume ccache install to c:\ccache, copy c:\ccache\ccache.exe
to c:\ccache\cl.exe

```powershell
set ccache_path=c:\ccache\
set props_4_ccache_path=%CD%\props_4_ccache.props
set msbuild_args=/p:UseMultiToolTask=True /p:TrackFileAccess=false /p:CLToolPath=%ccache_path% /p:ForceImportAfterCppProps=%props_4_ccache_path%
set TrackFileAccess=false
set UseMultiToolTask=True
Comment thread
congzhangzh marked this conversation as resolved.
Outdated
set CLToolPath=c:\ccache\
set ForceImportAfterCppProps=%CD%\tools\msvc\props_4_ccache.props
# run vcbuild to build node, rerun should be fast even after out dir be deleted
.\vcbuild
```
Expand Down
9 changes: 9 additions & 0 deletions tools/msvs/props_4_ccache.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<ItemDefinitionGroup>
<ClCompile>
<!-- /Z7 of cl.exe, ref: https://learn.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format -->
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<ObjectFileName>$(IntDir)%(FileName).obj</ObjectFileName>
</ClCompile>
</ItemDefinitionGroup>
</Project>