Commit Graph

90 Commits

Author SHA1 Message Date
Xi Ge
515cf21ba3 driver: refactor driver tool logics into a library. NFC 2021-07-13 10:03:12 -07:00
Artem Chikin
038af80a88 Merge pull request #37850 from artemcm/DriverForwardingArgumentStructure
Use `std::vector` for collecting arguments for swift-driver forwarding.
2021-06-09 15:46:51 -07:00
Artem Chikin
34af205d6e Use std::vector for collecting arguments for swift-driver forwarding.
Just something to try while we investigate whether SmallVector could be messing up the input to `execv`.
2021-06-09 10:48:56 -07:00
Erik Eckstein
809ce72e05 libswift: build support for the initial libswift
* add the (still empty) libswift package
* add build support for libswift in CMake
* add libswift to swift-frontend and sil-opt

The build can be controlled with the LIBSWIFT_BUILD_MODE cmake variable: by default it’s “DISABLE”, which means that libswift is not built. If it’s “HOSTTOOLS”, libswift is built with a pre-installed toolchain on the host system.
2021-06-09 11:25:15 +02:00
Xi Ge
e24eef4b35 driver: emit a warning when user specified flags to disable the new driver
rdar://78021402
2021-05-14 11:00:36 -07:00
Xi Ge
01b1aea958 Driver: diagnose options that are only supported in the new driver 2021-05-11 16:28:57 -07:00
artemcm
8e637eca41 Enable swift-driver forwarding on non-Apple platforms.
This removes the `#ifdef __APPLE__` guard that restricts this forwarding to Apple platforms only.
If a given build/toolchain does not build or include the `swift-driver` executable alongside the compiler executables, the driver will still safely default to the legacy driver.

Resolves rdar://75534188
2021-05-06 10:29:09 -07:00
Artem Chikin
d4fae29e0e [Driver] Emit the -new-driver-path option before actual compiler arguments.
Otherwise, if it is last then it will come after the input input source-file arguments. And in immediate (`swift`) mode, things that come after input source-file arguments are considered to be arguments to the underlying script and are placed after the `--`.

Resolves rdar://75039518
2021-03-16 13:48:42 -07:00
swift-ci
3bd26d0a38 Merge pull request #36381 from owenv/api-digester-as-frontend-tool 2021-03-15 23:26:26 -07:00
Xi Ge
2a1a7a8bca Merge pull request #36388 from nkcsgexi/75275788
driver: prefer a new driver name as swift-driver instead of swift-driver-new
2021-03-15 12:04:30 -07:00
Xi Ge
5e2bd57d90 driver: prefer a new driver name as swift-driver instead of swift-driver-new
rdar://75275788
2021-03-13 22:07:26 -08:00
Owen Voorhees
77efd77d23 [APIDigester] Build the API digester as a frontend tool instead of a standalone executable 2021-03-10 19:30:10 -08:00
Steven Wu
02c41656be swift-api-extract to generate JSON API information
Add a new swift-frontend driver option that extract APIs in the swift
module and print in JSON format. This is to allow tooling to understand
and process swift APIs without the need to be a swift compiler or
understand swift module/AST.
2021-02-15 15:04:52 -08:00
Xi Ge
64a3a25836 driver: use a non-op front-end argument to indicate new driver is getting used
This could help avoiding emitting remarks.

rdar://73710910
2021-02-10 10:35:26 -08:00
Varun Gandhi
caf1a55eea Merge pull request #35229 from mininny/switch-find-to-contains
[NFC] Replace uses of find(x) != end() idiom with contains(x) for StringRef and Set-like types
2021-02-08 13:57:43 -08:00
Varun Gandhi
0d1e7abc9a Merge pull request #35757 from cypherean/refactor_transform
Replace std::transform with llvm::transform
2021-02-05 08:17:48 -08:00
shreyaa-sharmaa
2b11d7acc7 Task SR-14138 Replace std::transform with llvm::transform 2021-02-04 12:58:33 +05:30
Xi Ge
dd83f17fbc Frontend: allow retrying expanding response files in argument lists
We've seen bad file descriptor errors in certain build environments (rdar://73157185) and retrying
opening those files seems to be a walkaround. In this change, we allow the
compiler to retry expanding reponse files in argument lists.

