You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swift's compiler driver is a program that coordinates the compilation of Swift source code into various compiled results: executables, libraries, object files, Swift modules and interfaces, etc. It is the program one invokes from the command line to build Swift code (i.e., `swift` or `swiftc`) and is often invoked on the developer's behalf by a build system such as the [Swift Package Manager (SwiftPM)](https://github.com/swiftlang/swift-package-manager) or Xcode's build system.
3
+
Swift's compiler driver is a program that coordinates the compilation of Swift source code into various compiled results: executables, libraries, object files, Swift modules and interfaces, etc. It is the program one invokes from the command line to build Swift code (i.e., `swift` or `swiftc`) and is often invoked on the developer's behalf by a build system such as the [Swift Package Manager](https://github.com/swiftlang/swift-package-manager) or [Swift Build](https://github.com/swiftlang/swift-build).
4
4
5
-
The `swift-driver` project is a new implementation of the Swift compiler driver that is intended to replace the [existing driver](https://github.com/apple/swift/tree/main/lib/Driver) with a more extensible, maintainable, and robust code base. The specific goals of this project include:
5
+
The `swift-driver` project is the primary implementation of the Swift compiler driver that has replaced the [legacy driver](https://github.com/apple/swift/tree/main/lib/Driver) with a more extensible, maintainable, and robust code base. Core pillars of the project's architecture include:
6
6
7
7
* A maintainable, robust, and flexible Swift code base
8
8
* Library-based architecture that allows better integration with build tools
@@ -11,8 +11,6 @@ The `swift-driver` project is a new implementation of the Swift compiler driver
11
11
12
12
## Getting Started
13
13
14
-
**Note:** Currently, swift-driver is only compatible with trunk development snapshots from [swift.org](https://swift.org/download/#snapshots).
15
-
16
14
The preferred way to build `swift-driver` is to use the Swift package manager.
17
15
18
16
On most platforms you can build using:
@@ -27,27 +25,24 @@ However, on Windows, because Swift Package Manager does not differentiate betwee
27
25
swift build -Xlinker "%SDKROOT%\usr\lib\swift\windows\x86_64\swiftCore.lib"
28
26
```
29
27
30
-
To use `swift-driver` in place of the existing Swift driver, create a symbolic link from `swift` and `swiftc` to `swift-driver`:
28
+
To use a locally-built `swift-driver` in place of the existing Swift driver, create a symbolic link from `swift` and `swiftc` to `swift-driver`:
Swift packages can be built with the new Swift driver by overriding `SWIFT_EXEC` to refer to the `swiftc` symbolic link created above and `SWIFT_DRIVER_SWIFT_FRONTEND_EXEC` to refer to the original `swift-frontend`, e.g.,
35
+
Swift packages can be built with the new Swift driver by overriding `SWIFT_EXEC` to refer to the `swiftc` symbolic link created above and `SWIFT_DRIVER_SWIFT_FRONTEND_EXEC` to refer to the original `swift-frontend`, e.g.
38
36
39
37
```
40
38
SWIFT_EXEC=$SOME_PATH/swiftc SWIFT_DRIVER_SWIFT_FRONTEND_EXEC=$TOOLCHAIN_PATH/bin/swift-frontend swift build
41
39
```
42
40
43
-
Similarly, one can use the new Swift driver within Xcode by adding a custom build setting (usually at the project level) named `SWIFT_EXEC` that refers to `$SOME_PATH/swiftc` and adding `-driver-use-frontend-path $TOOLCHAIN_DIR/usr/bin/swiftc` to `Other Swift Flags`.
41
+
Similarly, one can use the Swift driver within Xcode by adding a custom build setting (usually at the project level) named `SWIFT_EXEC` that refers to `$SOME_PATH/swiftc`.
44
42
45
43
## Building with CMake
46
44
47
-
`swift-driver` can also be built with CMake, which is suggested for
48
-
environments where the Swift Package Manager is not yet
49
-
available. Doing so requires several dependencies to be built first,
50
-
all with CMake:
45
+
`swift-driver` can also be built with CMake, which is suggested for environments where the Swift Package Manager is not yet available. Doing so requires several dependencies to be built first, all with CMake:
*[llbuild](https://github.com/apple/swift-llbuild) configure CMake with `-DLLBUILD_SUPPORT_BINDINGS="Swift"` and `-DCMAKE_OSX_ARCHITECTURES=x86_64` (If building on Intel) when building
The new Swift driver is a work in progress, and there are numerous places for anyone with an interest to contribute! This section covers testing, miscellaneous development tips and tricks, and a rough development plan showing what work still needs to be done.
62
+
Swift compiler driver is constantly evolving and improving, and there are numerous places for anyone with an interest to contribute! This section covers testing, and miscellaneous development tips and tricks.
68
63
69
64
### Driver Documentation
70
65
@@ -78,26 +73,6 @@ Test using command-line SwiftPM or Xcode.
78
73
$ swift test --parallel
79
74
```
80
75
81
-
Integration tests are costly to run and are disabled by default. Enable them
82
-
using `SWIFT_DRIVER_ENABLE_INTEGRATION_TESTS` environment variable. In Xcode,
83
-
you can set this variable in the scheme's test action.
84
-
85
-
```
86
-
$ SWIFT_DRIVER_ENABLE_INTEGRATION_TESTS=1 swift test --parallel
87
-
```
88
-
89
-
Some integration tests run the lit test suites in a Swift working copy.
90
-
To enable these, clone Swift and its dependencies and build them with
91
-
build-script, then set both `SWIFT_DRIVER_ENABLE_INTEGRATION_TESTS`
92
-
and `SWIFT_DRIVER_LIT_DIR`, either in your Xcode scheme or
`swift-driver` Continuous Integration runs against the most recent Trunk Development snapshot published at [swift.org/download](https://swift.org/download/).
103
78
@@ -114,7 +89,7 @@ After the toolchain is installed, Xcode needs to be told to use it. This can mea
114
89
115
90
Building with the toolchain is easy, set the toolchain in Xcode: Menu Bar > Xcode > Toolchains > select your toolchain
116
91
117
-
Running the driver requires setting the TOOLCHAINS environment variable. This tells xcrun which toolchain to use (on darwin xcrun is used to find tools). This variable is the name of the toolchain and not the path (ex: `Swift Development Snapshot`). Important note: xcrun lookup is lower priority than the SWIFT_EXEC_*_EXEC family of environment variables, the tools directory, and any tools in the same directory as the driver (This includes a driver installed in a toolchain). Even though TOOLCHAINS is not highest priority it's a convenient way to run the xctest suite using a custom toolchain.
92
+
Running the driver requires setting the TOOLCHAINS environment variable. This tells xcrun which toolchain to use (on darwin xcrun is used to find tools). This variable is the name of the toolchain and not the path (ex: `Swift Development Snapshot`). Important note: xcrun lookup is lower priority than the `SWIFT_EXEC_*_EXEC` family of environment variables, the tools directory, and any tools in the same directory as the driver (This includes a driver installed in a toolchain). Even though `TOOLCHAINS` is not highest priority it's a convenient way to run the xctest suite using a custom toolchain.
The goal of the new Swift driver is to provide a drop-in replacement for the existing driver, which means that there is a fixed initial feature set to implement before the existing Swift driver can be deprecated and removed. The development plan below covers that feature set, as well as describing a number of tasks that can improve the Swift driver---from code cleanups, to improving testing, implementing missing features, and integrating with existing systems.
133
+
The development plan below covers a number of tasks that can improve the Swift driver---from code cleanups, to improving testing, implementing missing features, and integrating with existing systems.
159
134
160
135
* Code and documentation quality
161
-
*[ ]Search for `FIXME:` or `TODO:`: there are lots of little things to improve!
162
-
*[ ]Improve documentation of how to incorporate the driver into your own builds
163
-
*[ ]Add useful descriptions to any `Error` thrown within the library
136
+
* Search for `FIXME:` or `TODO:`: there are lots of little things to improve!
137
+
* Improve documentation of how to incorporate the driver into your own builds
138
+
* Add useful descriptions to any `Error` thrown within the library
164
139
* Option parsing
165
-
*[ ] Look for complete "coverage" of the options in `Options.swift`. Is every option there checked somewhere in the driver?
166
-
*[ ] Find a better way to describe aliases for options. Can they be of some other type `OptionAlias` so we can't make the mistake of (e.g.) asking for an alias option when we're translating options?
167
-
*[ ] Diagnose unused options on the command line
168
-
*[ ] Typo correction for misspelled option names
169
-
*[ ] Find a better way than `makeOptions.cpp` to translate the command-line options from [Swift's repository](https://github.com/apple/swift/tree/main/include/swift/Option) into `Options.swift`.
170
-
* Platform support
171
-
*[x] Teach the `DarwinToolchain` to also handle iOS, tvOS, watchOS
172
-
*[x] Fill out the `GenericUnixToolchain` toolchain to get it working
173
-
*[x] Implement a `WindowsToolchain`
174
-
*[x] Implement proper tokenization for response files
175
-
* Compilation modes
176
-
*[x] Batch mode
177
-
*[x] Whole-module-optimization mode
178
-
*[x] REPL mode
179
-
*[x] Immediate mode
180
-
* Features
181
-
*[x] Precompiled bridging headers
182
-
*[x] Support embedding of bitcode
183
-
*[x] Incremental compilation
184
-
*[x] Parseable output, as used by SwiftPM
185
-
*[x] Response files
186
-
*[x] Input and primary input file lists
187
-
*[x] Complete `OutputFileMap` implementation to handle all file types uniformly
188
-
* Testing
189
-
*[ ] Build stuff with SwiftPM or Xcode or your favorite build system, using `swift-driver`. Were the results identical? What changed?
190
-
*[x] Shim in `swift-driver` so it can run the Swift repository's [driver test suite](https://github.com/apple/swift/tree/main/test/Driver).
191
-
*[ ] Investigate differences in the test results for the Swift repository's driver test suite (above) between the existing and new driver.
192
-
*[ ] Port interesting tests from the Swift repository's [driver test suite](https://github.com/apple/swift/tree/main/test/Driver) over to XCTest
193
-
*[ ] Fuzz the command-line options to try to crash the Swift driver itself
194
-
* Integration
195
-
*[x] Teach the Swift compiler's [`build-script`](https://github.com/apple/swift/blob/main/utils/build-script) to build `swift-driver`.
196
-
*[x] Building on the above, teach the Swift compiler's [`build-toolchain`](https://github.com/apple/swift/blob/main/utils/build-toolchain) to install `swift-driver` as the primary driver so we can test full toolchains with the new driver
140
+
* Look for complete "coverage" of the options in `Options.swift`. Is every option there checked somewhere in the driver?
141
+
* Find a better way to describe aliases for options. Can they be of some other type `OptionAlias` so we can't make the mistake of (e.g.) asking for an alias option when we're translating options?
142
+
* Diagnose unused options on the command line
143
+
* Typo correction for misspelled option names
144
+
* Find a better way than `makeOptions.cpp` to translate the command-line options from [Swift's repository](https://github.com/apple/swift/tree/main/include/swift/Option) into `Options.swift`.
197
145
198
146
### Build all Swift interfaces from an SDK
199
147
Based on libSwiftDriver, `swift-build-sdk-interfaces` is a tool to batch build all Swift textual interfaces (`.swiftinterface`) from an SDK into binary modules (`.swiftmodule`). As an example, the following command finds all Swift textual interface from the MacOSX SDK, builds all of them into binary modules, and outputs module-specific error logs into the given directory.
Contributions to swift-driver are welcomed and encouraged! Please see the [Contributing to Swift guide](https://swift.org/contributing/).
219
162
220
-
To be a truly great community, [Swift.org](https://swift.org/) needs to welcome
221
-
developers from all walks of life, with different backgrounds, and with a wide
222
-
range of experience. A diverse and friendly community will have more great
223
-
ideas, more unique perspectives, and produce more great code. We will work
224
-
diligently to make the Swift community welcoming to everyone.
163
+
Before submitting the pull request, please make sure you have [tested your changes](https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md) and that they follow the Swift project [guidelines for contributing code](https://swift.org/contributing/#contributing-code).
225
164
226
-
To give clarity of what is expected of our members, Swift has adopted the
227
-
code of conduct defined by the Contributor Covenant. This document is used
228
-
across many open source communities, and we think it articulates our values
229
-
well. For more, see the [Code of Conduct](https://swift.org/code-of-conduct/).
165
+
To be a truly great community, [Swift.org](https://swift.org/) needs to welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make the Swift community welcoming to everyone.
230
166
167
+
To give clarity of what is expected of our members, Swift has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the [Code of Conduct](https://swift.org/code-of-conduct/).
0 commit comments