Commit Graph

1131 Commits

Author SHA1 Message Date
John McCall
bfffae279c Merge pull request #41399 from rjmccall/suppressible-compatibility-checks
Fix and generalize the printing of suppressible features
2022-02-17 03:26:44 -05:00
Alexis Laferrière
a2d5bae8ac Merge pull request #41372 from apple/disable-win-cache-diag
[ModuleCache] Disable flaky module-cache-diagnostics test on Windows
2022-02-16 14:20:28 -08:00
John McCall
54c38cbb71 Fix and generalize the printing of suppressible features,
and make `@_unsafeInheritExecutor` a suppressible feature.

Some language features are required in order to parse a
declaration correctly, but some can safely be ignored.
For the latter, we'd like the module interface to simply
contain the declaration twice, once with the feature and
once without.  Some basic support for that was already
added for the SpecializeAttributeWithAvailability feature,
but it didn't interact correctly with required features
that might be checked in the same `#if` clause (it simply
introduced an `#else`), and it wasn't really set up to
allow multiple features to be handled this way.  There
were also a few other places that weren't updated to
handle this, presumably because they never coincided
with a `@_specialize` attribute.

Introduce the concept of a suppressible feature, which
is anything that the ASTPrinter can modify the current
PrintOptions in order to suppress.  Restructure the
printing of compatibility checks so that we can print
the body multiple times with different settings.
Print required feature checks in an outer `#if...#endif`,
then perform a separate `#if...#else...#endif` within
if we have suppressible features.  If there are multiple
suppressible features, check for the most recent first,
on the assumption that it will imply the rest; then
perform subsequent checks with an `#elsif` clause.

This should be a far more solid foundation on which to
build compatibility checks in the future.

`@_unsafeInheritExecutor` needs to be suppressible
because it's been added to some rather important
existing APIs.  Simply suppressing the entire decl will
effectively block old tools from using a new SDK to
build many existing projects (if they've adopted
`async`).  Dropping the attribute changes the semantics
of these functions, but only if the compiler features
the SE-0338 scheduling change; this is a very narrow
window of main-branch development builds of the tools,
none of which were officially released.
2022-02-16 16:58:56 -05:00
Allan Shortlidge
70e7e84977 Merge pull request #41348 from tshortli/emit-backdeploy-function-bodies
Emit function bodies for functions annotated with @_backDeploy
2022-02-14 16:19:33 -08:00
Alexis Laferrière
b9eb90b443 [ModuleCache] Disable flaky module-cache-diagnostics test on Windows 2022-02-14 10:28:06 -08:00
Doug Gregor
1b21f13654 Add missing test file 2022-02-11 19:18:47 -08:00
Doug Gregor
0d39a8dd29 Limit inference of Sendable for public, frozen types relying on preconcurrency
When inferring Sendable for a public, frozen type, that Sendable conformance
becomes part of the contract. Therefore, don't infer this conformance
when any of instance storage is implicitly non-Sendable.

Fixes rdar://88652324.
2022-02-11 16:40:01 -08:00
Allan Shortlidge
25b59cb8bc AST: Emit @_backDeploy function bodies into .swiftinterface files.
Resolves rdar://88650341
2022-02-11 14:47:32 -08:00
Allan Shortlidge
ab457959b1 Fix the back-deploy-attr.swift test case by using target-swiftc_driver instead of swiftc_driver. 2022-02-09 09:18:23 -08:00
Allan Shortlidge
2de28dfa75 AST: Use -verify-emitted-module-interface in test case the emits a swiftinterface containing a back-deployed decl. Also leave a FIXME to stop using -merge-modules in the future and fix a diagnostic typo. 2022-02-08 14:04:49 -08:00
Allan Shortlidge
b860e762b2 AST: Introduce the @_backDeploy function attribute:
- Parse the attribute and diagnose parsing issues
- Serialize the attribute
2022-02-08 10:11:04 -08:00
Robert Widmann
25ab410896 Implement (Sugared) Bound Generic Extensions
A scoped-down version of #39307. Implement extension of bound generic types. The important bit here is in TypeCheckGeneric where we now use the underlying type of a typealias and its associated nominal type decl when we're generating substitutions for the extended type.

