Commit Graph

1144 Commits

Author SHA1 Message Date
Jordan Rose
230443ae9a [REPL] Don't recursively IRGen imported modules if source imports are off.
This was causing all the external definitions to go from SILGen through
IRGen multiple times per REPL statement. Since this only matters if we
have source modules enabled, just turn it off.

We still generate all the external definitions for every REPL /line/, which
is the cause of <rdar://problem/16164076>.

Swift SVN r14467
2014-02-27 19:28:38 +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
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
Connor Wakamo
9747d87ff6 [frontend] Added a handful of options to force the frontend to assert or crash.
Added -debug-assert-immediately and -debug-crash-immediately, which cause an
llvm_unreachable or LLVM_BUILTIN_TRAP to execute during argument parsing.

Added -debug-assert-after-parse and -debug-crash-after-parse, which cause an
llvm_unreachable or LLVM_BUILTIN_TRAP to execute after calling
CompilerInstance::performParse().

This fixes <rdar://problem/16013025>.

Swift SVN r13653
2014-02-07 22:03:32 +00:00
Jordan Rose
302f9cb50d Disallow importing other Swift source files as modules.
Because this is useful in testing, I've left in a frontend option
-enable-source-import for both swift and swift-ide-test that sidesteps the
module restriction. Right now, though, this is the right thing to avoid
users running into strange issues when they import another file within
their module and Swift treats it as a separate module.

<rdar://problem/15937521>

Swift SVN r13248
2014-01-31 23:01:04 +00:00
Jordan Rose
6af4dbf0e9 Move SILLinkMode to SILOptions.
SILSerializeAll and EmitVerboseSIL are /not/ being moved because they are
options controlling the output, not about SILGen and SIL passes.

No functionality change.

Swift SVN r13197
2014-01-31 02:34:34 +00:00
Jordan Rose
c7f1064527 Extract '-sil-inline-threshold' from the performance inliner.
Plumbing this through to the inliner necessitated the creation of a
SILOptions class (like FrontendOptions and IRGenOptions). I'll move
more things into this soon.

One change: for compatibility with the new driver, the option must be
specified as "-sil-inline-threshold 50" instead of "-sil-inline-threshold=50".
(We're really trying to be consistent about joined-equals vs. separate
in the new frontend.)

Swift SVN r13193
2014-01-31 01:52:12 +00:00
Jordan Rose
bac31d985a Add '-sil-serialize-all' testing option to the new frontend.
Swift SVN r13190
2014-01-31 01:02:06 +00:00
Jordan Rose
f165afe1aa Replace "-enable-sil-linking=false" with "-disable-sil-linking".
Also, restructure so that the option isn't declared in a random library file.
(And do the same with "-sil-link-all".)

Part of the migration to the new driver.

