Commit Graph

685 Commits

Author SHA1 Message Date
Ben Langmuir
309d00706c Make swiftc default to -emit-executable even with no inputs
Running the repl here doesn't fit with the interactive/batch-compilation
split.

Swift SVN r20453
2014-07-24 01:04:40 +00:00
Ben Langmuir
915657fe3d Introduce NoInteractiveOption and NoBatchOption opt flags
... and use them to start diagnosing unsupported mode flag and
DriverKind combinations (e.g. swifti -c, swiftc -i). Also hide the
unsupported options from -help.

Swift SVN r20452
2014-07-24 01:04:37 +00:00
Ben Langmuir
afd88cab2a Add parsing support for swifti
Parse until the first input, and then collect the remaining arguments
and forward them to the script.

Swift SVN r20437
2014-07-23 22:42:05 +00:00
Ben Langmuir
a96009c52f Add a 'swifti' symlink to stage in the upcoming driver changes
For now, keep 'swift' the same and put all the interactive driver
changes under 'swifti'. When these are in good shape, I will remove
swifti and make 'swift' the interactive driver as discussed.

Swift SVN r20359
2014-07-23 02:30:39 +00:00
Connor Wakamo
497eeffa55 [driver] Allow -force-single-frontend-invocation and -emit-objc-header[-path] to be used together.
Added support in Driver which allows -force-single-frontend-invocation and
-emit-objc-header[-path] to be used together in a single invocation.

Added support in tools::Swift to pass -emit-objc-header-path if an Objective-C
header was requested; this is only valid in OutputInfo::Mode::SingleCompile
mode, and an assertion enforces this.

Added a test which ensures that the same header is emitted in with
-force-single-frontend-invocation and without it.

Swift SVN r20185
2014-07-18 22:04:29 +00:00
Connor Wakamo
0fe539f579 Renamed swift::createDriverOptTable() to swift::createSwiftOptTable().
Swift SVN r19827
2014-07-10 20:51:54 +00:00
Connor Wakamo
2d6c9e9062 Moved Swift's option table from swiftDriver into a new swiftOption library.
This allows swiftFrontend to drop its dependency on swiftDriver, and could
someday allow us to move the integrated frontend's option parsing out of
swiftFrontend (which would allow other tools which use swiftFrontend to
exclude the option table entirely).

Swift SVN r19824
2014-07-10 20:51:50 +00:00
Jordan Rose
bb6c62d2ca [Driver] Disallow bridging headers with framework targets.
While this appears to work, it causes problems down the line -- it's a
brittle configuration for debugging, and PrintAsObjC currently doesn't
fail gracefully if you reference a bridging-header-only type in your
public interface.

We definitely want something like this to work some day, but don't have
time to fix it now. Filed <rdar://problem/17615898>.

Swift SVN r19762
2014-07-09 23:58:54 +00:00
Ben Langmuir
8b7cc4f619 Make -i compatible with shebangs and forward arguments correctly
The driver option -i now requires an input file as argument, and any
options after the input file will be treated as arguments to the
interpretted file.

This also renames the frontend option to -interpret, since it is parsed
as a flag, unlike -i. We could support -interpret in the driver if we
wanted, which would allow us to use --, but wouldn't work with shebang
scripts. For now, it's frontend-only.

Swift SVN r19718
2014-07-09 02:37:42 +00:00
Jordan Rose
76a8ed4b2d [Driver] Eliminate now-unused variable (after r18872).
No functionality change.

Swift SVN r18880
2014-06-13 22:58:43 +00:00
Jordan Rose
9155772014 [Driver] Drop the -arch flag; it does the wrong thing for the iOS simulator.
Clang uses this to produce fat binaries, so we'll probably want to get it
right some day, but for now it's fine to just leave it out.

Swift SVN r18872
2014-06-13 17:27:48 +00:00
Michael Gottesman
9b72aa0e47 Revert "Update to ToT which removed std::error_code"
This reverts commit r18853. This was already fixed by the previous
commit.

Swift SVN r18855
2014-06-13 04:34:18 +00:00
Pete Cooper
676b005839 Update to ToT which removed std::error_code
Swift SVN r18853
2014-06-13 03:50:33 +00:00
Justin Bogner
a0c0dc25be Use std::error_code rather than llvm::error_code
std::error_code is no longer available via the llvm namespace as of
r210835.

