Commit Graph

75 Commits

Author SHA1 Message Date
Jordan Rose
41700b03da Add a new (hidden) option -autolink-force-load.
This option puts a special symbol into the generated object files that other
object files can reference to force the library to be loaded.

The next commit will modify the way we serialize autolinking information so
that importers of this module will always emit a reference to this symbol.
This means the library will be linked into the final binary even if no other
symbols are used (which happens for some of our overlays that just add
category methods to Objective-C classes).

Part of <rdar://problem/16829587>

Swift SVN r17750
2014-05-09 01:07:07 +00:00
Jordan Rose
465b083ba9 [serialization] Serialize the header path used by -import-objc-header.
This doesn't handle cross-references to decls /loaded/ from the header
just yet, so all that's testable right now is whether the header's imports
are visible from the secondary target (after being imported in response
to loading the serialized module).

More of <rdar://problem/16702101>

Swift SVN r17638
2014-05-07 19:03:21 +00:00
Arnold Schwaighofer
3ba7225aa3 Fix the driver's handling of the AssertConfig option
The driver was not passing the 'AssertConfig' option to the frontend.

rdar://16805810

Swift SVN r17472
2014-05-05 18:21:57 +00:00
Joe Pamer
006158ff56 Always emit detailed type check diagnostics, update unit tests to reflect this.
Swift SVN r17334
2014-05-03 23:03:47 +00:00
Doug Gregor
4996efbfba Implement support for making "with" implicit on the first argument of an initializer.
When importing an Objective-C init method or factory method into an
initializer, if the first camelCase word of the first argument name
starts with "with", drop the "with". This means that

  -initWithRed:green:blue:alpha:

will get imported into Swift as

  init(red:green:blue:alpha:)

as will

  +colorWithRed:green:blue:alpha:

This is <rdar://problem/16795899>, hidden behind the
-implicit-objc-with flag.

Swift SVN r17271
2014-05-02 21:13:04 +00:00
Jordan Rose
cf77de720a Add -import-objc-header option, and wire up the basic infrastructure.
THIS IS NOT READY FOR USE YET.

The new plan for mixed-source non-framework targets is that the Swift
compiler will import an Objective-C header directly, and treat the decls
and imports in that header as explicitly visible to the entire target.
This means users don't have to modularize their headers before bringing
them into Swift.