Swift SVN r13184
2014-01-31 00:02:46 +00:00
Jordan Rose
d0d4286d21 Put modules for 32-bit iOS builds in lib/swift/iphone{os,simulator}/32.
This keeps us from having to deal with fat swiftmodules for now.
In the long run we're hoping to solve this problem with build configurations,
so that a single module file can support multiple architectures.
(See <rdar://problem/15056323>)

<rdar://problem/15204953>

Swift SVN r13135
2014-01-30 03:26:50 +00:00
Jordan Rose
12fb34d60f Eliminate "Immediate" flag from CompilerInvocation.
This adds some ugliness in the current swift binary because we weren't
bothering to set a requested action before, but it keeps things simpler
elsewhere. (Thanks, Connor.)

Swift SVN r13067
2014-01-28 22:20:13 +00:00
Connor Wakamo
552558d03f [frontend] Removed the separate TargetOptions class.
TargetOptions only contained the target triple, which was duplicated in
IRGenOptions. These could get out-of-sync, which would cause issues during
IRGen. Since nothing was using TargetOptions other than CompilerInvocation,
removed TargetOptions in favor of making IRGenOptions the canonical home of the
target triple.

Swift SVN r12869
2014-01-23 19:07:55 +00:00
Connor Wakamo
947f3be6e7 [driver] Removed the limited support for -module-source-list.
This option was never honored, and the main functionality that this option
would have implemented has been subsumed by -output-file-map.

Swift SVN r12800
2014-01-22 22:37:21 +00:00
Adrian Prantl
035a1175df Debug info: Ensure that the SDK is emitted if it is implicit. Also do a
slightly better job at quoting.
<rdar://problem/15808224> Point ClangImporter at the right SDK for the target

Swift SVN r12310
2014-01-15 01:51:41 +00:00
Connor Wakamo
3a1810336e [frontend] Implement support for emitting modules with the integrated frontend.
Added support for the -emit-module and -module-output-path options. -emit-module
and -module-output-path function similarly to -serialize-diagnostics and
-serialized-diagnostics-path: notably, -module-output-path implies -emit-module,
but -emit-module can be passed without -module-output-path and a default path
will be determined based on other inputs.

Added support for the -module-link-name option, which specifies the name of the
library to link against when importing the generated module.

Note that support for these options is only implemented in the integrated
frontend; driver-level support for these options is forthcoming.

Swift SVN r12301
2014-01-14 23:38:36 +00:00
Connor Wakamo
b0f27de6b8 [frontend] Move InputKind from CompilerInvocation to FrontendOptions, and move handling of -parse-as-library to ParseFrontendArgs().
Swift SVN r12174
2014-01-11 00:33:30 +00:00
Connor Wakamo
044be74855 [frontend] Move ParseStdlib from CompilerInvocation to FrontendOptions, and move handling of -parse-stdlib to ParseFrontendArgs().
Swift SVN r12173
2014-01-11 00:33:30 +00:00
Connor Wakamo
a35540be40 [frontend] Added CompilerInstance::getPrimarySourceFile().
During CompilerInstance::performParse(), set CompilerInstance::PrimarySourceFile if we create a SourceFile from a buffer whose ID matches the PrimaryBufferID.
This allows clients of CompilerInstance to get a SourceFile for the user-specified primary input.

Swift SVN r12156
2014-01-10 22:39:08 +00:00
Connor Wakamo
9f89b432b5 [frontend] Added CompilerInstance::PrimaryBufferID.
This maps a particular buffer ID to the PrimaryInput, which will (eventually) allow us to map a SourceFile to the PrimaryInput.

Swift SVN r12155
2014-01-10 22:39:07 +00:00
Connor Wakamo
6eb9a82465 [frontend] Switch CompilerInstance::MainBufferIndex to CompilerInstance::MainBufferID.
This matches how we will handle primary inputs.
This also fixes an issue where a file named main.swift may not be chosen as the main file if there were multiple inputs and it was replaced by an input buffer.

Swift SVN r12154
2014-01-10 22:39:07 +00:00
Connor Wakamo
c193138c33 [frontend] Added convenience accessors to determine if a SelectedInput is a filename or a buffer.
Swift SVN r12153
2014-01-10 22:39:06 +00:00
Connor Wakamo
18795f8293 [frontend] Switch from llvm::Optional to swift::Optional for FrontendOptions::PrimaryInput.
Swift SVN r12152
2014-01-10 22:39:06 +00:00
Connor Wakamo
8475eeaad3 [frontend] Make InputKind::Filename the default InputKind for a SelectedInput.
Nearly all uses of this will be to specify a filename, so make that the default.

Swift SVN r12149
2014-01-10 22:39:04 +00:00
Connor Wakamo
e9cc548765 [frontend] Added support in FrontendOptions for denoting the primary input.
When a primary input is specified, output will only be generated for that input. (If a primary input is not specified, output will be generated for the whole module.)
This commit only adds the storage for the primary input; the primary input is not yet honored by the frontend, nor is it possible to specify the primary input.

Swift SVN r12148
2014-01-10 22:39:04 +00:00
Connor Wakamo
d360c2d167 [frontend] Moved InputBuffers from CompilerInvocation to FrontendOptions.
Swift SVN r12147
2014-01-10 22:39:04 +00:00
Greg Parker
0e360cb26e Install stdlib into /usr/lib/swift/<OS name>/.
This reinstates r11411 with fixes for the autoconf+make build.


Swift SVN r11494
2013-12-20 01:01:35 +00:00
Connor Wakamo
39bb2bf2a2 [frontend] Added proper support for parsing -l and -framework.
Moved the responsibility for storing LinkLibraries from CompilerInvocation to the invocation’s IRGenOpts.
Moved the handling of -l and -framework into ParseIRGenArgs.

Swift SVN r11450
2013-12-18 23:42:51 +00:00
Connor Wakamo
41b0a59644 [frontend] Add an IRGenOptions to CompilerInvocation.
Swift SVN r11447
2013-12-18 23:42:47 +00:00
Chris Lattner
073974dca4 revert r11411, which completely broke the makefile build.
Swift SVN r11414
2013-12-18 04:33:58 +00:00
Greg Parker
9032632299 Install stdlib into /usr/lib/swift/<OS name>/.
Swift SVN r11411
2013-12-18 02:19:29 +00:00
Connor Wakamo
9861019cc5 [frontend] Add a member function to FrontendOptions which returns whether or not the RequestedAction has output.
Swift SVN r11393
2013-12-17 21:34:24 +00:00
Connor Wakamo
3705f018ac [frontend] Make -dump-parse explicitly set ParseOnly to true.
Also updated the comments in FrontendOptions::ActionType to indicate that only -dump-parse skips type-checking. (Previously, the comments implied that -parse also skipped type-checking, which is not the desired behavior.)

Swift SVN r11374
2013-12-17 02:43:39 +00:00
Connor Wakamo
2216a31de6 [frontend] Moved ParseOnly from CompilerInvocation to FrontendOptions.
Swift SVN r11373
2013-12-17 02:43:39 +00:00
Connor Wakamo
20e0d1c64e [frontend] Add support for parsing the action which the integrated frontend should perform.
Added an ActionType enum to FrontendOptions with the various actions that the integrated frontend will support, as well as a new RequestedAction member.
Added support for determining the user’s requested action in ParseFrontendArgs. (The integrated frontend does not yet honor this request; support for that is forthcoming.)

Swift SVN r11372
2013-12-17 02:43:27 +00:00
Connor Wakamo
40dfbc0bc8 [frontend] Add support for parsing ImmediateArgv.
These are not yet used, since the integrated frontend doesn’t yet support immediate mode, but they are ready for use once immediate mode is supported.

Swift SVN r11326
2013-12-15 00:58:28 +00:00
Connor Wakamo
0d3369be03 [frontend] Add support for -help and --help-hidden.
Added PrintHelp and PrintHelpHidden to FrontendOptions.
Marked both -help and --help-hidden with the FrontendOption flag.
Updated ParseFrontendArgs to parse -help and --help-hidden.
Updated frontend_main() so that it prints the help for the frontend options.

Swift SVN r11320
2013-12-14 23:52:15 +00:00
Connor Wakamo
a1266393cd [frontend] Implemented support for verifying diagnostics with the integrated frontend.
Added a new DiagnosticOptions class to swiftBasic, and added a DiagnosticOptions member to CompilerInvocation.
Added a static ParseDiagnosticArgs function to parse diagnostic-related arguments.
Added -verify to FrontendOptions.td, and added support for parsing -verify in ParseDiagnosticArgs.
Updated frontend_main() to enable and trigger the DiagnosticVerifier when -verify is passed.

Swift SVN r11318
2013-12-14 22:08:08 +00:00
Connor Wakamo
f203e1fd96 [frontend] Moved ModuleSourceListPath from CompilerInvocation to FrontendOptions.
Also moved the handling of -module-source-list from the loop to ParseFrontendArgs.

Swift SVN r11290
2013-12-14 01:44:12 +00:00
Connor Wakamo
8f465324cf [frontend] Split target-related options out from ComplierInvocation into a new TargetOptions class.
Removed CompilerInvocation::TargetTriple and replaced it with CompilerInvocation::TargetOpts, a TargetOptions object.
Added a static ParseTargetArgs function to set up TargetOptions, and moved handling of -target into that function.

Swift SVN r11288
2013-12-14 01:28:13 +00:00
Connor Wakamo
20ce2ba390 [frontend] Moved SDKPath from CompilerInvocation to SearchPathOptions.
Swift SVN r11237
2013-12-13 04:52:58 +00:00
Connor Wakamo
9a1c706be7 [frontend] Moved FrameworkSearchPaths from CompilerInvocation to SearchPathOptions.
Swift SVN r11216
2013-12-12 22:36:42 +00:00
Connor Wakamo
1ecc5cc3e6 [frontend] Moved ImportSearchPaths out of CompilerInvocation/ASTContext and into SearchPathOptions.
Also updated findModule() in SourceLoader.cpp and SerializedModuleLoader.cpp to get the ImportSearchPaths from the ASTContext’s SearchPathOpts, instead of directly from the ASTContext.

Swift SVN r11214
2013-12-12 22:15:58 +00:00
Connor Wakamo
86b4a3b049 [frontend] Begin moving search path-related options into SearchPathOptions.
Added a new SearchPathOptions class to swiftAST, which will contain options like import search paths and the SDK path.
Moved the RuntimeIncludePath from CompilerInvocation into SearchPathOptions. For now, at least, the RuntimeIncludePath is handled separately from other ImportSearchPaths, since we can’t yet guarantee that RuntimeIncludePath is set up before we parse the ImportSearchPaths.
Added a SearchPathOptions member to ASTContext.
Updated findModule() in SourceLoader.cpp and SerializedModuleLoader.cpp to check RuntimeIncludePath after everything else if no module was found. (This matches existing behavior, which had RuntimeIncludedPath at the end of ImportSearchPaths.)

Swift SVN r11213
2013-12-12 21:38:11 +00:00
Connor Wakamo
e6b0f16ad0 [frontend] Add support for -print-stats.
Swift SVN r11190
2013-12-12 17:44:51 +00:00
Connor Wakamo
23a60d60d8 [frontend] Added support for -delayed-function-body-parsing.
Swift SVN r11188
2013-12-12 17:32:02 +00:00
Connor Wakamo
8661d230b4 [frontend] Added an accessor to CompilerInvocation to get the invocation's ClangImporterOptions.
Swift SVN r11181
2013-12-12 03:59:58 +00:00
Connor Wakamo
04bdf73b91 [frontend] Move options for controlling the behavior of the Clang importer into a new ClangImporterOptions class.
Added a new ClangImporterOptions class which wraps the ModuleCachePath and ExtraArgs for the Clang importer.
Added a new ParseClangImporterArgs static function which fills in the passed-in ClangImporterOptions.
Updated CompilerInvocation and CompilerInvocation::parseArgs() to use ClangImporterOptions and ParseClangImporterArgs, respectively.

Swift SVN r11180
2013-12-12 03:53:20 +00:00
Connor Wakamo
d14959b586 [frontend] Switch from providing a constructor for FrontendOptions to providing default values for its members.
Swift SVN r11173
2013-12-12 03:17:43 +00:00
Connor Wakamo
4ede1d0c23 [frontend] Added support for parsing the “-emit-verbose-sil” frontend argument.
This is not yet hooked up anywhere (beyond FrontendOptions), since the integrated frontend does not yet know how to emit SIL.

Swift SVN r11161
2013-12-12 00:48:13 +00:00