Commit Graph

619 Commits

Author SHA1 Message Date
Saleem Abdulrasool
53b9eb46ed Frontend: add -autolink-library= option to support Windows
All modules on Windows need to link against one of {libcmtd.lib, libcmt.lib,
msvcrtd.lib, msvcrt.lib}.  In addition to being the C library, it is the
equivalent of crtbegin0.o on other targets.  It is responsible for providing the
entry point itself.  Traditionally, cl will embed the linkage requirement into
all objects based on the flags given -- one of {/MTd, /MT, /MDd, /MD}.  clang
emulates this via the `--dependent-lib=` option.  Emulate that behaviour in the
swift driver so that swift objects being compiled for Windows targets can
auto-link to the required libraries.
2016-07-06 17:53:04 -07:00
Joe Groff
231db9d108 Clang importer: Import ObjC 'id' as Swift 'Any' (behind a flag).
For experimentation purposes, add a flag to cause the Clang importer to map ObjC APIs using `id` to `Any` instead of `AnyObject`.
2016-07-05 12:29:45 -07:00
Adrian Prantl
6b1263bf5a [Driver] Add a -gdwarf-types option and set it up as an alias for -g (NFC-ish)
Background
----------

Now that Swift AST type support in LLDB has matured, we can stop emitting DWARF
type information by default to reduce compile time and ibject file size.
A future commit will change -g to emit only AST type references.

The full set of debug options will be
-gnone
-gline-tables-only
-g                 // AST types (= everything that LLDB needs)
-gdwarf-types      // AST types + DWARF types (for legacy debuggers)
2016-07-05 12:06:23 -07:00
Slava Pestov
011e306fe8 Sema: Add -enable-experimental-nested-generic-types frontend flag
Also, split up test/decl/nested.swift into several files.
2016-06-13 16:46:41 -07:00
gregomni
2f9ac3444e Disable typealiases in protocols and add frontend flag to re-enable.
Goes back to Swift 2.2 behavior of treating the 'typealias' keyword inside a protocol as a deprecated form of an associatedtype. To get the newer (but still partly buggy) behavior of treating it as an actual typealias, add "-Xfrontend -enable-protocol-typealiases" to the compile invocation. 'decl/typealias/typealias.swift' now uses this flag to continue testing the enabled behavior.
2016-06-01 14:11:56 -07:00
Dan Liew
827f573d6b Teach the Swift front-end to generate code with
"Sanitizer Coverage" with a new flag ``-sanitize-coverage=``. This
flag is analogous to Clang's ``-fsanitize-coverage=``.

This instrumentation currently requires ASan or TSan to be enabled
because the module pass created by ``createSanitizerCoverageModulePass()``
inserts calls into functions found in compiler-rt's "sanitizer_common".
"sanitizer_common" is not shipped as an individual library but instead
exists in several of the sanitizer runtime libraries so we have to
link with one of them to avoid linking errors.

The rationale between adding this feature is to allow experimentation
with libFuzzer which currently relies on "Sanitizer Coverage"
instrumentation.
2016-05-27 13:34:31 -07:00
David Farler
a38a4ce596 SwiftRemoteMirror: Turn on reflection metadata by default
Flip the enable flags to disable and make these IRGen options
true by default.

rdar://problem/26206547
2016-05-21 17:40:37 -07:00
David Farler
83c17d29b7 Remove -enable-refleciton-builtins flag, now unnecessary
We can always potentially emit 'builtin' reflection metadata, since
that now includes imported types referenced by the module.

rdar://problem/26259668
2016-05-12 20:49:35 -07:00
Jordan Rose
18c7592863 Add frontend option "-warn-long-function-bodies=<N>".
This is a /slightly/ more user-friendly option than
-debug-time-function-bodies; pass it a limit in milliseconds and
the compiler will warn whenever a function or multi-statement closure
takes longer than that to type-check.

Since it's a frontend option (and thus usually passed with -Xfrontend),
I went with the "joined" syntax as the common case. The usual "separate"
syntax of "-warn-long-function-bodies <N>" is also available.

