Commit Graph

685 Commits

Author SHA1 Message Date
Erik Eckstein
cedc6c5671 Driver: simplify handling of temporary files.
Should be NFC.



Swift SVN r26228
2015-03-17 17:06:25 +00:00
Luqman Aden
0c6464aec7 [driver] Add -emit-sibgen option.
Swift SVN r25936
2015-03-10 18:31:08 +00:00
Luqman Aden
34b74cfa1c [driver] Add -emit-sib primary action.
Swift SVN r25783
2015-03-05 19:15:07 +00:00
Dmitri Hrybenko
cc05e7640b Disable Linux support in Apple B&I builds
Swift SVN r25633
2015-02-28 02:42:43 +00:00
Graham Batty
c48b5e1a0a Use LLVM's config to determine correct dylib ext.
Later this should be derived from the target so cross-compilation
does the right thing, but for now this at least makes it so that
it does the right thing for the non-cross-compile case.

Swift SVN r25564
2015-02-26 21:43:16 +00:00
Manman Ren
391e731796 [Driver] add -embed-bitcode for bitcode store project.
With -embed-bitcode, we will invoke swift twice, once to generate the bitcode
file, the second time to perform code generation on the bitcode file.

For now, -embed-bitcode causes -incremental builds to not be incremental,
because of potential issues of mixing the two.

rdar://19048891


Swift SVN r25559
2015-02-26 19:53:12 +00:00
Jordan Rose
02f0ee10c4 [Driver] Fix a use-after-free caught by the ASan bot.
Swift SVN r25533
2015-02-25 19:42:40 +00:00
Graham Batty
078a558b26 Extract autolink information as a compile step.
Swift SVN r25510
2015-02-24 20:33:05 +00:00
Jordan Rose
cadd851e1b [Driver] Warn when using -incremental without a proper output file map.
Just so people don't try to use it on the command line and then get
surprised.

Swift SVN r25508
2015-02-24 20:02:26 +00:00
Jordan Rose
6430d30a51 [Driver] For now, just ignore -incremental under -whole-module-optimization.
These aren't inherently incompatible, but today it would do nothing useful,
and using both flags together causes problems (see previous commit).

rdar://problem/19669432

Swift SVN r25389
2015-02-19 02:28:34 +00:00
Argyrios Kyrtzidis
7fd2ca6fc9 [driver] Introduce 'continue-after-building' functionality in the driver.
The '-update-code' mode is taking advantage of it to go through all the swift files, even though they have errors.

Swift SVN r24902
2015-02-02 21:57:04 +00:00
Jordan Rose
9a9a6969b7 [Driver] Error if we don't support the target we're given.
Also, normalize the target triple up front, so that we're never dealing
with non-normalized triples in the driver unless explicitly asking for
the original user option.

rdar://problem/18065292

Swift SVN r24563
2015-01-20 20:42:03 +00:00
Jordan Rose
6e0df7d65e [Driver] Rebuild everything when command-line arguments change.
If certain command-line arguments change, the results of the last
compilation aren't reusable, i.e. we can't do an incremental build.
Do a full rebuild when we detect that this happens.

(Which command-line options? Conservatively assume all of them, /except/
those with the new DoesNotAffectIncrementalBuild flag in Options.td.)

Swift SVN r24385
2015-01-13 01:11:38 +00:00
Jordan Rose
1b7cd80d1d [Driver] Track the latest a particular job could have been run.
This is mostly just a matter of not throwing away mtimes we were already
looking up. We can compare these values to the mtimes of cross-module
dependencies to find out what's been updated.

Part of rdar://problem/19270920

Swift SVN r24336
2015-01-10 00:38:11 +00:00
Argyrios Kyrtzidis
e021f5077d [swift-update] Treat 'swift-update' as a symlink to the driver, instead of a separate executable.
This avoids having another copy of the frontend in the toolchain.

Swift SVN r24320
2015-01-09 18:55:16 +00:00
Argyrios Kyrtzidis
7a7ad97815 [driver] Change 'UseUpdateCodeTool' boolean into a OutputInfo::Mode::UpdateCode compiler mode.
Swift SVN r24290
2015-01-09 01:08:08 +00:00
Argyrios Kyrtzidis
eb89a0c6c0 [driver] Introduce '--update-code' which enables the driver to spawn invocations
of 'bin/swift-update' with the related frontend options.

