Commit Graph

56 Commits

Author SHA1 Message Date
zaks
2110235fd3 [asan] Cleanup based on Jordan's review comments 2016-02-26 16:02:40 -08:00
zaks
ef925f8fb3 [asan] Add basic support for Address Sanitizer function instrumentation
ASan allows to catch and diagnose memory corruption errors, which are possible
when using unsafe pointers.

This patch introduces a new driver/frontend option -sanitize=address to enable
ASan. When option is passed in, the ASan llvm passes will be turned on and
all functions will gain SanitizeAddress llvm attribute.
2016-02-24 09:45:38 -08:00
Jordan Rose
7552d49c4a [Driver] Eliminate unused fields from Compilation.
No functionality change.
2016-01-12 16:17:27 -08:00
Jordan Rose
5f78d24e85 [Driver] Make the list of input files available when creating Jobs.
Previously jobs had to grovel this information out of the raw argument
list, which dropped the types we had inferred on input files. This
makes things more consistent across the compiler, though arguably we
should be able to designate "primary" and "non-primary" inputs on a
per-action basis rather than resorting to "global" state.

Use this new information to stop passing object file inputs to the
Swift frontend, fixing rdar://problem/23213785.

The list wouldn't have to live on the Compilation, but I'm going to use
it to fix SR-280 / rdar://problem/23878192 as well.
2016-01-12 11:52:31 -08:00
Jordan Rose
af8eb3766d [Driver] Constify a parameter. No functionality change. 2016-01-12 11:52:31 -08:00
Jordan Rose
dbd0d47568 [Driver] Only JobActions have inputs, not InputActions.
Also, cluster the flags on Action into a single word. This probably doesn't
make any real difference, but it's the convention.

No functionality change.
2016-01-12 11:52:31 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
practicalswift
f91525a10f Consistent placement of "-*- [language] -*-===//" in header. 2016-01-04 09:46:20 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Michael Gottesman
c03adef030 Fix "Adjust to InputArgList being a move-only type"
DerivedArgList has a pointer to the InputArgList it came from, so we can't
just std::move it around. Put most of the driver back the way it was, with
small changes to clarify ownership.

Swift SVN r31811
2015-09-09 04:37:29 +00:00
Michael Gottesman
d6cdce1013 Adjust to InputArgList being a move-only type
Swift SVN r31800
2015-09-09 04:37:17 +00:00
Slava Pestov
d072199251 Driver: getToolChain()'s DarwinArchName parameter was never set, remove it together with some associated dead code, NFC
Swift SVN r30255
2015-07-16 07:08:39 +00:00
Jordan Rose
036b083138 [Driver] Eliminate the JobList class.
This was just a wrapper around SmallVector that optionally owned the Job pointers
in it. Now that all Jobs are owned by the Compilation, we don't have to worry
about this any more.

No functionality change.

Swift SVN r29668
2015-06-25 15:45:45 +00:00
Jordan Rose
482cfac8a1 [Driver] Store all Jobs in a flat list in the Compilation object.
The Compilation is now the only owner of the Jobs.

No end-user functionality change.

