Commit Graph

1823 Commits

Author SHA1 Message Date
Alastair Houghton
4c7822cdac Merge pull request #71213 from al45tair/eng/PR-121522431
[Frontend][AST][IRGen] Improve availability support.
2024-02-02 22:30:19 +00:00
Alastair Houghton
c226bf3c3c [AST][IRGen] Add -min-runtime-version option and IRGen support code.
Add a `-min-runtime-version` option that can be used to avoid problems
when building on Linux and Windows where because the runtime isn't
part of the OS, availability doesn't solve the problem of trying to
build the compiler against an older runtime.

Also add functions to IRGen to make it easy to test feature
availability using both the runtime version and the existing Darwin
availability support.

rdar://121522431
2024-02-02 16:17:08 +00:00
Slava Pestov
39411d31e9 Sema: Fix -debug-inverse-requirements flag 2024-02-01 17:17:43 -05:00
Meghana Gupta
968f69cf66 Add -enable-experimental-lifetime-dependence-inference option
Until stdlib can be built with noncopyable generics, stdlib types
can appear as ~Escapable and ~Copyable, leading to invalid inference.

Use a flag to test implicit lifetime dependence
2024-01-31 00:01:32 -08:00
Arnold Schwaighofer
701549fe6e Merge pull request #71215 from aschwaighofer/large_loadable_reg2mem
Large loadable types peepholes and address assignment
2024-01-30 10:41:20 -08:00
Slava Pestov
f79aa8d556 Turn on -enable-experimental-associated-type-inference by default 2024-01-29 23:38:45 -05:00
Arnold Schwaighofer
5e2144bdb8 Large loadable types peepholes and address assignment
Contract some load store patterns and assign addresses to (non-address)
SIL SSA values.

rdar://115571407
2024-01-29 17:10:46 -08:00
Kavon Farvardin
483b569bc8 [NCGenerics] trigger module mismatch
A swiftmodule can only be correctly ingested by a compiler
that has a matching state of using or not-using
NoncopyableGenerics.

The reason for this is fundamental: the absence of a Copyable
conformance in the swiftmodule indicates that a type is
noncopyable. Thus, if a compiler with NoncopyableGenerics
reads a swiftmodule that was not compiled with that feature,
it will think every type in that module is noncopyable.

Similarly, if a compiler with NoncopyableGenerics produces a
swiftmodule, there will be Copyable requirements on each
generic parameter that the compiler without the feature will
become confused about.

The solution here is to trigger a module mismatch, so that
the compiler re-generates the swiftmodule file using the
swiftinterface, which has been kept compatible with the compiler
regardless of whether the feature is enabled.
2024-01-23 22:42:37 -08:00
Kavon Farvardin
287297c16e [NCGenerics] SwiftSources == CompilerInvocation
Match up the additional flags in SwiftSources.cmake and
CompilerInvocation.cpp with respect to NoncopyableGenerics.

I think only CompilerInvocation is truly needed, though.
2024-01-23 22:41:59 -08:00
Kavon Farvardin
fc9575cda9 [NCGenerics] enable new associated type inference
The experimental-associated-type-inference flag is needed to correctly
build programs when NoncopyableGenerics is enabled.
2024-01-23 22:41:59 -08:00
Kavon Farvardin
b92fe5f2e9 [build-script] fix NoncopyableGenerics option
This patch introduces `--enable-experimental-noncopyable-generics` for
the build script. It replaces
`--swift-stdlib-experimental-noncopyable-generics`

The old build option only enables the feature when building the
stdlib, but if we've built the stdlib with NoncopyableGenerics, the
compiler should be hardwired to have that feature enabled, too.