'swift-update' will be the tool for producing diffs to update swift code to the
latest version.

Swift SVN r24287
2015-01-08 23:46:13 +00:00
Jordan Rose
43bcbb8f9e [Driver] Handle outstanding jobs by reading the build record.
r23968 wrote out a record of which source files were included in a build,
and whether they were succesfully compiled or not...and if not, whether
they were out of date because of a cascading or non-cascading dependency.
This commit uses that information to decide what files might need to be
rebuilt even if a particular input doesn't change and doesn't appear to
have any changed dependencies. The two interesting cases are:

- A file was going to be built last time, but the build was halted
  because of an error. Build it this time.
- One of the files was removed and thus we've lost a source of dependency
  information; rebuild everything!

rdar://problem/19270980

Swift SVN r24018
2014-12-18 21:24:18 +00:00
Jordan Rose
94e7a284bd [Driver] Write out a record of which files were compiled in a build.
This is important because we might get part-way through the full
compilation, overwriting swiftdeps files as we go, and then encounter an
error. We don't want to lose information about any decls that have been
removed since the previous compile, so we propagate forward the information
we already have by saving it to a "build record" file.

More simply, this is necessary to track when a file is removed from a target.

The next commit will handle reading in this file at the start of a build.

Swift SVN r23968
2014-12-17 00:26:28 +00:00
Jordan Rose
c5547f7068 [Driver] Use return value instead of out parameter for buildOutputFileMap.
No functionality change, just a cleanup.

Swift SVN r23966
2014-12-17 00:26:25 +00:00
Jordan Rose
c385a9d43a [Driver] Make the "incremental" flag an explicit part of Compilation.
No functionality change. Laying groundwork for the next commit.

Swift SVN r23965
2014-12-17 00:26:23 +00:00
Chris Willmore
c6ac72e47a Add whole-module optimization option to Swift compiler
Add -whole-module-optimization option as synonym of
-force-single-frontend-invocation (for now). Add support for
-output-file-map when using -whole-module-optimization with multiple
input files -- the key for the single output file's map is the empty string.

<rdar://problem/18603795>

Swift SVN r23625
2014-12-03 00:20:09 +00:00
Adrian Prantl
30976b2eb3 No need to emit a Swift module in -gline-tables-only mode.
Thanks Jordan for pointing this out!

Swift SVN r23616
2014-12-02 18:07:37 +00:00
Adrian Prantl
41a30f5988 Support line table only DWARF for Swift. <rdar://problem/19106981>
The new option is called -gline-tables-only to mirror clang.

Swift SVN r23615
2014-12-02 17:44:23 +00:00
Graham Batty
e2258fa323 Only run dsymutil on darwin.
Swift SVN r23325
2014-11-14 20:14:11 +00:00
Jordan Rose
4870fa905f [Driver] Use -incremental as the top-level option for dependency tracking.
This was being staged as -emit-reference-dependencies, but it's affecting
a lot more than that. Eventually for command line builds this should also
preserve intermediate build outputs (like .o and .swiftmodule) for use in
later builds, rather than putting them in $TMPDIR and deleting them after.

This option is still hidden.

Swift SVN r23295
2014-11-13 00:19:04 +00:00
Jordan Rose
6ca70b3c49 [Driver] Add debug option -driver-use-frontend-path.
This will be used to test dependency analysis by substituting a different
executable to use as the frontend.

For debugging purposes only.

Swift SVN r23272
2014-11-12 18:06:08 +00:00
Jordan Rose
3a52f2ad5c [Driver] Provide a single API to iterate over all valid file types.
Previously we had three separate instances of iterating from TY_INVALID+1
to TY_LAST, completely breaking type safety. Now we have a nice little
wrapper that takes a closure, which should inline down to the same thing
anyway.

Also, eliminate TY_LAST and just use TY_INVALID as our sentinel.