Put this behind a new experimental flag

-enable-experimental-bound-generic-extensions

Resolves SR-4875
Resolves rdar://17434633
2022-02-02 17:05:23 -08:00
Allan Shortlidge
12102c4181 [Sema] Warn if the @_originallyDefinedIn attribute is applied to a decl that is inaccessible outside the current module.
Resolves rdar://82441657
2022-02-01 16:51:03 -08:00
Allan Shortlidge
49e351f404 Ensure that a module can be compiled successfully from the swiftinterface produced for enums-layout-helper.swift. 2022-01-26 13:57:57 -08:00
Allan Shortlidge
646a3a545f [Sema] Avoid computing raw values for enum cases in swiftinterface files
Raw values of enum cases from another module are not specified in the declaration of the enum unless that enum is `@objc`. This meant that `EnumRawValuesRequest` was computing potentially incorrect raw values when the enum declaration supported it and was emitting incorrect diagnostics for other enum decls.

Resolves SR-14355 and rdar://75451691
2022-01-26 13:43:00 -08:00
Erik Eckstein
beb2bd2a96 AST: support @_effects attribute with custom strings.
In addition to the predefined cases,  like "readnone", "readonly", etc. support providing a custom string, which will be parsed later.
Also, allow multiple effects attributes to be put onto a function.
2022-01-25 11:29:23 +01:00
Xi Ge
53d46841d4 ModuleInterface: pass-down paths obfuscator to module interface building commands
While implicitly building .swiftinterface, the interface may import other binary modules.
These binary modules may contain serialized search paths that have been obfuscated. To help
interface building commands recover these search paths, we need to pass down the obfuscators
to the module building commands.

rdar://87840268
2022-01-20 14:48:55 -08:00
Slava Pestov
fa570fe072 ASTMangler: Respect @_originallyDefinedIn in mangleOpaqueTypeDecl()
mangleOpaqueTypeDecl() used to enable DWARFMangling, which
ignores @_originallyDefinedIn, which would in turn break module
interfaces.

Fixes rdar://problem/86480663.
2022-01-06 23:44:14 -05:00
Saleem Abdulrasool
849d5f0aaf Serialization: normalize the path before use
This normalizes the path so that we always have the mapping in normal
form.  This fixes a bug in the cross-module import tracing, allowing us
to finally enable the test on Windows.
2021-12-22 08:41:17 -08:00
Xi Ge
ad3588eb82 sema: avoid emitting several _const diagnostics for .swiftinterface files 2021-11-23 19:48:29 -08:00
Xi Ge
06e63896cd ModuleInterface: consume _const keyword at var and parameter decls and keep them in textual/binary modules
This is to ensure users can start adding these annotations. Type checker supports will come in later commits.

Related to pitch: https://forums.swift.org/t/pitch-compile-time-constant-values/53606