Swift SVN r29667
2015-06-25 15:45:43 +00:00
Jordan Rose
2b7b78d162 [Driver] A .swift file should be rebuilt if its mtime has changed.
...not if it's newer than its output .o file. This handles cases where the
object file is generated too quickly (rdar://problem/19404140) or when you
revert to a previous version of the file, mtime intact (rdar://problem/19720146).

There's a lot of test churn here; the only real new test is the backwards
mtime update in one-way.swift.

Swift SVN r29584
2015-06-24 00:06:58 +00:00
Argyrios Kyrtzidis
8b250d6d35 [driver] Remove the 'swift-fixit' symlink and introduce '-emit-fixits-path' frontend option that
writes compiler fixits as source edits.

Driver option '-fixit-code' adds '-emit-fixits-path' for all the frontend invocations.

Swift SVN r27208
2015-04-10 17:33:29 +00:00
Argyrios Kyrtzidis
623b9827b4 [driver] Separate "delegate to the migrator with swift-update" and "get compiler fixits with swift-fixit" functionalities.
Swift SVN r27139
2015-04-08 22:02:23 +00:00
Erik Eckstein
5537cf84ca Driver: Support -num-threads <n> option.
Together with -wmo it enables multi-threaded compilation.
I didn't want to reuse the -j option for this, because -num-threads (even if n == 1) does change the generated code.
For details see commit message of r25930.



Swift SVN r26258
2015-03-18 10:05:11 +00:00
Erik Eckstein
cedc6c5671 Driver: simplify handling of temporary files.
Should be NFC.



Swift SVN r26228
2015-03-17 17:06:25 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Jordan Rose
9cb81b0006 [driver] Add support for invoking ld.
swift_driver can now end-to-end compile a Swift file. Try it yourself!

echo 'println("hello")' | swift_driver -

Swift SVN r12840
2014-01-23 02:11:47 +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
Connor Wakamo
77890aa5cc [driver] Added initial support for loading an OutputFileMap.
Added an -output-file-map option which will specify the path to an
OutputFileMap.

Added Driver::buildOutputFileMap(), which constructs an OutputFileMap
from the arguments.

Added OutputFileMap* parameters to Driver::buildJobs() and
Driver::buildJobsForAction(). (These parameters are not yet honored, except to
pass to calls of these functions.)

Swift SVN r12772
2014-01-22 21:07:05 +00:00
Connor Wakamo
a982000175 [driver] Added a hidden -force-single-frontend-invocation option.
This sets OutputInfo::CompilerMode to a new SingleCompile mode, which in turn
causes the driver to create a single CompileJobAction for all inputs. This mode
also prevents the creation of a MergeModuleJobAction, since we can rely on the
frontend to generate a full swiftmodule.

This mode will allow the driver to properly compile the stdlib; if this mode is
necessary for other inputs, we can rename and publicize this option.

Swift SVN r12612
2014-01-20 21:47:17 +00:00
Connor Wakamo
bb439764b4 [driver] Implemented driver-level support for immediate mode and the REPL.
Introduced OutputInfo::Mode and OutputInfo::CompilerMode, which dictate how the
driver should invoke the integrated frontend. Currently, there are three
options:

- StandardCompile: invoke the frontend once-per-input, using -primary-file
- REPL: invoke the frontend as the REPL
- Immediate: invoke the frontend in immediate mode

Updated buildOutputInfo() to properly set the CompilerMode, and updated
buildActions() and Swift::constructJob() to honor the CompilerMode.

With these changes, "swift_driver" (with no inputs) and "swift_driver -repl"
should invoke the REPL, and "swift_driver -i" should invoke the frontend in
immediate mode.

Swift SVN r12547
2014-01-18 20:55:21 +00:00
Connor Wakamo
62d1fec41e [driver] Added support for suppressing the "no input files" error.
While SuppressNoInputFiles is not yet set, this is necessary for driver-level
support for the REPL, which requires no input files.

Swift SVN r12545
2014-01-18 20:55:19 +00:00
Connor Wakamo
622b83b98d [driver] Updated OutputInfo with a ShouldTreatModuleAsTopLevelOutput field.
This will indicate that the generated module was user-requested, so it should be
placed alongside other outputs.

Updated buildOutputInfo() in a few ways:
  - Updated it to set ShouldTreatModuleAsTopLevelOutput correctly.
  - Updated it such that -g implies that a module should be generated, but treated as an intermediate.
  - Moved the fallback ModuleName handling into buildOutputInfo(), which requires passing an InputList.

Swift SVN r12502
2014-01-17 19:39:25 +00:00
Connor Wakamo
6a33e53258 [driver] Renamed OutputMode to OutputInfo.
OutputInfo no longer just describes a "mode", so use a more applicable name for
the class.

Swift SVN r12501
2014-01-17 19:39:25 +00:00
Connor Wakamo
db3888ba0f [driver] Replaced Tool::constructJob()’s LinkingOutput parameter with an OutputMode parameter.
Moved OutputMode out of Driver and directly into swift::driver.
Adjusted callers of Tool::constructJob() to pass an OutputMode.

Swift SVN r12497
2014-01-17 19:39:23 +00:00
Connor Wakamo
11a6121caa [driver] Updated OutputMode to include the module name.
This is centralized, as many Commands need to reference the module name.

Swift SVN r12496
2014-01-17 19:39:23 +00:00