Skip to content

Commit 156f081

Browse files
authored
Merge pull request #59588 from apple/egorzhdan/hosttools-docs
[SwiftCompilerSources][docs] Describe using `hosttools` builds with a locally built toolchain
2 parents 6e14c7f + b64c2b0 commit 156f081

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docs/DevelopmentTips.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,25 @@ Copy the invocation that has ` -o <build-path>/swift-macosx-x86_64/stdlib/publi
2323
### Choosing the bootstrapping mode
2424
By default, the compiler builds with the `boostrapping-with-hostlibs` (macOS) or `bootstrapping` (Linux) bootstrapping mode. To speed up local development it's recommended to build with the `hosttools` mode: `utils/build-script --bootstrapping=hosttools`.
2525

26-
It requires a recently new swift toolchain to be installed on your build machine. On macOS this comes with your Xcode installation.
26+
It requires a recently new swift toolchain to be installed on your build machine. You might need to download and install a nightly Swift toolchain to build the Swift project in `hosttools` mode.
2727

2828
Not that changing the bootstrapping mode needs a reconfiguration.
2929

30+
#### Using a locally built Swift toolchain
31+
32+
If you do not want to install a nightly Swift toolchain, or you need to debug Swift code within SwiftCompilerSources, you can build the Swift toolchain in `boostrapping-with-hostlibs` mode on your local machine once, and then use this toolchain to iterate on your changes with the `hosttools` mode:
33+
34+
* Build the toolchain locally in `boostrapping-with-hostlibs` mode: `./utils/build-toolchain com.yourname`.
35+
* Copy the `swift-LOCAL-YYYY-MM-DD.xctoolchain` file from `./swift-nightly-install/Library/Developer/Toolchains` to `/Library/Developer/Toolchains`.
36+
* Launch Xcode, in the menu bar select _Xcode_ > _Toolchains_ > _Local Swift Development Snapshot YYYY-MM-DD_.
37+
* Remove the Swift build directory: `./build`.
38+
* Run the Swift build script with the locally built Swift toolchain in `hosttools` mode: `TOOLCHAINS=com.yourname.YYYYMMDD ./utils/build-script --bootstrapping=hosttools`. Repeat this step as you iterate on your change.
39+
40+
To debug using LLDB, run LLDB from the locally built toolchain with a couple of environment variables set:
41+
```
42+
DYLD_LIBRARY_PATH=/Library/Developer/Toolchains/swift-LOCAL-YYYY-MM-DD.xctoolchain/usr/lib/swift/macosx DYLD_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Library/Frameworks /Library/Developer/Toolchains/swift-LOCAL-YYYY-MM-DD.xctoolchain/usr/bin/lldb
43+
```
44+
3045
### Working with two build directories
3146
For developing and debugging you are probably building a debug configuration of swift. But it's often beneficial to also build a release-assert configuration in parallel (`utils/build-script -R`).
3247

0 commit comments

Comments
 (0)