This patch also introduces the `noncopyable_generics` lit parameter, so
that tests assuming the system was built with the feature can live
in-tree and be tested, if they specify `REQUIRES: noncopyable_generics`.
2024-01-23 22:41:59 -08:00
nate-chandler
0b52679a07 Merge pull request #70895 from nate-chandler/opaque-values/20240112/1
[OpaqueValues] Add frontend flag to disable.
2024-01-12 22:47:48 -08:00
Allan Shortlidge
a3286c59e9 Merge pull request #70784 from tshortli/swift3-no-more
Remove `-enable-swift3-objc-inference`
2024-01-12 17:05:53 -08:00
Nate Chandler
7d8f8b526e [OpaqueValues] Add frontend flag to disable.
To facilitate bringup and in preparation for enabling by default.
2024-01-12 13:27:26 -08:00
Holly Borla
d37b9763b6 [Concurrency] Promote StrictConcurrency to an upcoming feature flag. 2024-01-11 21:23:25 -08:00
Allan Shortlidge
e5c6bb649c Remove support for Swift 3 @objc inference.
Obsolete the `-enable-swift3-objc-inference` option and related options by
removing support for inferring `@objc` attributes using Swift 3 rules.
Automated migration from Swift 3 has not been supported by the compiler for
many years.
2024-01-11 15:40:04 -08:00
Holly Borla
e47a66cc33 [Concurrency] Enable IsolatedDefaultValues under strict concurrency checking. 2024-01-10 20:53:42 -08:00
Holly Borla
0e71623386 [SE-0411] Promote IsolatedDefaultValues from an experimental feature to an
upcoming feature.
2024-01-10 14:54:24 -08:00
Allan Shortlidge
2fbef52d16 Frontend: Hide and deprecate options for Swift 3 @objc inference.
The compiler has not supported migrating Swift 3 code to Swift 4 for a long
time. The `-enable-swift3-objc-inference` option and related options were
originally designed to aid that transition and should be deprecated at this
point.

Resolves rdar://120490061
2024-01-08 12:28:11 -08:00
Sophia Poirier
073f541734 [Concurrency] promote GlobalConcurrency from experimental to future feature 2024-01-06 19:07:23 -08:00
Zoe Carver
f7f5070454 Merge pull request #70734 from zoecarver/cross-module-everything 2024-01-06 10:28:11 -05:00
Ben Barham
d51c58a6f9 [Basic] hasFeature should succeed for promoted language features
Merge `$<Feature>` and `hasFeature` implementations.
  - `$<Feature>` did not support upcoming language features.
  - `hasFeature` did not support promoted language features and also
    didn't take into account `Options` in `Features.def`.

Remove `Options` entirely, it was always one of three cases:
  - `true`
  - `langOpts.hasFeature`
  - `hasSwiftSwiftParser`

Since `LangOptions::hasFeature` should always be used anyway, it's no
longer necessary. `hasSwiftSwiftParser` can be special cased when adding
the default promoted language features (by removing those features).

Resolves rdar://117917456.
2024-01-05 10:26:13 -08:00
zoecarver
64fa0a35db [opt] Add new -enable-cmo-everything flag to enable serializing all sil, match serialization behavior of Embedded Swift. 2024-01-05 13:06:20 -05:00
Allan Shortlidge
41c414381b Frontend: Remove conformance availability error flags.
Now that the diagnostics are automatically errors in Swift 6, we don't need an
`-enable-conformance-availability-errors` flag to control whether unavailable
conformances are diagnosed as errors. Nobody was using the flag so it should be
safe to remove.

Part of rdar://88210812
2024-01-04 17:53:34 -08:00
Ben Barham
a6c8bf3818 [Frontend] Diagnose rather than exit/assert on experimental features
Diagnose rather than exit when using experimental features that cannot
be enabled in production. Also diagnose if using a compiler without
`SwiftCompilerSources` when enabling embedded.

This is especially important for long-running services like sourcekitd,
which shouldn't exit just because an invalid argument was passed.

Resolves rdar://119724074.
2024-01-02 12:49:08 -08:00
Steven Wu
ead742b8f1 [CAS] Do not create redirect file system when using clang-include-tree
Redirecting file system can canonicalize the file path before forwarding
the path to IncludeTreeFileSystem, which is a simplied FS that can only
intepret the paths that has been seen by dep-scanner. Since all files
that need redirecting already added to underlying FS via DepScan, there
is no need for such layer when compiling using clang-include-tree.

