Commit Graph

875 Commits

Author SHA1 Message Date
swift-ci
fa22d03adb Merge remote-tracking branch 'origin/main' into rebranch 2021-07-26 16:53:31 -07:00
Ben Barham
f1c45de2a9 [NFC] Refactor getRenameDecl to use the request evaluator
Move `getRenameDecl` from `PrintAsObjC` into its own request so that
other components can re-use this functionality.
2021-07-24 10:00:02 +10:00
swift-ci
0d099bf3b1 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-08 11:44:01 -07:00
Holly Borla
89b58d582a Merge pull request #38302 from hborla/warn-until-Swift-6
[Diagnostics] Add `InFlightDiagnostic::warnUntilSwiftVersion` to downgrade errors to warnings
2021-07-08 11:23:01 -07:00
Holly Borla
a06c4afcfa [Diagnostics] Add InFlightDiagnostic::warnUntilSwiftVersion to limit the
diagnostic behavior to a warning until the specified language version.

This helper can be used to stage in fixes for stricter diagnostics
as warnings until the next major language version.
2021-07-07 16:52:37 -07:00
swift-ci
8eed427d64 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-07 06:34:04 -07:00
Victoria Mitchell
85fabb23ed include comments on SPI symbols when they're in symbol graphs 2021-06-30 16:13:08 -06:00
Evan Wilde
9bd93db2be Update all the APInt toStrings
Just went through and updated the rest of the APInt toString calls.
This should take care of them, I hope.
2021-06-25 10:44:13 -07:00
Yuta Saito
6362a98aa0 [Frontend] Add -public-autolink-library option (#35936)
Foundation imports CoreFoundation with `@_implementationOnly`,
so CoreFoundation's modulemap won't be read, and the dependent libraries
of CoreFoundation will not be automatically linked when using static
linking.

For example, CoreFoundation depends on libicui18n and it's modulemap has
`link "icui18n"` statement. If Foundation imports CoreFoundation with
`@_implementationOnly` as a private dependency, the toolchain doesn't have
CoreFoundation's modulemap and Foundation's swiftmodule  doesn't import
CoreFoundation. So the swiftc can't know that libicui18n is required.

This new option will add LINK_LIBRARY entry in swiftmodule to
specify dependent libraries (in the example case, Foundation's
swiftmodule should have LINK_LIBRARY entry of libicui18n)


See also: [Autolinking behavior of @_implementationOnly with static linking](https://forums.swift.org/t/autolinking-behavior-of-implementationonly-with-static-linking/44393)
2021-06-15 12:38:19 +01:00
3405691582
b708ed5f45 Fix broken implicit import conditional rename.
In #37686 `SWIFT_IMPLICIT_CONCURRENCY_IMPORT` was introduced alongside
the existing `SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY`, but the
`#cmakedefine` for this preprocessor symbol was renamed to the former
instead of a new `#cmakedefine` being introduced.

This means the `#ifdef` conditional referred in this commit was broken.
Instead of just introducing the old symbol back again, let's rename it
as it probably was intended here.

However, the semantics of this symbol is slightly different: this now
requires prospective builders to explicitly turn this off on platforms
where Dispatch is unavailable. To address this, the docs are updated to
match. Caveat: I have not ran the procedure in the doc recently, but
this hopefully should suffice to guide the reader until I get around to
doing so.
2021-06-09 22:43:13 -04:00
QuietMisdreavus
40b084e5c0 Merge pull request #37640 from apple/QuietMisdreavus/spi-symbols
add symbol-graph flag to include SPI symbols
2021-06-04 11:34:48 -06:00
Konrad `ktoso` Malawski
6008b32789 [Distributed] initial distributed support, fixed availability (#37650)
* [Distributed] Initial distributed checking

* [Distributed] initial types shapes and conform to DistributedActor

* [Distributed] Require Codable params and return types

* [Distributed] initial synthesis of fields and constructors

* [Distributed] Field and initializer synthesis

* [Distributed] Codable requirement on distributed funcs; also handle <T: Codable>

* [Distributed] handle generic type params which are Codable in dist func

[Distributed] conformsToProtocol after all

* [Distributed] Implement remote flag on actors

* Implement remote flag on actors

* add test

* actor initializer that sets remote flag

[Distributed] conformances getting there

* [Distributed] dont require async throws; cleanup compile tests

* [Distributed] do not synthesize default implicit init, only our special ones

* [Distributed] properly synth inits and properties; mark actorTransport as _distributedActorIndependent

Also:

- do not synthesize default init() initializer for dist actor

* [Distributed] init(transport:) designated and typechecking

* [Distributed] dist actor initializers MUST delegate to local-init

* [Distributed] check if any ctors in delegation call init(transport:)

* [Distributed] check init(transport:) delegation through many inits; ban invoking init(resolve:using:) explicitly

* [Distributed] disable IRGen test for now

* [Distributed] Rebase cleanups

* [Concurrent] transport and address are concurrent value

* [Distributed] introduce -enable-experimental-distributed flag

* rebase adjustments again

* rebase again...

* [Distributed] distributed functions are implicitly async+throws outside the actor

* [Distributed] implicitly throwing and async distributed funcs

* remove printlns

* add more checks to implicit function test

* [Distributed] resolve initializer now marks the isRemote actor flag

* [Distributed] distributedActor_destroy invoked instead, rather than before normal

* [Distributed] Generate distributed thunk for actors

* [distributed] typechecking for _remote_ functions existing, add tests for remote funcs

* adding one XFAIL'ed task & actor lifetime test

The `executor_deinit1` test fails 100% of the time
(from what I've seen) so I thought we could track
and see when/if someone happens to fix this bug.

Also, added extra coverage for #36298 via `executor_deinit2`

* Fix a memory issue with actors in the runtime system, by @phausler

* add new test that now passes because of patch by @phausler

See previous commit in this PR.
Test is based on one from rdar://74281361

* fix all tests that require the _remote_ function stubs

* Do not infer @actorIndependent onto `let` decls

* REVERT_ME: remove some tests that hacky workarounds will fail

* another flaky test, help build toolchain

* [Distributed] experimental distributed implies experimental concurrency

* [Distributed] Allow distributed function that are not marked async or throws

* [Distributed] make attrs SIMPLE to get serialization generated

* [Distributed] ActorAddress must be Hashable

* [Distributed] Implement transport.actorReady call in local init

* cleanup after rebase

* [Distributed] add availability attributes to all distributed actor code

* cleanup - this fixed some things

* fixing up

* fixing up

* [Distributed] introduce new Distributed module

* [Distributed] diagnose when missing 'import _Distributed'

* [Distributed] make all tests import the module

* more docs on address

* [Distributed] fixup merge issues

* cleanup: remove unnecessary code for now SIMPLE attribute

* fix: fix getActorIsolationOfContext

* [Distributed] cmake: depend on _concurrency module

* fixing tests...

* Revert "another flaky test, help build toolchain"

This reverts commit 83ae6654dd.

* remove xfail

* clenup some IR and SIL tests

* cleanup

* [Distributed] fix cmake test and ScanDependencies/can_import_with_map.swift

* [Distributed] fix flags/build tests

* cleanup: use isDistributed wherever possible

* [Distributed] don't import Dispatch in tests

* dont link distributed in stdlib unittest

* trying always append distributed module

* cleanups

* [Distributed] move all tests to Distributed/ directory

* [lit] try to fix lit test discovery

* [Distributed] update tests after diagnostics for implicit async changed

* [Distributed] Disable remote func tests on Windows for now

* Review cleanups

* [Distributed] fix typo, fixes Concurrency/actor_isolation_objc.swift

* [Distributed] attributes are DistributedOnly (only)

* cleanup

* [Distributed] cleanup: rely on DistributedOnly for guarding the keyword

* Update include/swift/AST/ActorIsolation.h

Co-authored-by: Doug Gregor <dgregor@apple.com>

* introduce isAnyThunk, minor cleanup

* wip

* [Distributed] move some type checking to TypeCheckDistributed.cpp

* [TypeCheckAttr] remove extra debug info

* [Distributed/AutoDiff] fix SILDeclRef creation which caused AutoDiff issue

* cleanups

* [lit] remove json import from lit test suite, not needed after all

* [Distributed] distributed functions only in DistributedActor protocols

* [Distributed] fix flag overlap & build setting

* [Distributed] Simplify noteIsolatedActorMember to not take bool distributed param

* [Distributed] make __isRemote not public

* [Distributed] Fix availability and remove actor class tests

* [actorIndependent] do not apply actorIndependent implicitly to values where it would be illegal to apply

* [Distributed] disable tests until issue fixed

Co-authored-by: Dario Rexin <drexin@apple.com>
Co-authored-by: Kavon Farvardin <kfarvardin@apple.com>
Co-authored-by: Doug Gregor <dgregor@apple.com>
2021-05-28 07:22:03 +09:00
Konrad `ktoso` Malawski
0c75bd2a39 Revert Initial distributed, some issues to be fixed first (#37556)
* Revert "[Distributed] disable tests until issue fixed"

This reverts commit 0a04278920.

* Revert "[Distributed] Initial `distributed` actors and functions and new module (#37109)"

This reverts commit 814ede0cf3.
2021-05-21 19:28:48 +09:00
Konrad `ktoso` Malawski
814ede0cf3 [Distributed] Initial distributed actors and functions and new module (#37109)
* [Distributed] Initial distributed checking

* [Distributed] initial types shapes and conform to DistributedActor

* [Distributed] Require Codable params and return types

* [Distributed] initial synthesis of fields and constructors

* [Distributed] Field and initializer synthesis

* [Distributed] Codable requirement on distributed funcs; also handle <T: Codable>

* [Distributed] handle generic type params which are Codable in dist func

[Distributed] conformsToProtocol after all

* [Distributed] Implement remote flag on actors

* Implement remote flag on actors

* add test

* actor initializer that sets remote flag

[Distributed] conformances getting there

* [Distributed] dont require async throws; cleanup compile tests

* [Distributed] do not synthesize default implicit init, only our special ones

* [Distributed] properly synth inits and properties; mark actorTransport as _distributedActorIndependent

Also:

- do not synthesize default init() initializer for dist actor

* [Distributed] init(transport:) designated and typechecking

* [Distributed] dist actor initializers MUST delegate to local-init

* [Distributed] check if any ctors in delegation call init(transport:)

* [Distributed] check init(transport:) delegation through many inits; ban invoking init(resolve:using:) explicitly

* [Distributed] disable IRGen test for now

* [Distributed] Rebase cleanups

* [Concurrent] transport and address are concurrent value

* [Distributed] introduce -enable-experimental-distributed flag

* rebase adjustments again

* rebase again...

* [Distributed] distributed functions are implicitly async+throws outside the actor

* [Distributed] implicitly throwing and async distributed funcs

* remove printlns

* add more checks to implicit function test

* [Distributed] resolve initializer now marks the isRemote actor flag

* [Distributed] distributedActor_destroy invoked instead, rather than before normal

* [Distributed] Generate distributed thunk for actors

* [distributed] typechecking for _remote_ functions existing, add tests for remote funcs

* adding one XFAIL'ed task & actor lifetime test

The `executor_deinit1` test fails 100% of the time
(from what I've seen) so I thought we could track
and see when/if someone happens to fix this bug.

Also, added extra coverage for #36298 via `executor_deinit2`

* Fix a memory issue with actors in the runtime system, by @phausler

* add new test that now passes because of patch by @phausler

See previous commit in this PR.
Test is based on one from rdar://74281361

* fix all tests that require the _remote_ function stubs

* Do not infer @actorIndependent onto `let` decls

* REVERT_ME: remove some tests that hacky workarounds will fail

* another flaky test, help build toolchain

* [Distributed] experimental distributed implies experimental concurrency

* [Distributed] Allow distributed function that are not marked async or throws

* [Distributed] make attrs SIMPLE to get serialization generated

* [Distributed] ActorAddress must be Hashable

* [Distributed] Implement transport.actorReady call in local init

* cleanup after rebase

* [Distributed] add availability attributes to all distributed actor code

* cleanup - this fixed some things

* fixing up

* fixing up

* [Distributed] introduce new Distributed module

* [Distributed] diagnose when missing 'import _Distributed'

* [Distributed] make all tests import the module

* more docs on address

* [Distributed] fixup merge issues

* cleanup: remove unnecessary code for now SIMPLE attribute

* fix: fix getActorIsolationOfContext

* [Distributed] cmake: depend on _concurrency module

* fixing tests...

* Revert "another flaky test, help build toolchain"

This reverts commit 83ae6654dd.

* remove xfail

* clenup some IR and SIL tests

* cleanup

* [Distributed] fix cmake test and ScanDependencies/can_import_with_map.swift

* [Distributed] fix flags/build tests

* cleanup: use isDistributed wherever possible

* [Distributed] don't import Dispatch in tests

* dont link distributed in stdlib unittest

* trying always append distributed module

* cleanups

* [Distributed] move all tests to Distributed/ directory

* [lit] try to fix lit test discovery

* [Distributed] update tests after diagnostics for implicit async changed

* [Distributed] Disable remote func tests on Windows for now

* Review cleanups

* [Distributed] fix typo, fixes Concurrency/actor_isolation_objc.swift

* [Distributed] attributes are DistributedOnly (only)

* cleanup

* [Distributed] cleanup: rely on DistributedOnly for guarding the keyword

* Update include/swift/AST/ActorIsolation.h

Co-authored-by: Doug Gregor <dgregor@apple.com>

* introduce isAnyThunk, minor cleanup

* wip

* [Distributed] move some type checking to TypeCheckDistributed.cpp

* [TypeCheckAttr] remove extra debug info

* [Distributed/AutoDiff] fix SILDeclRef creation which caused AutoDiff issue

* cleanups

* [lit] remove json import from lit test suite, not needed after all

* [Distributed] distributed functions only in DistributedActor protocols

* [Distributed] fix flag overlap & build setting

* [Distributed] Simplify noteIsolatedActorMember to not take bool distributed param

* [Distributed] make __isRemote not public

Co-authored-by: Dario Rexin <drexin@apple.com>
Co-authored-by: Kavon Farvardin <kfarvardin@apple.com>
Co-authored-by: Doug Gregor <dgregor@apple.com>
2021-05-21 09:12:29 +09:00
Victoria Mitchell
d281722589 add symbol-graph flag to include SPI symbols
rdar://70794131
2021-05-20 15:10:49 -06:00
Xi Ge
b6cd513534 Frontend: teach the compiler to use a backup directory to find .swiftinterface files to compile
This mechanism allows the compiler to use a backup interface file to build into a binary module when
a corresponding interface file from the SDK is failing for whatever reasons. This mechansim should be entirely opaque
to end users except several diagnostic messages communicating backup interfaces are used.

Part of rdar://77676064
2021-05-13 09:11:45 -07:00
Erik Eckstein
762e9c7882 Serialization: serialize if the module is a static library
If the `-static` option is specified, store that in the generated
swiftmodule file.  When de-serializing, recover this information in the
representative SILModule.

This will be used for code generation on Windows.  It is the missing
piece to allow static linking to function properly.  It additionally
opens the path to additional optimization on ELF-ish targets - GOT, PLT
references can be avoided when the linked module is known to be static.

Co-authored by: Saleem Abdulrasool <compnerd@compnerd.org>
2021-05-02 09:34:52 -07:00
Xi Ge
fe5c7ef995 ModuleInterface/Serialization: allow library authors to define a custom module version number
This allows library authors to pass down a project version number so that library users can conditionally
import that library based on the available version in the search paths.

Needed for rdar://73992299
2021-04-30 10:00:45 -07:00
swift-ci
6ba245dce2 Merge pull request #37027 from 3405691582/ImportConcurrencyEmplicitlyIfEnabled 2021-04-26 03:00:48 -07:00
QuietMisdreavus
7a57818ad7 Merge pull request #37017 from apple/revert-36542-QuietMisdreavus/supplementary-symbol-graph
Revert "[Driver][Frontend] add the symbol graph dir to the supplementary file map"
2021-04-23 11:27:15 -06:00
3405691582
72d9503be0 [concurrency] Import module on OpenBSD if enabled.
Tests are written under the assumption that since they are conditioned
on the concurrency feature, the explicit `_Concurrency` module import is
not necessary since it is imported implicitly if concurrency is enabled.
However, this is not the case; the module import is only included
implictly on selected targets.

It may very well be ideal to import the `_Concurrency` module implicitly
when `SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY` is true and therefore solve
the incorrect assumption, however, that decision is something that is
above my pay grade. Some guidance on this is welcome.

That being said, on OpenBSD, Dispatch is currently unsupported upstream
but there is a draft PR to add this support (559). This means that even
while we have draft Dispatch support, all the Concurrency tests fail
because they do not import `_Concurrency`, but we cannot unconditionally
support concurrency until Dispatch is supported upstream.

Therefore, we especially need to support both cases. So instead, on
OpenBSD, if the concurrency feature is enabled, import the module
implicitly, otherwise, do not. This lets us run the tests and get a good
signal that concurrency features are working with the draft Dispatch
support, while avoiding problems when building with the documented
configuration that disables Dispatch, and therefore, disables
concurrency.
2021-04-22 22:52:47 -04:00
Artem Chikin
f92abb8c81 Verify that _Concurrency *can* be imported on implicit import.
In case the compiler is used with concurrency features enabled (by-default or otherwise), and an older SDK is used which does not include the `_Concurrency` module, do not load this module implicitly. Instead, emit a diagnostic indicating that no such module is found.

rdar://76967260
2021-04-22 13:46:59 -07:00
QuietMisdreavus
419483863f Revert "[Driver][Frontend] add the symbol graph dir to the supplementary file map" 2021-04-22 12:20:14 -06:00
QuietMisdreavus
170dcd88bc Merge pull request #36863 from apple/QuietMisdreavus/docs-inheritance
[SymbolGraph] Add information about "inherited docs" for synthesized symbols
2021-04-19 19:40:38 -06:00
Doug Gregor
c1328bd83f Merge pull request #36857 from DougGregor/import-concurrency-by-default-take-2
Enable import of the _Concurrency module by default.
2021-04-15 13:12:45 -07:00
Becca (née Brent) Royal-Gordon
6e710b2806 Merge pull request #36594 from beccadax/nonstandard-library
Preload standard library in ModuleInterfaceBuilder
2021-04-15 10:43:28 -07:00
Dario Rexin
01298df2f5 Enable import of _Concurrency by default on Linux 2021-04-13 23:14:06 -07:00
Doug Gregor
ca6b6953a0 Only import _Concurrency implicitly on Darwin and Windows for now. 2021-04-13 23:14:06 -07:00
Doug Gregor
568e943115 Enable import of the _Concurrency module by default. 2021-04-13 23:14:06 -07:00
Victoria Mitchell
f4154d6019 add flag to skip docs on synthesized symbols 2021-04-11 17:40:37 -05:00
Arnold Schwaighofer
9286ece71c Revert "Enable import of the _Concurrency module by default." 2021-04-09 13:20:30 -07:00
Doug Gregor
cc0a74d766 Enable import of the _Concurrency module by default. 2021-04-06 14:08:41 -07:00
Becca Royal-Gordon
1f713074ac [NFC] Fix issues with -verify mode
This commit fixes two weird bugs in -verify mode:

1. SourceLocs from the wrong SourceManager could be passed through a ForwardingDiagnosticConsumer into the DiagnosticVerifier.

2. -verify-additional-file did not error out correctly when the file couldn’t be opened.

No tests, as we only have basic tests for the diagnostic verifier.
2021-03-25 16:02:29 -07:00
Victoria Mitchell
97a4cba250 add the symbol graph dir to the supplementary file map
rdar://75582169
2021-03-24 09:44:23 -05:00
Michael Gottesman
504b5f2058 [ossa][frontend] Separately namespace enable-ossa-modules in the prebuilt module cache so that the flag causes recompilation of imported resilient modules when the flag is enabled.
This will enable users to try out the '-enable-ossa-modules' flag if their
compiler supports it and get OSSA code on all inlinable code that they use. The
idea is that this is a nice way to stage this in and get more testing.

The specific implementation is that the module interface loader:

1. Knows if enable ossa modules is enabled not to search for any compiled
modules. We always rebuild from the interface file on the system.

2. Knows that if enable ossa modules is enabled to mixin a bit into the module
interface loader cache hash to ensure that we consider the specialized ossa
compiled modules to be different than the modules in that cache from the system.

This ensures that when said flag is enabled, the user transparently gets all
their code in OSSA form from transparent libraries.
2021-03-18 13:03:51 -07:00
Doug Gregor
2a28fed34d Allow one to separately specify the ABI name of a module.
Introduce a new compiler flag `-module-abi-name <name>` that uses the
given name as the ABI name for the module (rather than the module's
name in source code). The ABI name impacts name mangling and metadata.
2021-03-12 07:42:07 -08:00
Victoria Mitchell
3e22b20551 don't pop the last path component from -emit-symbol-graph-dir
rdar://74318113
2021-03-08 12:04:17 -07:00
Robert Widmann
28a37a427f Add Real Enable/Disable Flags for Cross-Module Incremental Builds
In the legacy driver, these flags will merely be propagated to the
frontends to indicate that they should disable serialization of
incremental information in swift module files.

In the new driver, these flags control whether the Swift driver performs
an incremental build that is aware of metadata embedded in the module.

Kudos to David for coming up with our new marketing name: Incremental
Imports.

rdar://74363450
2021-03-01 10:15:25 -08:00
Ben Barham
bb9dd3a4aa [Frontend] Allow missing files when allowing compiler errors
As with other compilation errors, we want to generate the swiftmodule
regardless.
2021-02-24 14:13:21 +10:00
AG
a5b804602d Merge pull request #35110 from bitjammer/acgarland/emit-symbol-graph
Add optional -emit-symbol-graph output when emitting modules
2021-02-12 09:00:58 -08:00
Becca Royal-Gordon
8d0040fa2b Improve access note error handling
The LLVM rebranch added an “AllowUnknownKeys” setting to llvm::yaml::Input, which lets us rip out a lot of marginal code and encourages a broader rework of access note error diagnosis:

• Access note warnings and errors are now diagnosed as they’re found during YAML parsing
• They now have proper SourceLocs inside the .accessnotes file
• They’re now tested using -verify-additional-file instead of FileCheck
• A lot of gross duct tape is now gone
2021-02-10 00:29:34 -08:00
Becca Royal-Gordon
01fa74510e [NFC] Clean up access note code
• Rename properties for greater consistency with the YAML file
• Rename AccessNotes -> AccessNotesFile
• Add doc comments
• Miscellaneous comment/style improvements.
2021-02-09 14:17:35 -08:00
Becca Royal-Gordon
bf13139495 Allow unknown keys in access notes
LLVM’s YAML support wants to show a hard error if an unknown string appears in an access note. Instead, emit a remark but load the parts of the access note we do understand to allow for future expansion of access notes.
2021-02-09 14:17:35 -08:00
Becca Royal-Gordon
e42294737f Handle access note I/O and parse errors 2021-02-09 14:17:35 -08:00
Becca Royal-Gordon
ccf244b89b Add ability to load access notes 2021-02-09 14:17:33 -08:00
Ashley Garland
69c4fc47cb Add optional -emit-symbol-graph output when emitting modules
rdar://71497047
2021-01-28 09:55:33 -08:00
swift-ci
90eb4fe6af Merge remote-tracking branch 'origin/main' into rebranch 2021-01-15 13:12:33 -08:00
Xi Ge
fcbc2b4d9d Merge pull request #35414 from nkcsgexi/volatile-open-input
Frontend: add an option -bad-file-descriptor-retry-count
2021-01-15 12:58:55 -08:00
Xi Ge
ae9d873009 Frontend: add an option -bad-file-descriptor-retry-count
This option allows the compiler to retry opening an input file if the previous
opening returns an error of bad file descriptor. Swift-driver will set this
argument in certain circumstances to walk-around such error.

rdar://73157185
2021-01-15 10:28:27 -08:00
swift-ci
6841728fb2 Merge remote-tracking branch 'origin/main' into rebranch 2021-01-14 09:32:28 -08:00