Commit Graph

1195 Commits

Author SHA1 Message Date
3405691582
62a13e9ecd [test] Erase SDKROOT since env -u is not portable.
The `env -u` flag is not portable and not available on all platforms, so
this unit test will fail when the feature is unavailable.  Instead of
trying to unset the field, just erase it instead, since trying to copy
the entire invoked environment is difficult.
2020-09-19 21:05:01 -04:00
Xi Ge
028a75572c ModuleInterface: remark potential version differences between SDK and prebuilt modules
Prebuilt-module directory now contains a SystemVersion.plist file copied from the SDK
it's built from. This patch teaches the compiler to remark this version and the SDK version
when -Rmodule-interface-rebuild is specified. The difference between these versions could
help us debug unusable prebuilt modules.
2020-09-04 11:45:05 -07:00
Brent Royal-Gordon
8fbd449501 Merge pull request #33114 from brentdax/check-your-interfaces-at-the-door
Verify that just-emitted module interfaces parse and typecheck
2020-08-24 20:33:58 -07:00
Slava Pestov
ce550f2464 AST: Try harder to preserve type sugar in AbstractGenericSignatureRequest
AbstractGenericSignatureRequest tries to minimize the number of GSBs that we
spin up by only creating a GSB if the generic parameter and requirement types
are canonical. If they're not canonical, it first canonicalizes them, then
kicks off a request to compute the canonical signature, and finally, re-applies
type sugar.

We would do this by building a mapping for re-sugaring generic parameters,
however this mapping was only populated for the newly-added generic parameters.

If some of the newly-added generic requirements mention the base signature's
generic parameters, they would remain canonicalized.

Fixes <rdar://problem/67579220>.
2020-08-24 19:16:36 -04:00
Alexis Laferrière
fd78da5137 [ModuleInterface] Don't print extensions to implementation-only imported types
Extensions to implementation-only types are accepted at type-checking
only if they don't define any public members. However if they declared a
conformance to a public type they were also printed in the
swiftinterface, making it unparsable because of an unknown type.

Still accept such extensions but don't print them.

rdar://problem/67516588
2020-08-20 17:12:31 -07:00
Brent Royal-Gordon
22e3cff700 Tweak diagnostic for failed module interface verification 2020-08-07 17:45:04 -07:00
Brent Royal-Gordon
5f523fee66 Add flag to verify just-emitted module interfaces
The driver can now schedule jobs which typecheck just-emitted module interfaces to ensure that they can be consumed later. This can be enabled manually by passing `-verify-emitted-module-interface` to the driver.
2020-08-07 17:45:03 -07:00
Brent Royal-Gordon
9bc787ef5f Add a “typecheck module interface” mode 2020-08-07 16:00:15 -07:00
Arnold Schwaighofer
54c758f2a1 Convert the EagerSpecializer pass to a function pass
Should be NFC.
2020-07-27 13:55:59 -07:00
Xi Ge
1b40abd52c test: fix ModuleInterface/emit-forward-modules.swift 2020-07-20 11:39:07 -07:00
Mike Ash
8362ddd1a0 [Test] Disable ModuleInterface/emit-forward-modules.swift until it can be fixed 2020-07-20 11:29:42 -04:00
Xi Ge
f9396f2812 ModuleInterface: teach -compile-module-from-interface to emit forwarding module
-compile-module-from-interface action now takes arguments of -candidate-module-file.
If one of the candidate module files is up-to-date, the action emits a forwarding
module pointing to the candidate module instead of building a binary module.
2020-07-18 19:13:47 -07:00
Xi Ge
f5477d67af ModuleInterface: teach the compiler to look into SDK-versioned prebuilt module cache dir
To support multiple versions of SDKs of the same platform, we should move prebuilt
module cache into an SDK-versioned sub-directory and teach the compiler to look into
the directory if present.

rdar://65488510
2020-07-14 10:40:16 -07:00
Robert Widmann
39ad5e48ba Merge pull request #32789 from compnerd/pipe-dream
test: use `-log-path` for stderr access in ModuleInterface tests
2020-07-10 14:35:29 -07:00
Saleem Abdulrasool
e3548dd638 test: use -log-path for stderr access in ModuleInterface tests
The stderr handles seem to behave differently under Python 3.  Use the
`-log-path` option to capture the standard error output and validate the
output.
2020-07-09 17:19:55 +00:00
Nathan Hawes
9bcb54910e [AST] Prefer the 'macOS' spelling over 'OSX' when printing the platform kind.
This affects module interfaces, interface generation in sourcekitd, and
diagnostics. Also fixes a fixit that was assuming the 'OSX' spelling when
computing the source range to replace.

