Skip to content

Commit b755ae1

Browse files
authored
doc: update clang-cl on Windows building guide
- Mention that when the individual components cannot be found despite already being installed, try re-installing. - Mention that with newer version of Visual Studio, ccache should be copied to `clang-cl.exe` instead. - Mention how to use clang-cl with ccache PR-URL: #57087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 4afc136 commit b755ae1

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

Diff for: BUILDING.md

+33-7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ file a new issue.
3131
* [Building a debug build](#building-a-debug-build)
3232
* [Building an ASan build](#building-an-asan-build)
3333
* [Speeding up frequent rebuilds when developing](#speeding-up-frequent-rebuilds-when-developing)
34+
* [ccache](#ccache)
35+
* [Loading JS files from disk instead of embedding](#loading-js-files-from-disk-instead-of-embedding)
3436
* [Troubleshooting Unix and macOS builds](#troubleshooting-unix-and-macos-builds)
3537
* [Windows](#windows)
3638
* [Windows Prerequisites](#windows-prerequisites)
@@ -540,6 +542,8 @@ make test-only
540542

541543
#### Speeding up frequent rebuilds when developing
542544

545+
##### ccache
546+
543547
Tips: The `ccache` utility is widely used and should generally work fine.
544548
If you encounter any difficulties, consider disabling `mold` as a
545549
troubleshooting step.
@@ -575,17 +579,26 @@ export CXX="ccache c++" # add to ~/.zshrc or other shell config file
575579

576580
On Windows:
577581

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.
582+
Follow <https://github.com/ccache/ccache/wiki/MS-Visual-Studio>, and you
583+
should notice that obj file will be bigger than the normal one.
580584

581-
First, install ccache, assume ccache install to c:\ccache, copy
582-
c:\ccache\ccache.exe to c:\ccache\cl.exe with this command
585+
First, install ccache. Assuming the installation of ccache is in `c:\ccache`
586+
(where you can find `ccache.exe`), copy `c:\ccache\ccache.exe` to `c:\ccache\cl.exe`
587+
with this command.
583588

584589
```powershell
585590
cp c:\ccache\ccache.exe c:\ccache\cl.exe
586591
```
587592

588-
When building Node.js provide a path to your ccache via the option
593+
With newer version of Visual Studio, it may need the copy to be `clang-cl.exe`
594+
instead. If the output of `vcbuild.bat` suggestion missing `clang-cl.exe`, copy
595+
it differently:
596+
597+
```powershell
598+
cp c:\ccache\ccache.exe c:\ccache\clang-cl.exe
599+
```
600+
601+
When building Node.js, provide a path to your ccache via the option:
589602

590603
```powershell
591604
.\vcbuild.bat ccache c:\ccache\
@@ -594,6 +607,14 @@ When building Node.js provide a path to your ccache via the option
594607
This will allow for near-instantaneous rebuilds when switching branches back
595608
and forth that were built with cache.
596609

610+
To use it with ClangCL, run this instead:
611+
612+
```powershell
613+
.\vcbuild.bat clang-cl ccache c:\ccache\
614+
```
615+
616+
##### Loading JS files from disk instead of embedding
617+
597618
When modifying only the JS layer in `lib`, it is possible to externally load it
598619
without modifying the executable:
599620

@@ -678,14 +699,19 @@ Optional requirements for compiling for Windows on ARM (ARM64):
678699
* Visual C++ ATL for ARM64
679700
* Windows 10 SDK 10.0.17763.0 or newer
680701

681-
Optional requirements for compiling with ClangCL:
702+
Optional requirements for compiling with ClangCL (search for `clang` in Visual Studio
703+
Installer's "individual component" tab):
682704

683-
* Visual Studio optional components
705+
* Visual Studio individual components
684706
* C++ Clang Compiler for Windows
685707
* MSBuild support for LLVM toolset
686708

687709
NOTE: Currently we only support compiling with Clang that comes from Visual Studio.
688710

711+
When building with ClangCL, if the output from `vcbuild.bat` shows that the components are not installed
712+
even when the Visual Studio Installer shows that they are installed, try removing the components
713+
first and then reinstalling them again.
714+
689715
##### Option 2: Automated install with WinGet
690716

691717
[WinGet configuration files](https://github.com/nodejs/node/tree/main/.configurations)

0 commit comments

Comments
 (0)