Swift SVN r23222
2014-11-11 00:43:28 +00:00
Jordan Rose
0364724ec3 [Driver] Add an mtime test for single-file compilation jobs.
The Swift compiler is always fed the entire list of files in a module.
If it's told to track dependencies, though, it should look to see if it
actually needs to recompile all of its inputs. The first step in this is
to see which files are actually dirty, which it does by comparing the mtime
of each source file with the mtime of its output object file. If a source
file is not dirty, it only needs to be rebuilt if it depends on something
in a dirty file.

Nothing actually uses this information yet, but we can print it with
-driver-print-bindings!

Swift SVN r23221
2014-11-11 00:43:27 +00:00
Jordan Rose
1fdf0e48b4 [Driver] Add -emit-reference-dependencies to the driver.
This just adds another possible output kind and forwards it to the frontend.
Note that in builds without an output map, this will just dump the dependencies
next to the output file, which is a temp file whose name is chosen randomly.
That's not so useful, but we can fix it later.

Part of rdar://problem/15353101

Swift SVN r23220
2014-11-11 00:43:22 +00:00
Jordan Rose
c4fd29eb0b [Driver] Eliminate the common base class of Command and JobList.
...and rename Command to Job (previously the name of the base class).

We never generated job lists directly contained in other job lists, so
let's not even worry about this case. We may some day need to break Job
out into separate subclasses (Clang has Command and FallbackCommand in
addition to JobList), but we should be able to keep the list separate.

No intended functionality change.

Swift SVN r23144
2014-11-07 00:10:18 +00:00
Chris Willmore
1b6624a5cd llvm::sys::FindProgramByName() -> llvm::sys::findProgramByName()
llvm::sys::FindProgramByName() was removed in llvm r221258. Use
llvm::sys::findProgramByName() instead.

Swift SVN r23103
2014-11-04 19:51:08 +00:00
Jordan Rose
fe68e7512f Add a -gnone option that can negate a previous -g option.
The name -gnone was chosen by analogy with -O and -Onone. Like -O/-Onone,
the last option on the command line wins.

The immediate use case for this is because we want to be able to run the
tests with -g injected into every command line, but some tests will fail
when debug info is included. Those particular tests can be explicitly marked
-gnone.

rdar://problem/18636307

Swift SVN r22777
2014-10-15 22:12:07 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Graham Batty
a1e0b0fbf7 Driver: More stubbing for Linux support
Swift SVN r22362
2014-09-29 21:14:32 +00:00
Jordan Rose
48bcad35be Address review comments for r21845 and r21846, including updates to ABI.rst.
Thanks, Dmitri and Joe.

Swift SVN r21849
2014-09-10 20:35:30 +00:00
Jordan Rose
86b24b7d5f [Driver] Ban files with the same basename in the same module.
We use the basename to generate the private-discriminator. Why just the
basename? Because we want projects checked out in different locations to
still have a chance of generating identical binaries, and (at least for now)
private symbols still have external linkage.

Part of rdar://problem/17632175

Swift SVN r21845
2014-09-10 19:10:44 +00:00
Jordan Rose
2d727bb7a3 [Driver] Reject SDKs older than OS X 10.10 or iOS 8.
Actually, reject SDK directories whose names match
  "*OSX<version>(.Internal)?.sdk" on OS X with a version older than 10.10
  "*OS7*" on iOS
  "*Simulator7*" on iOS

We only really care about 10.9 anyway, but just in case people install the
one-previous version of iOS...

<rdar://problem/17951615>

Swift SVN r21100
2014-08-08 00:22:35 +00:00
Connor Wakamo
174323481c [driver] Added support for disabling the check that input files exist.
This is only exposed as API on Driver; this check cannot be disabled with a
command line option at this time.

Swift SVN r20930
2014-08-01 23:59:09 +00:00
Connor Wakamo
3722438826 [driver] Fix an assertion failure when running "swiftc -v -force-single-frontend-invocation".
Previously, the driver would unconditionally create a CompileJobAction if it was
in SingleCompile or Immediate mode. If there were no inputs, though, the driver
would end up asserting later because it could not create a Command for a
CompileJobAction with no inputs.

To match the behavior of the StandardCompile mode, avoid creating a
CompileJobAction if there are no inputs. (This change only affects -v, since it
disables the 'no input files' error which otherwise prevents this condition from
being hit.)

Additionally, added a test to check swiftc's behavior when no inputs are
provided.