rdar://73892564
2021-02-03 16:05:40 -08:00
Minhyuk Kim
e924cf6104 Replace usages of StringRef.find(Key) != StringRef::npos to StringRef.contains(Key) 2021-02-04 00:42:04 +09:00
Robert Widmann
d815e2724a [NFC] Add Compilation::Result
In order to extract the module dependency graph from the compilation the driver just ran, define a separate semantic type to hold a result code and the graph itself.
2020-12-09 19:25:56 -08:00
Xi Ge
84afba5cf0 driver: forward driver invocation to the new driver by default
rdar://71817843
2020-12-01 15:20:22 -08:00
Xi Ge
5b4cc58f8a driver: add an option to avoid forwarding to the new driver 2020-11-07 18:24:33 -08:00
Xi Ge
f8577b2aa8 driver: allow SWIFT_USE_NEW_DRIVER to specify a driver executable name 2020-11-07 10:26:50 -08:00
Xi Ge
11b2251ac1 Driver: forwarding driver invocations to the new driver when SWIFT_USE_NEW_DRIVER is defined
This allows us to experiment with the new swift-driver without changing build systems.
2020-10-02 14:02:13 -07:00
David Ungar
6f9df09766 Merge pull request #33701 from davidungar/handle-bad-j
Don't crash on a bad -j input
2020-08-29 22:26:55 -07:00
David Ungar
fcf398a17b Don't crash on a bad -j input 2020-08-29 19:36:04 -07:00
Brent Royal-Gordon
d48e397b86 Support --driver-mode with swift-frontend
This makes development in Xcode somewhat simpler.
2020-08-07 16:00:15 -07:00
Doug Gregor
6c0d957ffe [Driver] Execute the frontend when invoked via swift-frontend.
This obviates the need for "-frontend", although we still accept it
for backward compatibility. Switch lit's %target-swift-frontend et al
over to calling swift-frontend.
2020-06-23 13:00:26 -07:00
Brian Gesiak
9208154c16 Document what a "subcommand" is
There are a few references to "subcommands" in the repository, but no
explanation of what they are. Beef up the docblock for
`shouldRunAsSubcommand()` to make things a little clearer.
Specifically, I'd like to make the difference between driver jobs and
driver subcomnmands clearer.

In addition, remove a double negative comment, "If we are not run as
'swift', don't do anything special", and replace it with something a
little clearer (in my opinion).
2020-04-09 16:42:15 -07:00
Ashley Garland
7a3a0a9e23 Symbol graph support
Adds a tool `swift-symbolgraph-extract` that reads an existing Swift
module and prints a platform- and language-agnostic JSON description of
the module, primarly for documentation.

Adds a small sub-library `SymbolGraphGen` which houses the core
implementation for collecting relevant information about declarations.
The main entry point is integrated directly into the driver as a mode:
the tool is meant to be run outside of the normal edit-compile-run/test
workflow to avoid impacting build times.

Along with common options for other tools, unique options include
`pretty-print` for debugging, and a `minimum-access-level` options for
including internal documentation.

A symbol graph is a directed graph where the nodes are symbols in a
module and the edges are relationships between them. For example, a
`struct S` may have a member `var x`. The graph would have two nodes for
`S` and `x`, and one "member-of" relationship edge. Other relationship
kinds include "inherits-from" or "conforms to". The data format for a
symbol graph is still under development and may change without notice
until a specificiation and versioning scheme is published.

Various aspects about a symbol are recorded in the nodes, such as
availability, documentation comments, or data needed for printing the
shapes of declarations without having to understand specifics about the
langauge.

Implicit and public-underscored stdlib declarations are not included by
default.

