Commit Graph

63 Commits

Author SHA1 Message Date
Jordan Rose
f76d2c3976 [ModuleInterface] Short-circuit module loading for frameworks too (#24459)
Follow-up to 7969705 that handles frameworks as well. Oops.

rdar://problem/50070463
2019-05-03 11:11:07 -07:00
Harlan Haskins
f978cb0ba3 Merge pull request #24424 from harlanhaskins/an-absolutely-remarkable-thing
[ModuleInterface] Emit remarks when rebuilding from an interface
2019-05-02 22:45:15 -07:00
Harlan Haskins
dfe4491702 [ModuleInterface] Emit remarks when rebuilding from an interface
Keep track of information that led the module interface loader to reject loading a compiled module, if it needed to fall back to compiling an interface.

rdar://47792754
2019-05-02 17:46:34 -07:00
Jordan Rose
3d16557c7f [ModuleInterface] Look for a prebuilt module by full target name (#24402)
Although the default cache location separates by platform, a
/combined/ cache is still an interesting idea, and in that case we
need to use the full platform names.
2019-05-01 13:48:32 -07:00
Harlan Haskins
fec837a00d [ParseableInterfaces] Improvements to forwarding module dependencies (#23968)
- Fix a typo in the debug output for finding a prebuilt module
- Don't add the prebuilt module path to the dependency tracker
- Ensure we're registering the _forwarding module_'s dependencies in
cached modules, not the prebuilt module's dependencies.
- Check for the existence of a prebuilt module before doing the
is-up-to-date check (which will have failed anyway if it didn't exist).
- Test that forwarding module dependency collection works

rdar://48659199
2019-04-13 00:11:22 -07:00
Harlan Haskins
150ad99457 [ModuleInterfaces] Replace 'module file' with 'compiled module'
...only in diagnostics. And make the tests pass.

rdar://49359734
2019-04-11 18:05:09 -07:00
Harlan Haskins
6d72977642 [test] [ModuleInterfaces] Get tests passing with new diagnostics 2019-04-11 18:05:09 -07:00
Harlan Haskins
817b965420 [test] Make sure we prefer local .swiftmodules to SDK interfaces 2019-04-08 10:07:12 -07:00
Nathan Hawes
8f8fee105e [ParseableInterface][test] Fix path matching in the SDKDependencies and SystemDependencies tests for Windows
Also don't use -n option of cp as it looks like it's not supported.
2019-04-03 12:55:51 -07:00
Nathan Hawes
7144dab15a [ParseableInterface] Don't report out-of-date dependencies to the parent dependency tracker
We previously added dependencies to the tracker inline while validating a cached
module's dependencies were up to date. If one of its dependencies ended up being
out of date though, we shouldn't have added the previous dependencies, as that
means the dependency list itself was also out of date.

This patch changes the behavior to only add the module's dependencies once we've
verified they're all up to date.
2019-04-03 06:35:11 -07:00
Nathan Hawes
58d622d796 [ParseableInterface] Don't serialize resource directory deps and stop adding cached modules to the dependency tracker
This patch modifies ParseableInterfaceBuilder::CollectDepsForSerialization to
avoid serializing dependencies from the runtime resource path into the
swiftmodules generated from .swiftinterface files. This means the module cache
should now be relocatable across machines.

It also modifies ParseableInterfaceModuleLoader to never add any dependencies
from the module cache and prebuilt cache to the dependency tracker (in addition
to the existing behaviour of not serializing them in the generated
swiftmodules). As a result, CollectDepsForSerialization no longer checks if the
dependencies it is given come from the cache as they are provided by the
dependency tracker. It now asserts that's the case instead.
2019-04-03 06:35:11 -07:00
Nathan Hawes
accc64719e [ParseableInterface][test] Update SDKDependencies.swift test to explicitly check serialized dependencies
Also use the existing check-is-forwarding-module.py script to check for
forwarding modules, rather than doing it manually.
2019-04-03 06:35:11 -07:00
Nathan Hawes
37328020df [ParseableInterface] Don't serialize swiftmodule dependencies in the module cache or prebuilt module cache
*Their* dependencies are already being serialized out, so this shouldn't affect
up-to-date-checking except by alowing the regular and prebuilt module caches to
be relocated without invalidating their contents. In the case of the prebuilt
module cache, this gets us closer to supporting relocation across machines.
2019-04-03 06:35:11 -07:00
Nathan Hawes
58d0ee0888 [ParseableInterface] Distinguish SDK and non-SDK dependencies
This allows the SDK to be relocated without automatically resulting in a
rebuild.

Based on an old patch from Jordan Rose.
2019-04-03 06:35:11 -07:00
Jordan Rose
7f3344402c [ParseableInterface] Honor -track-system-dependencies when caching
One interesting thing here is that the decision of whether or not to
track system dependencies ends up going into the cache key for a
swiftmodule built from a parseable interface, because it affects that
module's up-to-date check. If we didn't include
-track-system-dependencies in the cache key, we could end up tracking
system dependencies for some modules but not others in the same build.

There's a bit of a bug here where they're /not/ honored if the
top-level invocation isn't tracking /any/ dependencies, but given
how uncommon this flag is in practice that's probably okay for now.

Still TODO: honor this for -build-swiftmodule-from-parseable-interface
as well. That's currently not tracking dependencies at all and it
probably should.
2019-04-03 06:34:29 -07:00
Saleem Abdulrasool
94f770672a Merge pull request #23705 from compnerd/we-have-picked-up-roots-and-moved
ParseableInterface: `/` is not part of the SDK on Windows
2019-04-01 13:37:44 -07:00
Saleem Abdulrasool
a446ad849a ParseableInterface: / is not part of the SDK on Windows
Extract a Unix-path specific test into its own file to allow the rest of
the tests to be covered on Windows.  This makes the last
ParseableInterface test pass.
2019-04-01 10:58:55 -07:00
Saleem Abdulrasool
7c078bf486 test: make the ParseableInterface.ModuleCache tests pass on Windows
Use a wrapper for invoking chmod a-r or icacls on Windows to make the
files actually unreadable.  This allows the tests to pass on Windows.
2019-04-01 09:58:20 -07:00
Saleem Abdulrasool
1677d4bd5d test: make more of the ParseableInterface tests pass on Windows
Rewrite the shell to be more clever so it is amenable to porting to
Windows.  Use env not rather than not env to permit the lit environment
handling to take over for Windows.
2019-03-21 14:57:30 -07:00
Jordan Rose
22f9853b76 [ParseableInterface] Turn on -enable-parseable-module-interface always (#23331)
...and remove the option. This is ~technically~ CLI-breaking because
Swift 5 shipped this as a hidden driver option, but it wouldn't have
/done/ anything in Swift 5, so I think it's okay to remove.

Note that if a parseable interface (.swiftinterface) and a binary
interface (.swiftmodule) are both present, the binary one will still
be preferred. This just /allows/ parseable interfaces to be used.

rdar://problem/36885834
2019-03-16 15:31:11 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
Jordan Rose
140b3cc37c [test] Tweak check-is-forwarding-module.py to handle multiple inputs (#23313)
And fix the error message printing while I'm at it.

I don't have a public test for this at the moment, but an Apple-
internal tool will use it. I hope to upstream that tool in the future.
2019-03-14 17:55:49 -07:00
Harlan Haskins
366bbf48b9 [ParseableInterface] Add ‘forwarding modules’
A ‘forwarding module’ is a YAML file that’s meant to stand in for a .swiftmodule file and provide an up-to-date description of its dependencies, always using modification times.

When a ‘prebuilt module’ is first loaded, we verify that it’s up-to-date by hashing all of its dependencies. Since this is orders of magnitude slower than reading mtimes, we’ll install a `forwarding module` containing the mtimes of the now-validated dependencies.
2019-03-07 11:36:15 -08:00
Brent Royal-Gordon
f1d1df3b30 Merge pull request #22842 from brentdax/target-practice
Name platform-specific module files using a normalized target triple
2019-02-28 16:07:37 -08:00
Brent Royal-Gordon
3f58a79174 Import error now mentions the target, not the arch 2019-02-27 11:43:12 -08:00
Brent Royal-Gordon
c1cc51d1f3 Use target triple for “universal” modules
When loading a module supporting multiple targets, the module loader now looks for a file named with a normalized version of the target triple first, and only falls back to the architecture name if the normalized triple is not found.
2019-02-27 11:43:12 -08:00
Saleem Abdulrasool
348520c4f1 Merge pull request #22688 from sarveshtamba/master
Changes for test failures on PowerPC64LE when running as non-root user
2019-02-25 08:26:54 -08:00
Jordan Rose
43feb9cbe1 On Apple platforms, use swiftmodule directories for the stdlib (#21797)
This changes the Swift resource directory from looking like

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          x86_64/
            Swift.swiftmodule
            Swift.swiftdoc
            Darwin.swiftmodule
            Darwin.swiftdoc

to

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          Swift.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc
          Darwin.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc

matching the layout we use for multi-architecture swiftmodules
everywhere else (particularly frameworks).

There's no change in this commit to how Linux swiftmodules are
packaged. There's been past interest in going the /opposite/ direction
for Linux, since there's not standard support for fat
(multi-architecture) .so libraries. Moving the .so search path /down/
to an architecture-specific directory on Linux would allow the same
resource directory to be used for both host-compiling and
cross-compiling.

rdar://problem/43545560
2019-02-19 14:47:21 -08:00
sarveshtamba
acc551f9bc Changes for test failures on PowerPC64LE when running as non-root user 2019-02-18 08:25:53 +00:00
Nathan Hawes
e146630b63 [ParseableInterface] Fix failing to build a module when the importing file has errors.
We were checking the parent invocation's DiagnosticEnginer rather than the
subinstance's to determine if there were any errors building the module, which
meant we would fail to load the module if there were errors prior to the import
statement in the importing file.

This also meant code completion would fail to load the module, because it always
emits a bogus error in order to mark the AST as erroneous so that different
parts of the compiler (e.g. the verifier) have less strict assumptions.

rdar://problem/43906499
2019-02-12 12:32:32 -08:00
Brent Royal-Gordon
031166e25b Revert "[ParseableInterface] Fix failing to build a module when the importing file has errors." 2019-02-11 15:59:42 -08:00
Nathan Hawes
2a746da9bc [ParseableInterface] Fix failing to build a module when the importing file has errors.
We were checking the parent invocation's DiagnosticEnginer rather than the
subinstance's to determine if there were any errors building the module, which
meant we would fail to load the module if there were errors prior to the import
statement in the importing file.

This also meant code completion would fail to load the module, because it always
emits a bogus error in order to mark the AST as erroneous so that different
parts of the compiler (e.g. the verifier) have less strict assumptions.

rdar://problem/43906499
2019-02-08 09:08:27 -08:00
Harlan Haskins
4eafcc9a6f [ParseableInterface] Use arch for cache key instead of full triple
The target triple actually includes too much information -- just use the
target architecture.

rdar://46503065
2019-02-05 15:44:39 -08:00
Nathan Hawes
e34a8b32c2 Merge pull request #22380 from nathawes/rdar44400260-test-diagnostics-in-inlinable-function-body-of-swiftinterface
[ParseableInterface] Add diagnostics test for errors in inlinable function bodies
2019-02-05 12:33:57 -08:00
Nathan Hawes
0a04b4bff0 [ParseableInterface] Add diagnostics test for errors in inlinable function bodies
Adds a test that errors reported in the inlinable function bodies of
.swiftinterface files are propagated correctly when generating the corresponding
.swiftmodule files.

rdar://problem/44400260
2019-02-05 11:04:08 -08:00
Harlan Haskins
8843cb6cb4 [test] Make sure we don't double-compile parseable dependencies
Adds a test to make sure that there's only one version of a dependent
module, regardless how many -swift-versions are present in the
dependency hierarchy.
2019-02-04 15:14:45 -08:00
Harlan Haskins
70df66ff6a [test] Change hash-based module cache tests to mtime-based
These tests made sure that changing the hash, while keeping mtime constant, causes dependent modules to be rebuilt. Flip this around so changing the mtime, while keeping the hash constant, causes the same rebuilding behavior.
2019-02-04 13:58:59 -08:00
Saleem Abdulrasool
49f85071dc ParseableInterface: improve test coverage on Windows
This slightly improves the passing set of tests on Windows.
2019-01-29 08:51:31 -08:00
sarveshtamba
c1612c73c3 Merge branch 'master' of https://github.com/apple/swift 2019-01-17 06:57:21 +00:00
sarveshtamba
7cb42b740c Changes for #SR-9413:Swift 5.0 test failures on PowerPC #21541 2019-01-16 11:05:02 +00:00
Saleem Abdulrasool
c0bb36fa2e test: remove some unnecessary shell usage
Replace the shell usage with lit substitutions.  NFC
2019-01-15 10:46:56 -08:00
Jordan Rose
129f39d89e Merge pull request #21513 from jrose-apple/cachet
[ParseableInterface] Pass prebuilt cache path down to sub-invocations

And several other fixes that got folded into this PR.
2019-01-09 14:58:59 -08:00
sarveshtamba
56318f3e1f Changes for #SR-9413:Swift 5.0 test failures on PowerPC 2018-12-24 11:37:38 +00:00
Jordan Rose
614deb640b [ParseableInterface] Pass prebuilt cache path down to sub-invocations
Otherwise, the top-level compilation gets the benefit of the prebuilt
cache path, but the sub-invocations for swiftinterfaces that /do/
need to be compiled do not.
2018-12-21 15:41:17 -08:00
Jordan Rose
5417ca0aa2 [ParseableInterfaces] Handle swiftdoc files correctly
The previous 'openModuleFiles' interface in SerializedModuleLoaderBase
still assumed that swiftmodule files and swiftdoc files would be found
next to each other, but that's not true anymore with
swiftinterfaces-built-to-modules. Give up on this assumption (and on
the minor optimization of passing down a scratch buffer) and split out
the interface into the customization point
'findModuleFilesInDirectory' and the implementation 'openModuleFiles'.
The latter now takes two full paths: one for the swiftmodule, one for
the swiftdoc.
2018-12-21 15:37:32 -08:00
Jordan Rose
4bfe4eff6d [ParseableInterfaces] Add -prebuilt-module-cache-path to the frontend
When trying to load a swiftinterface, search this directory before
doing all the work of building a swiftmodule.
2018-12-17 18:23:28 -08:00
Graydon Hoare
e7ab8fc261 [ModuleInterface] <rdar://46073729> Re-enable test that appears to be working now, unclear why initially failing. 2018-12-17 13:57:29 -08:00
Saleem Abdulrasool
f138f5046a test: invoke python scripts with the interpreter
Ensure that we explicitly provide the path to the interpreter when
running the python scripts during the tests.  This is needed to have the
tests work on Windows which does not honour the shebang in the file.  It
also ensures that we use the correct interpreter for the tests.
2018-12-12 16:07:17 -08:00
Jordan Rose
813316190b [ParseableInterface] Don't require Foundation to use @objc
Deinitializers are always @objc. (Arguably, this makes it unnecessary
to print, but we don't want to do any @objc inference at all in a
swiftinterface.)
2018-12-06 14:57:18 -08:00
Jordan Rose
a51f1dd3d2 [ParseableInterface] Pass down the module name and import source loc
- Use the name for the cached module, so that we don't end up with a
  zillion "x86_64-XXXXXXXX.swiftmodule" files in the cache when we're
  working with architecture-specific swiftmodules.

- Diagnose if the expected name is different from the name specified
  in the swiftinterface.

- Emit all diagnostics at the location of the import, instead of
  without any location at all.
2018-12-06 13:33:07 -08:00