Swift SVN r18851
2014-06-13 02:54:07 +00:00
Jordan Rose
3f97d035fd [Driver] Allow falling back to / for -i mode if xcrun says to.
After a long discussion with Daniel, the behavior of "xcrun --sdk macosx"
will always pick the best  SDK to use with the Swift found by "xcrun swift".
The only case in which we have a problem is if someone has explicitly
specified the path to a Swift binary, or if someone is on 10.9 but only has
the command line tools installed (in which case they lose anyway).

In order to keep this from polluting the tests, I've changed %swift_driver
to set SDKROOT to an empty path by default. Use -sdk if you need to provide
an SDK in a test, not the SDKROOT environment variable. (This is what
everyone has been doing so far.)

This is still limited to -i and REPL modes; for compilation an explicit SDK
is still required.

<rdar://problem/14395800>

Swift SVN r18770
2014-06-10 01:00:43 +00:00
Jordan Rose
e715940241 [Driver] Teach "swift -i" and "swift -repl" to default to the current OS X SDK.
This only works when swift is packaged with Xcode or installed as a command
line tool, but those are the important cases.

<rdar://problem/14395800>, again.

Swift SVN r18757
2014-06-09 21:29:08 +00:00
Jordan Rose
9e492a508f [Driver] Don't crash when an input file has unknown type.
If we can't determine the type of an input file, we assume it's a linker
input of some sort (like Clang does). However, if we're not actually linking,
this resulted in unused inputs, which the driver choked on.

This commit updates the driver to throw away (and diagnose) inputs that
aren't going to be compiled if they aren't going to be used later on.
It also checks that none of our non-object output types are being treated
as linker inputs, since we do have that information around.

<rdar://problem/16019895>

Swift SVN r18667
2014-05-30 01:44:03 +00:00
Jordan Rose
780c6bd87a [Driver] Turn on the LLDB REPL by default!
You can use -integrated-repl to access the previous REPL implementation.

<rdar://problem/16776719>

Swift SVN r18084
2014-05-14 23:23:16 +00:00
Jordan Rose
67f319b747 [Driver] Hook up -emit-dependencies option, but don't do anything with it yet.
Part of <rdar://problem/14899639>

Swift SVN r18044
2014-05-14 00:34:07 +00:00
Jordan Rose
c6c6c6ef0f [Driver] Preserve .o files when compiling with debug info.
Since we don't generate dSYMs yet, this is the only way to create debuggable
binaries.

Thanks, Jim.

Swift SVN r17853
2014-05-10 22:34:35 +00:00
Jordan Rose
087e59eca8 [Driver] Delete temporary files unless -save-temps is passed.
If a temporary file is mentioned in the output map, it is also preserved.
We can make a nicer -save-temps later, but for now this will at least stop
leaving random files in /var/tmp.

<rdar://problem/16874893>

Swift SVN r17850
2014-05-10 21:58:23 +00:00
Jordan Rose
216d8b9521 fixup
Swift SVN r17794
2014-05-09 19:11:10 +00:00
Jordan Rose
737703b325 [Driver] Drop -working-directory option.
This wasn't hooked up correctly anyway. We can add it back if it becomes
important.

Swift SVN r17793
2014-05-09 19:11:10 +00:00
Jordan Rose
c941322ec1 [Driver] Clean up Options.td, including adding -version and -h.
(as aliases for --version and -help)

Clean-up of FrontendOptions.td to come soon.

Swift SVN r17792
2014-05-09 19:11:06 +00:00
Jordan Rose
9c6ddc085f [driver] Add -lldb-repl and -integrated-repl modes.
Since LLDB is taking over as the REPL for Swift, we eventually want "swift"
and "swift -repl" to invoke "lldb --repl" rather than the frontend. However,
we only want to do this if the LLDB that's present is related to the Swift
that's present -- we don't want to invoke some random LLDB on the system
or in some other Xcode installation. Therefore, Swift searches for LLDB--
first next to the driver, then in the usr/bin/ outside of a toolchain--
before choosing to use it.

If the user just passes -repl and an LLDB is not found relative to the
driver, the existing "integrated" REPL will be launched instead.*

If the user passes -lldb-repl and an LLDB is not found relative to the
driver, one from the user's PATH will be chosen (like the linker).

The user can also pass -integrated-repl to get the existing behavior.
"swift -frontend -repl" always uses the integrated REPL.

* Since LLDB's not quite ready to be the REPL yet, "swift -repl" still
invokes the integrated REPL. "swift -repl -experimental-prefer-lldb" tests
the new behavior; this option will become the default (and the flag removed)
in <rdar://problem/16776719>.

<rdar://problem/16776705>