Swift SVN r20900
2014-08-01 17:55:08 +00:00
Connor Wakamo
e47ded9113 [driver] Added a separate Parseable OutputLevel.
This level is selected by -parseable-output. This flag is only accepted by
swiftc, since it does not make sense for any of the interactive modes.
(Currently, this level prints out the same information as Verbose, with a
"Command: " string prepended.)

Additionally, in Compilation::performJobs, set RequiresBufferedOutput to true if
parseable output was requested, since parseable output will require buffered
output.

Part of <rdar://problem/15958329>.

Swift SVN r20872
2014-08-01 01:15:41 +00:00
Jordan Rose
c510b1d425 [Driver] Infer libFOO.dylib from a module name of FOO and vice versa.
(when in -emit-library mode)

The one catch is that if you specify an output file named "libFOO" with no
extension, the module name will still be "libFOO", not "FOO". Explicitly
providing both -o and -module-name is always allowed.

<rdar://problem/17827584>

Swift SVN r20869
2014-08-01 00:52:06 +00:00
Ben Langmuir
d197964680 Rename -integrated-repl to -deprecated-integrated-repl
Swift SVN r20781
2014-07-30 22:09:37 +00:00
Jordan Rose
0481b87ba5 Move target configuration setup into CompilerInvocation.
Without this, clients that don't use a CompilerInstance (like LLDB) won't
have target configuration options available.

Also, move minimum OS checking into the driver. This makes sure the check
happens early (and only once), and in general fits the philosophy of
allowing the frontend to use configurations that might be banned for users.

<rdar://problem/17688913>

Swift SVN r20701
2014-07-29 21:48:59 +00:00
Connor Wakamo
f6a025d058 [driver] Added support for the '--driver-mode=' flag.
There are two valid values for this: 'swift' and 'swiftc'. This flag must be
specified as the first option; otherwise, it will be ignored. This flag allows
the caller of the driver to force 'swift' to behave as 'swiftc', or vice versa,
and is useful in situations where the name of the executable cannot be changed.

Swift SVN r20656
2014-07-28 23:36:50 +00:00
Ben Langmuir
920a8ff343 Make using the -i flag an error
This flag is now obsoleted by the interactive driver and simply
complicates understanding the command-line parsing. Making it an error
to force users to move also allows us to reuse the flag in the future if
we like.

Swift SVN r20641
2014-07-28 20:19:27 +00:00
Ben Langmuir
07a3c7cbd5 Switch to the new swift/swiftc commmand line interface
This makes the command line interface to 'swift' the same as what was
previously in 'swifti', and removes the staging symlink.

For posterity, the command line behaviour for 'swift' is now:
* `swift` -> start the repl
* `swift script.swift` -> run script.swift (the old -i mode)
* Any arguments after the input file are forwarded to the script as
  Process.arguments
* A shebang line is something like #!/usr/bin/xcrun swift

The batch compiler 'swiftc' behaves much like the old 'swift'
executable, but without the interactive bits now in 'swifti'.

<rdar://problem/17710788>

Swift SVN r20540
2014-07-25 13:28:21 +00:00
Jordan Rose
f1fe319119 [Driver] Don't save .o in -g mode anymore (unless asked to).
Now that we invoke dsymutil before cleaning up temporaries, we don't need to
keep them around for later debugging.

<rdar://problem/16877574>

Swift SVN r20530
2014-07-25 01:31:44 +00:00
Jordan Rose
69533b53f7 [Driver] Invoke dsymutil after linking when invoked with -g.
This matches Clang's behavior, though this implementation does not check
that it's actually on a platform that uses dsymutil.

<rdar://problem/16012971>

Swift SVN r20529
2014-07-25 01:31:40 +00:00
Ben Langmuir
d2ef235237 Move the lit tests over to the new swift/swiftc interfaces
Most of the tests just got moved to swiftc, but some of them were
duplicated to apply to both swiftc and swift. A handful still use the
existing 'swift' because they are for the existing '-i' syntax.

Note: this means config.swift_driver now uses the staging symlink
'swifti'. The only thing preventing us from dropping the 'i' and getting
rid of the old interface is that Xcode hasn't moved to swiftc yet
<rdar://problem/17769327>.

Swift SVN r20467
2014-07-24 04:34:10 +00:00