rdar://119727344
2023-12-20 12:30:14 -08:00
Steven Wu
ea58ef8fa5 [ClangImporter] Simply clang-importer creation flags
Currently,  `-direct-clang-cc1-module-build` and `-only-use-extra-clang-opts`
have to be passed together for clang importer creation to succeed.
Missing either will result in error. Simplified the swift-frontend flags
by removing `-only-use-extra-clang-opts` and let
`-direct-clang-cc1-module-build` to do both.
2023-12-19 12:16:20 -08:00
usama
3053fe01b5 [Sanitizers] Add new sanitize-stable-abi flag for libsanitizers.
This patch adds a new flag sanitize-stable-abi to support linking
against the Sanitizers stable ABI added recently in compiler-rt. The
patch also passes extra options for the ASan pass when using this flag
to outline instrumentation code and remove version check.

rdar://112915278
2023-12-16 14:13:00 -08:00
Kuba Mracek
ff1f8adac8 [embedded] Implement non-allocating embedded Swift mode, under -no-allocations flag 2023-12-11 09:00:50 -08:00
Slava Pestov
026d3f0078 Merge pull request #70311 from slavapestov/type-witness-system-inference-stdlib
Get the standard library to build with -enable-experimental-associated-type-inference
2023-12-10 17:50:33 -05:00
Adrian Prantl
3b38e15427 Merge pull request #70274 from adrian-prantl/117824367
Revert "Don't require a strict revision match in LLDB."
2023-12-08 13:23:44 -08:00
Slava Pestov
335d6ffea1 Frontend: Add -disable-experimental-associated-type-inference flag 2023-12-08 13:39:10 -05:00
Meghana Gupta
f6afc00541 Add a new flag to disable round trip through the new Swift parser 2023-12-06 16:38:40 -08:00
Adrian Prantl
5ef93af269 Revert "Don't require a strict revision match in LLDB."
This reverts commit 3cc2831608.

The compiler's revision check has been relaxed since the feature was introduced
and so it's nos better to reduce the number of special code paths for LLDB in
the compiler to facilitate reasoning about it.

rdar://117824367
2023-12-06 11:14:14 -08:00
Holly Borla
2aa8d56997 Merge pull request #70123 from hborla/swift-6-upcoming-features
[Features] Update upcoming feature flags for Swift 6.
2023-11-30 19:00:20 -08:00
Holly Borla
575514e906 [Feataures] Add an upcoming feature flag for complete concurrency checking. 2023-11-29 22:09:37 -08:00
Allan Shortlidge
5e5578aa0b Frontend: Ignore -experimental-lazy-typecheck when verifying module interfaces. 2023-11-29 10:51:24 -08:00
Allan Shortlidge
606bb391ff Frontend: Add -experimental-skip-non-inlinable-function-bodies-is-lazy.
This option causes the -experimental-lazy-typecheck and
-experimental-skip-non-exportable-decls options to be inferred from the
presense of -experimental-skip-non-inlinable-function-bodies. This new option
is meant to be a temporary testing aid that allows lazy typechecking to be
tested on projects without full build system support for passing the other
flags to the right jobs.