Swift SVN r17134
2014-05-01 02:15:53 +00:00
John McCall
3cf3f42e98 When targeting arm64-apple-ios, the target CPU is cyclone,
which provides the Neon feature.  Do all the necessary
plumbing to get this from the driver to the backend.

Also, support -arch arm64, and diagnose bad -arch values
instead of silently ignoring them.  It's not clear to me
that we really want to support -arch as an alternative
to -target, but unless we rip it out or establish some
sort of real policy about it, it really ought to do
something approximating the right thing.

It would be nice if we could abstract enough of clang's
driver that we could re-use some of its basic logic about
tool chains and targets instaed of iteratively
rediscovering everything it does that's actually
critically important.

Swift SVN r16447
2014-04-17 06:36:03 +00:00
Dmitri Hrybenko
e50b52fa02 Serializer/Driver: serialize comments to separate .swiftdoc files
The driver infers the filename from the module file by replacing the extension,
and passes the explicit path to the swiftdoc file to the frontend.  But there
is no option in the driver to control emission of swiftdoc (it is always
emitted, and name is always inferred from the swiftmodule name).

The swiftdoc file consists of a single table that maps USRs to {brief comment,
raw comment}.  In order to look up a comment for decl we generate the USR
first.  We hope that the performance hit will not be that bad, because most
declarations come from Clang.  The advantage of this design is that the
swiftdoc file is not locked to the swiftmodule file, and can be updated,
replaced, and even localized.


Swift SVN r14914
2014-03-11 10:42:26 +00:00
Jordan Rose
798e13d15c Wire up -emit-objc-header[-path] options that don't do anything yet.
These options piggyback on the "merge module" phase of the driver
because the header we output needs an entire complete module.

Swift SVN r13800
2014-02-12 01:19:13 +00:00
Jordan Rose
d354c89a65 [driver] Continue treating a single input file as indicating a module "main".
...unless we know better (e.g. because the user passed -emit-library,
-parse-as-library, or -parse-stdlib).

Swift SVN r13767
2014-02-11 00:18:38 +00:00
Jordan Rose
c24a6a7b46 [driver] Disallow "swift" as a module name unless -parse-stdlib is passed.
I didn't bother duplicating this check in -frontend mode. I think that's
acceptable.

<rdar://problem/15083796>