rdar://problem/55346798
2020-01-10 09:53:37 -08:00
Argyrios Kyrtzidis
0135e01d02 Rename the swift-format utility to swift-indent
This is to distinguish the C++ indenting functionality from the new formatter that is written in Swift.
2019-07-26 11:40:54 -07:00
Jordan Rose
f4487881e4 Add PrettyStackTraceSwiftVersion, and use it in the swiftc executable (#24235)
As pointed out on a recent JIRA, crash traces don't mention what
version of Swift you were running. Usually that can be gleaned from
the path, but not always.
2019-04-24 15:53:56 -07:00
Jason Mittertreiner
24c10fe8f7 Fix Response Files on Windows (#22985)
This prevents response files on Windows from being overridden after they
are read.
2019-03-01 19:03:46 -08:00
Jordan Rose
a23eaf4a02 Remove API notes compilation support from swiftc (#21759)
We don't use this feature anymore (see 0149129ed), and now that we've
branched Swift 5.0 for the last time it's time to rip it out of swiftc
(and then from Clang).

No functionality change, unless someone was compiling their own API
notes. If you were doing that, just copy them into place as text.
2019-01-16 10:39:39 -08:00
Bob Wilson
ca10ed04a6 [master-next] Remove unnecessary argument array copy from PR 17494 2018-07-03 17:26:14 -07:00
Bob Wilson
397ace0ac6 [master-next] NFC: Rename variable from PR #17494
Jordan reviewed my change and suggested using a better variable name
to avoid potential confusion between "args" and "argv".
2018-06-25 23:43:13 -07:00
Bob Wilson
ad9098fca0 [master-next] Fix up the driver's use of PROGRAM_START after PR #16362
On the master-next branch, the InitLLVM class used by the PROGRAM_START
macro can modify the argc/argv values (currently only on Windows).
Expanding response files before initializing the stack trace also modifies
the arguments so use a separate SmallVector for each copy of the argument
vector.
2018-06-25 17:01:01 -07:00
Bob Wilson
44712233c3 Merge remote-tracking branch 'origin/master' into master-next 2018-06-21 23:36:03 -07:00
Jordan Rose
7d8e40b0bb Merge pull request #16362 from dabelknap/frontend_responsefile
Wrap Command Line Arguments in a Response File if System Limits are Exceeded

https://bugs.swift.org/browse/SR-4517
2018-06-21 16:31:20 -07:00
Austin Belknap
be229fc173 Use subCommandArgs instead of argv within subcommand if block. 2018-06-20 15:24:37 -07:00
Austin Belknap
8e6abee651 Pass ArrayRefs by value. 2018-06-12 18:00:30 -07:00
Austin Belknap
6592b428f8 Style fixes. 2018-06-01 14:18:26 -07:00
Austin Belknap
3b38fa68a1 Preserve argv for the stack trace, and only create a copy if necessary. 2018-06-01 14:01:11 -07:00
swift-ci
6bcc013437 Merge remote-tracking branch 'origin/master' into master-next 2018-05-30 00:49:45 -07:00
Robert Widmann
d7493dd0fa [NFC] Expose the TaskQueue as a Compilation Parameter
Shuffle the responsibility for creating the TaskQueue out of the
Compilation's internal job state object and into the driver.  Expose
a builder convenience function that handles the argument parsing.
2018-05-29 21:58:27 -07:00
Austin Belknap
3fe62b94e7 Reformat verbose and stack trace printouts for response-files. 2018-05-23 11:05:20 -07:00
Saleem Abdulrasool
6b18cfe53f master-next: update for SVN r330216
sys::Process::GetArgumentVector has been removed.  It is unclear if it
was ever needed in the first place.  Simplify the code to avoid the use.
2018-04-23 11:24:02 -07:00
Austin Belknap
0e5f88c5ad Elaborate on the purpose of response files. 2018-04-18 09:54:59 -07:00
Austin Belknap
a7fe02e0c5 Add ability to expand response files from the command line. 2018-04-10 12:41:25 -07:00
Sho Ikeda
cea6c03eb2 [gardening] Use !empty() over size() > 0 2018-03-08 09:21:09 +09:00