Resolves rdar://118938251
2023-11-29 10:51:24 -08:00
Anders Bertelrud
a363603c14 [Playgrounds] Add a new -playground-option flag to control which transforms to apply (#69355)
Generalize the existing `-playground-high-performance` flag into a set of options that control various aspects of the "playground transformation" in Sema.

This commit adds the first two of those controllable parts of the transform, matching what the existing flag already controls (scope entry/exit and function arguments), but in an extensible way. The intent is for this to be a scalable way to control a larger set of upcoming options.

So instead of a single flag, we represent the playground transform options as a set of well-defined choices, with a new `-playground-option` flag to individually enable or disable those options (when prefixed with "No", the corresponding option is instead disabled). Enabling an already-enabled option or disabling an already-disabled option is a no-op.

For compatibility, the existing `-playground-high-performance` flag causes "expensive" transforms to be disabled, as before. We can also leave it as a useful shorthand to include or exclude new options even in the future, based on their cost. There is a comment on the old function indicating that new code should use the more general form, but it remains for clients like LLDB until they can switch over.

The machinery for implementing the playground options is similar to how `Features.def` works, with a new `PlaygroundOptions.def` that defines the supported playground transform options.  Each playground definition specifies the name and description, as well as whether the option is enabled by default, and whether it's also enabled in the "high performance" case.

Adding a new option in the future only requires adding it to `PlaygroundOptions.def`, deciding whether it should be on or off by default, deciding whether it should also be on or off in `-playground-high-performance` mode, and checking for its presence from the appropriate places in `PlaygroundTransform.cpp`.

Note that this is intended to control the types of user-visible results that the invoker of the compiler wants, from an externally detectable standpoint. Other flags, such as whether or not to use the extended form of the callbacks, remain as experimental features, since those deal with the mechanics and not the desired observed behavior.

rdar://109911673
2023-11-15 13:02:34 -08:00
Ellie Shin
e8d43434db Merge pull request #69733 from apple/es-pkg-intf
Introduce a package interface
2023-11-15 03:53:49 -08:00
Ellie Shin
82eef756ee Guard with env var SWIFT_ENABLE_PACKAGE_INTERFACE_LOAD
Update tests and formatting
2023-11-15 01:16:23 -08:00
Ellie Shin
9d716394b1 Add an interface mode getter/setter in PrintOptions and ModuleInterfaceOptions
Update args parsing
2023-11-13 13:48:07 -08:00
Steven Wu
109566fb81 [Caching] Switch clang-include-tree to be default for clang modules
Switch to use clang-include-tree by default for clang module
building/caching when using a CAS. This is the default mode for clang
module and has less issues than CAS file system based implementation.
2023-11-10 11:43:32 -08:00
Ellie Shin
e5ca8e5c0b Allow loading package interface if in same package.
Add a new flag to enable package interface loading.
Use the last value of package-name in case of dupes.
Rename PrintInterfaceContentMode as InterfaceMode.
Update diagnostics.
Test package interface loading with various scenarios.
Test duplicate package-name.
2023-11-09 18:44:06 -08:00
Ellie Shin
aba3b6c24e Introduce a package interface.
It has an extension .package.swiftinterface and contains package decls
as well as SPIs and public/inlinable decls. When a module is loaded
from interface, it now looks up the package-name in the interface
and checks if the importer is in the same package. If so, it uses
that package interface found to load the module. If not, uses the existing
logic to load modules.

Resolves rdar://104617854
2023-11-08 14:56:20 -08:00
Kuba Mracek
2936a33680 [embedded] Wrap SwiftCompilerSources initialization state into swiftModulesInitialized API 2023-11-07 10:00:53 -08:00
Kuba Mracek
f0dd174df3 [embedded] Require SwiftCompilerSources to use embedded Swift 2023-11-07 10:00:53 -08:00
Max Ovtsin
b0105e112d Introduce -application-extension-library (#63769)
The current implementation of `-application-extension` has a problem that affects the generation of ObjC headers for regular Swift modules.

The primary purpose of `-application-extension` is to prevent the use of unavailable APIs in app extensions. However, it has an impact on the generation of -Swift.h headers and exposes Swift's internal declarations to ObjC. This behavior is appropriate for mixed modules that are not consumed externally, such as app extensions, but it fails to address the situation when a module is not an extension itself but is consumed by the extension (c90cd11).

To resolve this issue while maintaining the desired behavior, we can introduce a new flag for this particular use-case.
2023-11-03 08:24:19 -07:00
Richard Howell
3d8e4b9102 Merge pull request #68847 from rmaz/filecompdirpassthrough
Pass through file-compilation-dir to the ClangImporter.
2023-10-30 07:12:02 -07:00
Doug Gregor
40e07cf900 [Typed throws] IR generation and runtime support for function type metadata
Extend function type metadata with an entry for the thrown error type,
so that thrown error types are represented at runtime as well. Note
that this required the introduction of "extended" function type
flags into function type metadata, because we would have used the last
bit. Do so, and define one extended flag bit as representing typed
throws.

Add `swift_getExtendedFunctionTypeMetadata` to the runtime to build
function types that have the extended flags and a thrown error type.
Teach IR generation to call this function to form the metadata, when
appropriate.

Introduce all of the runtime mangling/demangling support needed for
thrown error types.
2023-10-29 09:12:32 -07:00