rdar://85268028
2021-11-19 22:13:23 -08:00
Xi Ge
17cba71a18 Merge pull request #40196 from nkcsgexi/85426499 2021-11-16 07:43:07 -08:00
Xi Ge
2f2ee1bf1e ModuleInterface: print @_originallyDefinedIn attributes for synthesized extensions for synthesized conformances
rdar://85426499
2021-11-15 22:25:27 -08:00
Doug Gregor
035d492a3a Fix printing of 'isolated' parameters.
Fixes rdar://83316058.
2021-11-12 21:45:44 -08:00
Xi Ge
9acf26b0d0 Merge pull request #40113 from nkcsgexi/flag-downgrade-module-verification-error 2021-11-09 20:55:25 -08:00
Xi Ge
f77ca2e2ae Frontend: add a flag to downgrade all module interface verification errors to warnings
Ideally, module interface verification should fail the build when fatal error occurs when
type checking emitted module interfaces. However, we found it's hard to stage this phase in
because the ideal case requires all Swift adopters to have valid interfaces. This new front-end flag allows
driver to downgrade all interface verification errors to warnings as an intermediate step.
2021-11-09 15:58:42 -08:00
Arnold Schwaighofer
2b41beeb12 Merge pull request #39966 from aschwaighofer/feature_specialize_with_availability
Define a feature for _specialize with availability
2021-11-08 12:13:33 -08:00
Karoy Lorentey
e2cfab4f28 [stdlib][test] Adopt availability macros in tests 2021-10-31 15:00:58 -07:00
Karoy Lorentey
8e154a415a Merge pull request #39962 from lorentey/concurrency-availability
[stdlib] Introduce availability macros
2021-10-31 14:23:57 -07:00
Arnold Schwaighofer
0965a63eb8 Test case 2021-10-30 06:16:30 -07:00
Erik Eckstein
c578c937c8 SILOptimizer: run the GlobalOpt pass in the mandatory pipeline.
Replace the dynamic initialization of trivial globals with statically initialized globals, even in -Onone.
This is required to be able to use global variables in performance-annotated functions.
Also, it's a small performance improvement for -Onone.
2021-10-29 22:35:57 +02:00
Karoy Lorentey
47956908b7 [Concurrency] SwiftStdlib 5.5 ⟹ SwiftStdlib 5.1 (usages)
The concurrency runtime now deploys back to macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, which corresponds to the 5.1 release of the stdlib.

Adjust macro usages accordingly.
2021-10-28 14:36:36 -07:00
Xi Ge
495bd36238 ABIChecker: teach wmo mode to emit ABI descriptor files 2021-10-28 08:16:19 -07:00
Becca Royal-Gordon
195896a175 Print @_nonSendable extension in module interfaces
…instead of printing the attribute itself. This allows uses of @_nonSendable to back-deploy.
2021-10-14 12:14:46 -07:00
Arnold Schwaighofer
8840ea6b5b Add support for parsing an availability argument in @_specialize 2021-10-05 14:46:17 -07:00
Meghana Gupta
f458d9b490 Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)
* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag

This includes a bit in the module format to represent if the module was
compiled with -enable-ossa-modules flag. When compiling a client module
with -enable-ossa-modules flag, all dependent modules are checked for this bit,
if not on, recompilation is triggered with -enable-ossa-modules.

* Updated tests
2021-10-04 18:46:40 -07:00
Hamish Knight
36511474a4 [AST] Preserve source location in packIntoImplicitTupleOrParen
When type-checking a tuple construction such as
`Void()`, make sure to preserve the source info
from the argument list in the resulting
type-checked TupleExpr `()`. This is needed for
serialization to be able to grab the textual
representation.

SR-15181
rdar://83202870
2021-09-30 13:03:41 +01:00
Slava Pestov
3f8ef30185 RequirementMachine: Preserve sugared generic params in getSuperclassBound() and getConcreteType()
This was manifesting as module interfaces printing generic parameters
as `τ_0_0` in some cases.

Note that the GSB has the same bug, so this test case will fail with
-requirement-machine=off. I don't plan on fixing the bug in the GSB
unless we need to.

Fixes rdar://problem/78977127.
2021-09-29 14:39:38 -04:00
Xi Ge
f97653ef37 Frontend: teach -emit-module and -merge-modules to emit ABI descriptor files 2021-09-21 16:51:52 -07:00
Becca Royal-Gordon
e16cf3085f Override -triple on fallback to arm64e interface
When we fall back to loading an arm64e module interface during an arm64 build, we want to compile it for the arm64 target so that it is fully compatible with the module that will load it, even though the flags in the file specify the arm64e target. Rewrite the sub-invocation's TargetTriple property in this specific situation. If the two targets differ by more than just the sub-architecture, we will continue to respect the -target flag in the file.