This commit adds the option and introduces the "imported headers" module
as an implicit import for the source files being compiled. It also directs
the Clang importer to process the given header (using #import, so that it
won't somehow get included twice) and watches for any module imports that
occur as a result of reading that header.

Still to come: import of decls within the header (not within any module),
and proper serialization of cross-references to the header and its imports.

Part of <rdar://problem/16702101>

Swift SVN r17218
2014-05-02 00:55:31 +00:00
Doug Gregor
667d90c1f4 Start diagnosing scalar-to-tuple conversions that are missing a keyword argument.
Another baby step toward <rdar://problem/14462349>, made even more
tepid by the fact that I've quarantined this behind a new flag,
-strict-keyword-arguments. Enforcing this breaks a lot of code, so I'd
like to bring up the new model on the side (with good diagnostics that
include Fix-Its) before trolling through the entire standard library
and testsuite to fix violations of these new rules.


Swift SVN r17143
2014-05-01 06:15:30 +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
Greg Parker
4c9c52fb81 <rdar://15931346> Fix KVO.
* Temporarily turn on -link-objc-runtime by default. This will be 
  removed again in rdar://16753644.
* Symlink XcodeDefault.xctoolchain's copies of arclite into the Swift build's 
  resource directory so tests can see it.
* Enable the KVO test.


Swift SVN r17132
2014-05-01 01:39:23 +00:00
Mark Lacey
35c3799d2a Handle -target-abi as a frontend option and default it to darwinpcs for arm64/Darwin.
Swift SVN r17077
2014-04-30 06:12:54 +00:00
Jordan Rose
8699a3b83f Add -import-underlying-module option.
This option implicitly imports the Clang module with the same name as the
module being built into every source file in the module being built.
This will be used for mixed-source framework targets to give Swift code the
same implicit visibility for Objective-C decls in the same module that it
already has for other Swift decls.

<rdar://problem/16701230>

Swift SVN r17053
2014-04-29 23:13:45 +00:00
Jordan Rose
8f80f43e72 Add -[no-]link-objc-runtime option that controls the linking of arclite.
Currently arclite is never linked into a binary unless you pass the option.
See <rdar://problem/16679045> for more information.

Swift SVN r17003
2014-04-28 23:39:16 +00:00
Jordan Rose
84f4d3b9fa Sink some triple predicates into swiftBasic.
getPlatformNameForTriple isn't currently being used anywhere elsee, but
this seems more consistent.

No functionality change.

Swift SVN r17002
2014-04-28 23:39:15 +00:00
Joe Pamer
4cae5e82e8 Add a "detailed-diagnostics" flag to control emission of more detailed diagnostics for expression type-check failures.
Swift SVN r16988
2014-04-28 19:13:07 +00:00
Doug Gregor
5698fd3b8a Don't look in the standard import locations when building the core standard library.
This is a better way to fix the Darwin overlay <-> swift_stdlib_core
inferred circular dependency <rdar://problem/16603168>.

Swift SVN r16476
2014-04-17 22:07:48 +00:00
Doug Gregor
96bc99e3c4 Revert "Add a flag -ignore-overlays to ignore overlays, and use it when building the standard library."
This reverts commit r16383.

Swift SVN r16475
2014-04-17 22:07:47 +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
Doug Gregor
f384cbfe63 Add a flag -ignore-overlays to ignore overlays, and use it when building the standard library.
Fixes <rdar://problem/16603168>. This was way too much engineering
effort to ban fork() and vfork().

Swift SVN r16383
2014-04-16 00:02:38 +00:00
Doug Gregor
2d28d70bf8 Remove the language/driver/frontend options to enable/disable mangled names for the ObjC runtime.
Burn the bridges!


Swift SVN r16277
2014-04-13 05:36:08 +00:00
Ted Kremenek
2d4342b87a Give an error if “@obj” is used without importing ObjectiveC.
The standard library is exemptmpt (-parse-stdlib) from this checking.

Implements <rdar://problem/16559137>.

Swift SVN r16155
2014-04-10 09:08:09 +00:00
Doug Gregor
2424200990 Thread -split-objc-selectors through the driver.
Swift SVN r15879
2014-04-03 17:07:36 +00:00
Doug Gregor
9400e890d3 Emit @objc classes using namespaced names under a new flag -enable-objc-mangling.
Centralize the logic for figuring out what name to use for a class or
protocol in the Objective-C runtime. When the flag is enabled (it's
still disabled by default), use mangled names for all Swift-defined
classes, including those that are @objc. Note that the naming is
determined in the AST, because we're also going to use this logic when
printing an Objective-C header for Clang's consumption. The mangled
names will always start with _Tt, so they're easy to recognize and
demangle in various tools or, eventually, in the Objective-C runtime.

The new test (test/IRGen/objc_mangling.sil) is the only test of this
behavior at the moment. The other test changes are due to the
centralized logic tweaking the names of internal constants (_DATA_*,
_CATEGORY_*, etc.).

This is the majority of <rdar://problem/15506580>.



Swift SVN r15588
2014-03-28 23:00:08 +00:00
Ted Kremenek
8162660be6 Wire up basic driver support for App Extension restrictions.
The frontend/driver flag is "-application-extension'.  This
activates a language option which will be used for more restrictive
availability checking.

Operationally, this also passes...
  - "-fapplication-extension" to the clang importer
  - "-application_extension" to ld

Swift SVN r15543
2014-03-27 01:05:43 +00:00
Jordan Rose
1fec0510f7 [driver] Pass -Xcc options down to frontend tools.
These options are supposed to go to the Clang importer, but we were just
dropping them on the floor.

Swift SVN r15300
2014-03-20 21:53:48 +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
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00
Jordan Rose
11e9ec50c8 [driver] Pass -module-cache-path and -F to both compilation and module merging.
Previously we only passed -module-cache-path to the compilation jobs, which
meant the module merging jobs would default to using the system module cache
(which means double the Clang work if the module cache had been set, and
strange errors during development when Clang's serialized format changes).

We hadn't been passing -F to either job because we hadn't been worrying
about non-system frameworks, but that's likely to change soon.

I also consolidated the forwarding of -Xfrontend args in this commit.
I've convinced myself that this will pretty much always be necessary for the
merge-module step, and that we should have something else if we really
need to differentiate the two.

<rdar://problem/16113207>

Swift SVN r14114
2014-02-19 23:31:21 +00:00
Greg Parker
9a1cf1af16 Work around linker confusion by the Swift marker in ObjC metadata (rdar://16107696).
Swift SVN r14078
2014-02-19 09:22:38 +00:00
Jordan Rose
93b87edcbe Add -resource-dir option to find lib/swift directory.
This is equivalent to Clang's -fresource-dir; it provides the location of
compiler modules and libraries.

No end-user-visible changes, but the iOS build will no longer have to use
-I to build and test its own standard libraries.

Swift SVN r13888
2014-02-14 01:27:15 +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
Michael Gottesman
f88bc1ed3e Teach the frontend how to pass through -Xllvm commands.
This patch allows you to pass through commands to llvm from the driver so now
one can when compiling swift files get debug messages!

Swift SVN r13761
2014-02-10 22:49:56 +00:00
Argyrios Kyrtzidis
5cef0f74db [Driver] Pass '-module-cache-path' to the frontend.
Swift SVN r13682
2014-02-08 19:15:17 +00:00
Greg Parker
3e2d63fadc [driver] Pass the correct linker deployment target for iOS simulator.
Swift SVN r13627
2014-02-07 05:25:41 +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
7358f8c5dc [driver] Fix -S mode to not crash.
Convert a switch with a default case to explicitly list all cases.

Swift SVN r13466
2014-02-05 01:34:42 +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
80ea14a1f4 [driver] Pass the SDK to the merge-module tool.
...as well as the target triple, include paths, and whether or not we're
compiling with debug info. (The last one doesn't currently make any
difference, but it seems prudent to be consistent.)

<rdar://problem/15930675>

Swift SVN r13080
2014-01-29 00:39:09 +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
Connor Wakamo
96105255b6 [driver] Added support for passing a few additional arguments through to the frontend.
Pass -module-link-name, -I, -l, and -framework through to the frontend.

Swift SVN r12929
2014-01-24 19:32:28 +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
Dave Zarzycki
6eba6ceeeb Zap accumlated unused variable warnings in non-assert builds
Swift SVN r12861
2014-01-23 08:11:37 +00:00
Dave Abrahams
d58caea0cd Revert "Zap accumlated warnings in non-assert builds"
This reverts r12850, which broke the build for me.

Swift SVN r12856
2014-01-23 06:47:29 +00:00
Dave Zarzycki
17eb84d9c6 Zap accumlated warnings in non-assert builds
Swift SVN r12850
2014-01-23 05:45:24 +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
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
Connor Wakamo
0a3202a46a [driver] Standardized the names of output-specifying options for secondary outputs.
The new format is "-<option>" and "-<option>-path". As a result:
  - Renamed -serialized-diagnostics-path to -serialize-diagnostics-path.
  - Renamed -module-output-path to -emit-module-path.

Swift SVN r12614
2014-01-20 23:16:22 +00:00
Connor Wakamo
66d4c813d4 [driver] Added serialized diagnostics as an additional output for compile commands.
Added a SerializedDiagnostics entry to Types.def.
In Driver::buildJobsForAction(), set an appropriate path for serialized
diagnostics, if requested. In Swift::constructJob(), check for an additional
SerializedDiagnostics output to determine if -serialize-diagnostics and
-serialized-diagnostics-path should be passed.

This is necessary infrastructure for the output file map.

Swift SVN r12613
2014-01-20 22:37:53 +00:00