Swift SVN r13759
2014-02-10 22:40:44 +00:00
Jordan Rose
0de8d19514 Define globals for the names of the stdlib, ObjectiveC, and Foundation modules.
This is mostly useful for the standard library, whose name is going to
change to "Swift" soon. (See <rdar://problem/15972383>.) But it's good DRY.

Swift SVN r13758
2014-02-10 22:40:42 +00:00
Jordan Rose
3747aa1008 [driver] Handle .o files and .swiftmodule files passed on the command line.
This isn't perfect, since /both/ show up as arguments to both the
module-merger and the linker. However, it gets the job done: each tool just
ignores the inputs it doesn't use.

Swift SVN r13470
2014-02-05 01:58:15 +00:00
Jordan Rose
6435b64d6a [driver] Write textual output to stdout if no -o option is given.
Swift SVN r13468
2014-02-05 01:34:44 +00:00
Jordan Rose
c08571901c [driver] Refactor output filename generation into a helper function.
Use early returns instead of nested ifs. No functionality change.

Swift SVN r13467
2014-02-05 01:34:43 +00:00
Jordan Rose
df1bb7dd54 Re-apply "[driver] Pass -Xfrontend options to the module-merge tool."
Re-apply r13400, reverted in r13405, with the test fixed to handle
SWIFT_NEW_DRIVER=OFF.

Swift SVN r13451
2014-02-04 22:46:46 +00:00
Michael Gottesman
c7e9c655f0 Revert "[driver] Pass -Xfrontend options to the module-merge tool."
This reverts commit r13400. This broke the build.

Swift SVN r13405
2014-02-04 05:48:51 +00:00
Jordan Rose
099d37830a [driver] Pass -Xfrontend options to the module-merge tool.
...and honor -o for -emit-module mode if we're not emitting any other kind
of output.

Swift SVN r13400
2014-02-04 01:32:46 +00:00
Jordan Rose
5fd7325c83 [driver] Don't crash when given an unknown argument!
Swift SVN r13267
2014-02-01 01:20:00 +00:00
Connor Wakamo
6f365157a9 [driver] Added support for specifying output levels.
Added an OutputLevel enum, which is used by Compilation to determine what kind
of output it should emit when performing Jobs.

In Driver::buildCompilation(), set the default OutputLevel for the Compilation
to Normal, but set it to Verbose if -v was passed. This means that, by default,
the driver will only print subtask output; this matches Clang's behavior.

Swift SVN r13255
2014-02-01 00:22:42 +00:00
Connor Wakamo
49d8d07224 [driver] Moved Command printing into Command::printCommandLine().
This was previously implemented in both Compilation::performJobsInList() and printJob().

Swift SVN r13253
2014-02-01 00:22:41 +00:00
Connor Wakamo
70b47ef783 [driver] Forward-declare DiagnosticEngine in Driver.h instead of including swift/ADT/DiagnosticEngine.h.
Also removed an unnecessary newline in the declaration of Driver’s constructor.

Swift SVN r13177
2014-01-30 22:42:19 +00:00
Connor Wakamo
0d483cdd88 [driver] Emit real diagnostics in the driver and integrated frontend instead of just printing to stderr.
Added DiagnosticsDriver.def and DiagnosticsDriver.h for driver-only diagnostics.
(Diagnostics which are shared with the frontend remain in
DiagnosticsFrontend.{def,h}.)

Added a DiagnosticEngine& to Compilation, so that it can emit diagnostics for
events which occur while performing Jobs.

Replaced all of the locations where we were manually printing error messages to
emitting real diagnostics, adding diagnostics if necessary.

Updated Driver::buildCompilation() so that it fails early if any errors were
encountered.

Updated test/Driver/actions.swift to pass a -module-name for multi-input tests.

Swift SVN r13175
2014-01-30 22:42:16 +00:00
Connor Wakamo
37d5f8d925 [driver] Do not issue an error if one of the multiple top-level outputs is a swiftmodule.
This will occur if -emit-{library,executable} and -emit-module is passed but -g
is not, since both the LinkJobAction and the MergeModuleJobAction will be
top-level actions.

Swift SVN r13139
2014-01-30 04:53:19 +00:00
Connor Wakamo
df76387cad [driver] Remove any preexisting diagnostics files before compilation.
Since the driver may create only some of the diagnostics files it was asked to
create, start by removing all diagnostics files so clients can detect the
presence of one to determine if the command which creates it actually ran.

This is important so that clients do not mix old and new diagnostics files,
which may occur in the event of a compilation error.

Swift SVN r13074
2014-01-28 23:52:40 +00:00
Jordan Rose
b77dccef4e [driver] Add the -emit-library option.
This emits a dynamic library as the final build product (rather than an
executable), as well as implicitly passing -parse-as-library to the frontend.

Swift SVN r12930
2014-01-24 19:46:39 +00:00
Jordan Rose
be735e5380 [driver] Only build a swiftmodule for debug purposes if we are linking.
Swift SVN r12926
2014-01-24 19:02:11 +00:00
Jordan Rose
76c04132c0 [driver] In -g mode, create the __SWIFT,__ast section used by the debugger.
The section contains a copy of the serialized module for the binary.

Swift SVN r12924
2014-01-24 18:42:08 +00:00
Jordan Rose
d24b212597 [driver] Use the input file name as the output executable name.
...when no -module-name or -o is provided.

This makes the single-file compile /very/ easy: compiling "foo.swift"
produces an output named "foo", rather than "a.out". For multi-file
modes, the module name is used if -o is missing; if no module name is
provided, it defaults to "main".

In a nutshell:
  explicit -o > explicit -module-name > single file's stem name > "main"

<rdar://problem/12593849>

Swift SVN r12841
2014-01-23 02:11:48 +00:00
Connor Wakamo
6384482902 [driver] Added support to honor the SDKROOT environment variable.
Centralized the driver-level handling of the SDK path in OutputInfo and
Driver::buildOutputInfo(), and added support for falling back to getenv(SDKROOT)
if -sdk wasn't passed (and SDKROOT is set in the environment).

Updated Swift::constructJob() to get the SDK path from the OutputInfo instead of
just passing -sdk from the original driver invocation.

Also added a driver-level check to ensure that the specified SDK is present;
if not, print out a warning. This fixes <rdar://problem/14409974>.

Added test/Driver/sdk.swift to test the -sdk and SDKROOT behavior, as well as
the nonexistent SDK warning.

Swift SVN r12815
2014-01-22 23:41:29 +00:00
Jordan Rose
c101e360a9 [driver] Use "const std::string &" instead of StringRef.
…for strings required to be null-terminated.

Swift SVN r12790
2014-01-22 21:56:24 +00:00