Fixes <rdar://83056545>.
2021-09-15 12:36:17 -07:00
Evan Wilde
ddf210b449 Disabling arm64e testing in two tests
I wasn't aware that arm64e was a thing in open-source, but these two
tests are failing on Apple Silicon both on the main branch and on the
rebranch branch, so I'm disabling it for now.

The failing tests are:
 - ModuleInterface/arm64e-fallback.swift
 - stdlib/Reflection_objc.swift
2021-09-13 13:30:50 -07:00
Becca Royal-Gordon
e13fafc001 Merge pull request #39083 from beccadax/give-me-some-e
Add arm64 -> arm64e fallback to module loading
2021-09-10 13:12:52 -07:00
Becca Royal-Gordon
2240a39446 Add arm64 -> arm64e fallback
If we are building for ARM64 but we try to import a module with only an ARM64e interface, fall back to importing said interface.

This is the reverse of a similar fallback briefly introduced last year, but removed in #31196.
2021-09-07 12:00:02 -07:00
Xi Ge
a8b95cb9cd ABIChecker: don't fail when hitting EnumCaseDecl
All enum elments should have been handled separately so we don't need to anything special
for EnumCaseDecl except consuming them.
2021-09-03 16:45:24 -07:00
Becca Royal-Gordon
9358d7644a [NFC] Start separating DummyFramework
DummyFramework.framework has two different properties to support two different kinds of test cases: to support ModuleInterface/build-alternative-interface-framework.swift, its macOS interfaces are broken, but to support ModuleInterface/arm64e-fallback.swift, it supports only arm64, not arm64e, on iOS. The arm64e test's behavior is about to change, which will complicate all of this. As a preliminary step, make the two tests use two different frameworks so they aren't so intertwined.

This temporarily keeps the arm64e test using the name "DummyFramework", but that will change.
2021-08-27 14:50:56 -07:00
Doug Gregor
ebd7b49755 Build compiler, other libraries, and tests for back-deployed concurrency.
When build-script is given `--back-deploy-concurrency`, also use that
to build other parts of Swift with the back-deployed versions:

* The compiler allows async and actors to be defined with the
back-deployed availability, e.g., the same as `-Xfrontend
-enable-experimental-back-deploy-concurrency`. (The latter will go
away soon)
* The standard library unit testing framework and distributed actors
library are build with the older OS versions.
* The tests use the older OS versions, with some adjustments to make
them agnostic to the back-deployment setting.
2021-08-26 08:49:44 -07:00
Xi Ge
1a660c08ca Frontend: teach -compile-module-from-interface action to emit ABI descriptor as byproduct
We have implemented a libSwiftDriver-based tool to generate prebuilt module cache for
entire SDKs. Anchored on the same infrastructure, we could also generate ABI baselines
for entire SDKs.
2021-08-20 15:47:10 -07:00
Slava Pestov
1f652bc7d8 Sema: Don't derive witnesses in swiftinterface files
This fixes a regression from https://github.com/apple/swift/pull/36752.

Previously, a RawRepresentable enum would use the default implementation
of == from a protocol extension in the standard library. After the above
PR, we began synthesizing the == operator, just like we do for ordinary
enums.

However, when type checking an older swiftinterface file, we would
still synthesize the declaration and try to use it, even though it would
not have existed in the older dylib built with the older compiler.

Fix this by not deriving witnesses in swiftinterface files at all.
The interface should already explicitly list out all derived witnesses;
if one is not listed, it should not be derived, because it does not
exist in the dylib.

Fixes rdar://problem/80466745.
2021-08-18 16:22:26 -04:00
Xi Ge
c2e4e86670 ModuleInterface: avoid omitting platform names when printing @available
rdar://81903124
2021-08-13 11:14:11 -07:00
Luciano Almeida
1fc7f07d9b [tests] Make sure to build module interface test dummy library for arm64e 2021-07-28 20:14:07 -03:00