Resolves rdar://problem/64667960
2020-07-08 13:51:25 -07:00
Hamish Knight
241c5d95e3 Merge pull request #32461 from hamishknight/its-all-linked 2020-07-08 11:07:17 -07:00
Mishal Shah
1899d2c06b [Apple Silicon] Mark macOS tests that require x86_64 2020-07-02 16:28:41 -07:00
Mishal Shah
92ca9fc924 [Apple Silicon] Generalize tests for other macOS architectures
Most of the changes fall into a few categories:
* Replace explicit "x86_64" with %target-cpu in lit tests
* Cope with architecture differences in IR/asm/etc. macOS-specific tests
2020-07-02 16:27:46 -07:00
Hamish Knight
b3dcef9796 Avoid unnecessary linking in SIL tools
Previously we were linking in all SIL entities
if the input was a serialized non-SIB AST, and
`-disable-sil-linking` wasn't specified. However
none of the tests appear to want this behaviour.

Stop calling `SerializedSILLoader::getAll`, and
remove the `-disable-sil-linking` option, as this
is now the default behaviour.
2020-07-01 23:14:01 -07:00
Robert Widmann
89ae325d22 Use Formal Access To Compute Override Elision Check
The effective access of an overridden declaration is subject to
escalation by -enable-testing. When this is flag is enabled, an
interface containing an internal-overriding-public declaration will
still print `override`. This is because the effective access of the base
of the override is formally internal but effectively public.

Instead, use the formal access scope of the overridden declaration to
compute its access relative to the override. While I'm here, catch the
case where the base declaration is `@usableFromInline` and therefore
*will* be printed in the interface. We treat these declarations as
effectively public for the purpose of printing `override`.

Resolves rdar://64969741
2020-06-30 21:28:42 -07:00
Saleem Abdulrasool
240ae1b589 test: make make-unreadable Python 3 friendly
Make `make-unreadable` python 3 compatible.  `POINTER` is now in
`ctypes` rather than in `ctypes.wintypes`.  Use the new location which
is compatible across python 2 and python 3.
2020-06-24 09:00:21 -07:00
Alexis Laferrière
b4f2e63df8 [ModuleInterface] Prefer the swiftmodule in the SDK over the prebuilt-cache
Fix the search order for module interfaces to respect the documented
behavior:

1. Local cache
2. Next to the .swiftinterface
3. Prebuilt cache

Fixing the order of the last two allows the XcodeDefault compiler to
prioritize swiftmodule files with SPI information.

rdar://problem/64097455
2020-06-17 08:36:08 -07:00
Pavel Yaskevich
16862e50a5 Merge pull request #31713 from xedin/no-ranking-with-ambiguous-with-fixes
[ConstraintSystem] Overhaul ambiguity diagnostics
2020-06-16 12:55:14 -07:00
3405691582
c8ba437444 [test] Handle architecture aliasing for OpenBSD.
Swift calls the architecture x86_64, OpenBSD calls it amd64. If we use
run_cpu in lit.cfg as-is, then we may need to duplicate lines in each
test for 'x86_64' and 'amd64', which puts a maintenance burden on unit
test developers to ensure they are duplicating changes to each line.

Instead, alias 'amd64' to 'x86_64' for `run_cpu`, but keep the platform
module path referring to 'amd64', in order to distinguish the target
architecture name and the Swift architecture name. This is particularly
relevant for the %target-.*-name pseudovariables used, which should
reference the Swift architecture names.

However, some unit tests are directly referencing %target-cpu directly,
which would break the aliasing. This is done only for swiftinterface
files, so a new substitution is defined in lit.cfg for these variables,
and the affected unit test cases are migrated.
2020-06-12 21:06:37 -04:00
Pavel Yaskevich
d23b938331 [Diagnostics] Implement IgnoreAssignmentDestinationType::diagnoseForAmbiguity
For cases like this:

```swift
struct X {}
struct Y {}

func overloaded<T>(_ value: T) -> T { value }
func overloaded<T>(_ value: T) -> Int { 0 }

func test(x: inout X, y: Y) {
  x = overloaded(y)
}
```

Solver would record a `IgnoreAssignmentDestinationType` fix per overload,
`diagnoseForAmbiguity` could be used to properly diagnose ambiguity cases
like that.
2020-06-12 11:47:04 -07:00
Doug Gregor
014466de5a [Function builders] Update test case 2020-05-29 20:59:44 -07:00
Doug Gregor
8cec6b555d [Function builders] Add tests for function builders on protocol requirements 2020-05-25 23:42:45 -07:00
David Zarzycki
5dcc32f98f Remove all uses of -force-single-frontend-invocation
The `-force-single-frontend-invocation` flag predates WMO and is now an
alias for `-whole-module-optimization`. We should use the latter and let
the former fade into history.
2020-05-08 06:37:41 -04:00
Robert Widmann
fb8e23e94f Propagate Failures Explicitly in Opaque Type Resolution
This code should not yield the null Type() on failure. Instead, diagnose
the failure and yield an ErrorType. This matches what clients of this
function expect to signal failure.

Include a regression test that exercises a common failure mode if we
don't do this: module interface loading crashes.