As a frontend option, this is UNSUPPORTED and may be removed without
notice at any future date.

Additional caveats:
- Other parts of type-checking not measured by this may also be slow.
- May include first-use penalties (i.e. "this is slow because it's
  the first function that references an imported type, which causes
  many things to be imported")
- Does not report anything whatsoever about other phases of compilation
  (SILGen, optimization, IRGen, assembly emission, whatever).
- Does not catch anything accidentally being type-checked multiple times
  (a known issue for initial value expressions on properties).
2016-05-11 15:08:17 -07:00
John McCall
0793258bec Add a frontend option to enable use of the swiftcall convention. 2016-05-03 14:21:30 -07:00
Chris Willmore
af0c7bd620 Initial implementation of SE-0054 "Abolish IUO Type" (#2322)
This is a squash of the following commits:

* [SE-0054] Import function pointer arg, return types, typedefs as optional

IUOs are only allowed on function decl arguments and return types, so
don't import typedefs or function pointer args or return types as IUO.

* [SE-0054] Only allow IUOs in function arg and result type.

When validating a TypeRepr, raise a diagnostic if an IUO is found
anywhere other thn the top level or as a function parameter or return
tpye.

* [SE-0054] Disable inference of IUOs by default

When considering a constraint of the form '$T1 is convertible to T!',
generate potential bindings 'T' and 'T?' for $T1, but not 'T!'. This
prevents variables without explicit type information from ending up with
IUO type. It also prevents implicit instantiation of functions and types
with IUO type arguments.

* [SE-0054] Remove the -disable-infer-iuos flag.

* Add nonnull annotations to ObjectiveCTests.h in benchmark suite.
2016-05-03 14:06:19 -07:00
Ryan Lovelett
0c0bcbb094 Convert "armv7l" to "armv7" for the architecture component of paths (#2369)
On the Raspberry Pi 2 when trying to import Glibc, without this patch, it will attempt to
find the module map at "/usr/lib/swift/linux/armv7l/glibc.modulemap" and
fail to do so.

With this patch it will attempt to find the module map at
"/usr/lib/swift/linux/armv7/glibc.modulemap" where it will succeed in
finding the module map.

Similar behavior currently happens in the Driver and Frontend. To DRY up
this behavior it has been extracted to the Swift platform.
2016-05-02 15:25:58 -07:00
Doug Gregor
a2e03d556b Stage implementation of SE-0033 behind a flag, -enable-swift-newtype.
We're going to quarantine this feature behind a frontend flag for a
bit.
2016-04-25 18:03:04 -07:00
Joe Groff
825e02e2f1 Remove -enable-import-objc-generics staging flag. 2016-04-25 14:25:11 -07:00
Joe Groff
c49a992598 Turn on import of ObjC generics. 2016-04-25 11:56:13 -07:00
Slava Pestov
0d34bc21ef IRGen: Emit reflection metadata for certain builtin types when -enable-reflection-builtins flag is passed in
These types are not directly referenced as fields of aggregate types,
but are needed for reflection type lowering.

Also, use a SetVector to collect referenced builtin types, instead of
a SmallPtrSet, to ensure compiler output is deterministic.
2016-04-22 22:36:05 -07:00
John McCall
e4ddee46c0 Don't crash if a -filelist file doesn't exist or doesn't contain the primary file.
I know this is the frontend and not the driver, but c'mon.
2016-04-22 10:31:22 -07:00
Slava Pestov
98abbdb332 Emit reflection metadata, but not reflection names, by default
This allows the reflection type lowering test to pass with the
default build configuration.
2016-04-21 15:15:30 -07:00
Roman Levenstein
c8f6a06c02 Add the frontend option -disable-sil-perf-optzns.
Useful when you want to enable -O LLVM opts but not -O SIL opts.
2016-04-05 11:09:24 -07:00
Arnold Schwaighofer
7a129649bc Add a hidden flag to disable the swift bridge attribute
This will be used for writing performance tests
2016-03-29 14:12:45 -07:00
Chris Willmore
3bcb169f0b Import lightweight Objective-C generics as Swift generic type
parameters.
2016-03-28 09:50:30 -07:00
Michael Ilseman
bb43d88792 [Import as member] Bring up to date with fixes from master 2016-03-23 17:02:03 -07:00
Michael Ilseman
47e73ad4f1 Merge branch 'master' of github.com:apple/swift into import-as-member 2016-03-23 17:01:47 -07:00
Doug Gregor
593932741c Remove historical flags -enable-omit-needless-words/-enable-infer-default-arguments/-enable-swift-name-lookup-tables.
NFC; all of these options are always-on now and we no longer have a
way to turn them off.
2016-03-22 17:04:19 -07:00
Doug Gregor
0bdbce653c [Clang importer] Propagate NS prefix stripping flag correctly. 2016-03-22 14:08:13 -07:00
Chris Willmore
4cc75187c6 [Sema] Flag -disable-infer-iuos: don't infer IUO type for untyped bindings
If this option is enabled, when generating potential bindings for a type
variable, don't propagate IUO type. Instead try the optional type and
the underlying type. This way, untyped bindings will not be given IUO
type when they are initialized with exprs of IUO type.
2016-03-21 17:33:29 -07:00
Erik Eckstein
6d654aa3e8 Debugging on SIL level.
This change follows up on an idea from Michael (thanks!).
It enables debugging and profiling on SIL level, which is useful for compiler debugging.

There is a new frontend option -gsil which lets the compiler write a SIL file and generated debug info for it.
For details see docs/DebuggingTheCompiler.rst and the comments in SILDebugInfoGenerator.cpp.
2016-03-18 14:02:06 -07:00
Michael Ilseman
1b83dee698 [Clang importer] Inferr import as member flags
Plumbing for -enable-infer-import-as-member options and flags.Tests
coming soon.
2016-03-06 23:54:56 -08:00
AnnaZaks
767d9ca914 Merge pull request #1434 from apple/asan
[asan] Add basic support for Address Sanitizer function instrumentation
2016-02-29 18:58:40 -08:00
Michael Gottesman
aebc5baf84 Add a new frontend option for debugging called '-disable-incremental-llvm-codegen'.
Currently IRGen stores hashes of the bitcode generated by swift in object files.
This is then used to reduce compile time by not re-codegening if a subsequent
compilation yields a bit code with the same hash.

This is good for users and general compilation, but can result in confusion when
attempting to measure the "real" compile time of the compiler.

By default it is off.
2016-02-28 18:50:19 -08:00
zaks
2110235fd3 [asan] Cleanup based on Jordan's review comments 2016-02-26 16:02:40 -08:00
zaks
d727c68fde [asan] Add "unsupported option .. for target" error message
ASan support for Linux does not exist at this point.
2016-02-25 15:20:51 -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
Xi Ge
dd74e1c0ef [Serialization] Add a new front-end argument to specify the path of the group info file. NFC 2016-02-22 20:28:39 -08:00
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09:00
Joe Groff
d4fdc1e7a8 Conditionally enable behaviors by a frontend flag.
Since the feature is incomplete and yet to be accepted or implemented as proposed, hide it behind an -enable-experimental-property-behaviors frontend flag.
2016-02-20 15:01:06 -08:00
William Dillon
d0d9b1de5a Discard swift.ld and support gold linker 2016-02-17 17:47:35 -08:00
Mark Lacey
bd30572f80 Minor clean-up of -assert-config option handling.
* Replace 'Fast' with 'Unchecked' everywhere.
* Update the help text to specify DisableReplacement rather than
  Replacement and to document Unchecked.
* Simplify tests slightly and add a tests for Unchecked.
2016-02-12 15:10:45 -08:00
Jordan Rose
6272941c5c Rename "build configurations" to "conditional compilation blocks".
...because "build configuration" is already the name of an Xcode feature.

- '#if' et al are "conditional compilation directives".
- The condition is a "conditional compilation expression", or just
  "condition" if it's obvious.
- The predicates are "platform conditions" (including 'swift(>=...)')
- The options set with -D are "custom conditional compilation flags".
  (Thanks, Kevin!)

I left "IfConfigDecl" as is, as well as SourceKit's various "BuildConfig"
settings because some of them are part of the SourceKit request format.
We can change these in follow-up commits, or not.

rdar://problem/19812930
2016-02-12 11:09:26 -08:00
Erik Eckstein
9e28192ea3 Option -print-llvm-inline-tree for printing the inline-tree of the LLVM module.
This is useful to get information about what inlined functions contribute to the code size.
2016-02-10 12:14:23 -08:00
Doug Gregor
293d130272 [Omit needless words] Add a flag -enable-strip-ns-prefix to control NS stripping
Stripping "NS" is a massively invasive change; separate it out into
another flag.
2016-02-08 22:41:16 -08:00
David Farler
a6a5ece206 IRGen: Emit type references for remote reflection
- Implement emission of type references for nominal type field
  reflection, using a small custom encoder resulting in packed
  structs, not strings. This will let us embed 7-bit encoded
  32-bit relative offsets directly in the structure (not yet
  hooked in).
- Use the AST Mangler for encoding type references
  Archetypes and internal references were complicating this before, so we
  can take the opportunity to reuse this machinery and avoid unique code
  and new ABI.

Next up: Tests for reading the reflection sections and converting the
demangle tree into a tree of type references.

Todo: For concrete types, serialize the types for associated types of
their conformances to bootstrap the typeref substitution process.

rdar://problem/15617914
2016-02-03 13:52:26 -08:00
David Farler
bb2391adbd Add -strip-field-names and -strip-field-metadata IRGen options
This controls emission of field metadata for reflection, providing
the default decision. We might want to explore finer-grained
control per type, likely as a source code annotation.

  -strip-field-names
    Strip field names from nominal type metadata.

  -strip-field-metadata
    Strip all field metadata for nominal types. This also implies
    -strip-field-names.

NFC yet.
2016-01-26 09:33:54 -08:00
Doug Gregor
5e11e3f728 Also map -enable-omit-needless-words to a language option.
Although omit-needless-words is almost entirely a Clang importer task,
there are a handful of other places in the compiler that will need to
query this flag as well. NFC for now; those changes will come soon.
2016-01-17 23:40:14 -08:00
Slava Pestov
81267ce1db AST: Serialize -enable-resilience flag on the ModuleDecl
Since resilience is a property of the module being compiled,
not decls being accessed, we need to record which types are
resilient as part of the module.

Previously we would only ever look at the @_fixed_layout
attribute on a type. If the flag was not specified, Sema
would slap this attribute on every type that gets validated.

This is wasteful for non-resilient builds, because there
all types get the attribute. It was also apparently wrong,
and I don't fully understand when Sema decides to validate
which decls.

It is much cleaner conceptually to just serialize this flag
with the module, and check for its presence if the
attribute was not found on a type.
2016-01-16 02:23:27 -08:00
Michael Ilseman
34260e3a56 Merge remote-tracking branch 'origin/master' into warning_control 2016-01-15 14:22:47 -08:00
Michael Ilseman
dc689e607c [Diagnostics] -suppress-warnings and -warnings-as-errors flags
Exposes the global warning suppression and treatment as errors
functionality to the Swift driver. Introduces the flags
"-suppress-warnings" and "-warnings-as-errors". Test case include.
2016-01-15 14:20:44 -08:00
David Farler
bd8d85da0a Turn on dynamic super method dispatch by default
This removes the -use-native-super-method flag and turns on dynamic
dispatch for native method invocations on super by default.

rdar://problem/22749732
2016-01-15 13:37:53 -08:00
Doug Gregor
657319903e Add a "-swift3-migration" frontend option and corresponding language option.
This is intended to enable various Fix-Its to perform the one-way
migration from Swift 2.x to Swift 3, with a focus on the issues
involving naming.
2016-01-14 00:21:47 -08:00
Doug Gregor
12d6f02c45 Remove the "-disable-self-type-mangling" flag and corresponding language option
NFC
2016-01-14 00:21:47 -08:00