rdar://62745419
2020-05-01 18:22:38 -07:00
Brent Royal-Gordon
f7c4c9e920 Reduce path length of swift_build_sdk_interfaces Catalyst fixtures
#31342 moved a file to a path that’s too long for our Windows builders. Collapse the directory structure a bit to get it under the limit.
2020-04-28 20:42:24 -07:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
Brent Royal-Gordon
0c54e2d6e0 Rename Mac Catalyst-related test
Fixes rdar://62338598
2020-04-27 12:02:49 -07:00
Brent Royal-Gordon
92e3b5f785 Merge pull request #31288 from brentdax/reacting-to-reactivekit
Fix ReactiveKit failure seen in source compatibility suite
2020-04-24 21:20:05 -07:00
swift-ci
d385e2826f Merge pull request #31298 from varungandhi-apple/vg-update-arm64e-fallback-test 2020-04-24 17:20:34 -07:00
Varun Gandhi
fb1f65b80a [NFC] [arm64e] Mark arm64e fallback test unsupported for Catalyst.
Fixes rdar://problem/62337141.
2020-04-24 15:11:01 -07:00
Brent Royal-Gordon
e7bd60494a Revert "[ModuleLoader] Emit a better diagnostic for swiftinterfaces with wrong arch."
This reverts commit 412ee0a922.
2020-04-24 13:45:05 -07:00
Brent Royal-Gordon
9b252821d6 Add test case for failure seen in source compat suite
Master source compat suite job #4912 failed to build ReactiveKit because Combine does not have an interface for older iOS architectures that were retired before it was released, and a change to module loading diagnosis started to consider switfinterfaces. Add a test case that covers this situation.
2020-04-24 13:45:05 -07:00
Doug Gregor
94e9153878 Merge pull request #31170 from DougGregor/build-module-triples
[CMake] Use proper module triples for the names of standard library modules
2020-04-23 23:57:50 -07:00
Doug Gregor
58296b9dab Update test for building module interfaces for an SDK 2020-04-23 21:33:36 -07:00
Varun Gandhi
412ee0a922 [ModuleLoader] Emit a better diagnostic for swiftinterfaces with wrong arch.
Before this change, we would emit the warning only for swiftmodules; however,
it may be the case that only a swiftinterface (of a different arch) is present
but no swiftmodule is present.

Fixes rdar://problem/50905075.
2020-04-22 23:58:54 -07:00
Varun Gandhi
c4134ca452 [ModuleInterface] Remove fallback behavior for arm64e -> arm64.
Addresses rdar://problem/61407215.
2020-04-22 23:58:33 -07:00
Varun Gandhi
93958ed76b [NFC] Add test case for old arm64e fallback behavior. 2020-04-22 23:57:48 -07:00
Doug Gregor
b27b4d4bb6 [CMake] Use proper module triples for the names of standard library modules.
The standard library (and other Swift modules built by our CMake build system)
has been building module files with an architecture only (e.g., x86_64.swiftmodule)
rather than a proper module triple (x86_86-apple-macosx10.15,
x86_64-apple-ios13.0-simulator, etc.), unlike every other build
system. There are hacks in the compiler and other tools to cope with
this unnecessary build difference. Fix the module file names so we'll
be able to remove the hacks later.

Fixes rdar://problem/49071536.
2020-04-20 21:16:14 -07:00
Suyash Srijan
724f8c23db [Typechecker] Implement SE-0268 Refine didSet Semantics (#26632) 2020-04-09 01:23:15 +01:00
Xi Ge
b00698d977 ModuleInterface: print function-builder custom attribute only on parameters
Printing this attribute on other definitions isn't necessary.

rdar://58544718
2020-03-19 15:41:08 -07:00
Xi Ge
b717fafedb Merge pull request #30509 from nkcsgexi/58562780
ModuleInterface: skip override keywords when overriding an invisible decl from super class
2020-03-19 14:11:10 -07:00
Xi Ge
75abee8f45 ModuleInterface: skip override keywords when overriding an invisible decl from super class
When we are printing Swift interface, we have to skip the override keyword
if the overriden decl is invisible from the interface. Otherwise, an error
will occur while building the Swift module because the overriding decl
doesn't override anything.

We couldn't skip every `override` keywords because they change the
ABI if the overriden decl is also publicly visible.

For public-override-internal case, having `override` doesn't have ABI
implication. Thus we can skip them.

rdar://58562780
2020-03-19 11:47:54 -07:00
Slava Pestov
9ec80df97e SIL: Remove curried SILDeclRefs 2020-03-19 02:20:21 -04:00
Xi Ge
45d0eca9c7 ModuleInterface: consider inherited protocols from super class when collecting handled protocols
Protocol conformances can be implied by super classes. When collecting the list
of IncludedProtocols, we should traverse the class inheritance chain and collect
all protocols.

Without this change, these implied conformances will be printed again via a synthesized
extension at the end of the Swift interface file, leading to an error of redundant
conformances when building modules.

rdar://58563540
2020-03-18 17:21:13 -07:00