Commit Graph

23 Commits

Author SHA1 Message Date
Xi Ge
7d08a24161 ModuleInterface: reconstruct command-line arguments for building Swift module from interface explicitly 2020-05-15 10:49:45 -07:00
Xi Ge
3952fd5bf7 ModuleInterface: refactor compiler instance configuration to a standalone delegate class. NFC
Module interface builder used to maintain a separate compiler instance for
building Swift modules. The configuration of this compiler instance is also
useful for dependencies scanner because it needs to emit front-end compiler invocation
for building Swift modules explicitly.

This patch refactor the configuration out to a delegate class, and the
delegate class is also used by the dependency scanner.
2020-05-12 16:19:27 -07:00
Xi Ge
3cb8d8e814 DependencyScanner: inherit ASTContext options when configuring a sub compiler instance for interface scanner. NFC 2020-05-05 11:29:12 -07:00
Xi Ge
9bc036c050 DependencyScanner: honor additional compiler flags in interfaces files when collecting imports
Additional flags in interface files may change parsing behavior like #if
statements. We should use a fresh ASTContext with these additional
flags when parsing interface files to collect imports.

rdar://62612027
2020-05-04 22:18:11 -07:00
Brent Royal-Gordon
cd7bc73a0a Merge pull request #30462 from brentdax/futures-end-part-two
Provide fallback SourceLoc for swiftinterface build errors
2020-03-18 16:23:49 -07:00
Brent Royal-Gordon
a27fdad4e5 Provide fallback SourceLoc for swiftinterface build errors
When a swiftinterface fails to build for any of various reasons, we try to diagnose the failure at the site of the `import` declaration. But if the import is implicitly added—which happens for many SDK modules, like the standard library and ClangImporter overlays—there is no source location for the import, so the error ends up being diagnosed at <unknown>:0. This causes a number of issues; most notably, Xcode doesn’t display the diagnostic as prominently as others.

This change falls back to diagnosing the error at line 1, column 1 of the swiftinterface file itself. This is perhaps not an ideal location, and it won’t help with I/O errors where we can’t open the swiftinterface file (and therefore can’t diagnose an error in it), but it should improve the way we display most module interface building errors.
2020-03-17 18:44:31 -07:00
Dmitri Gribenko
841eeb05b0 Merge pull request #30403 from MForster/forster/string-fixes
Cherry-pick StringRef->std::string conversion fixes into `master`
2020-03-17 12:09:36 +01:00
Brent Royal-Gordon
a7a5e340aa Improve diagnostic for broken module interfaces
Currently, when a swiftinterface file fails to load, we emit the specific diagnostics for the failures, followed by a generic “failed to load module ‘Foo’” message. This PR improves that final diagnostic, particularly when the cause may be that the interface was emitted by a newer compiler using backwards-incompatible syntax.
2020-03-13 20:31:55 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
John McCall
eea07b318d Preserve PrettyStackTrace context in the interface worker thread.
Because we block the calling thread, this should be safe for the existing
implementation of PrettyStackTrace; however, it would be much nicer if
LLVM provided direct support for this.

The most important thing from the trace that we want to print is the
original command line, so an alternative would be to just make a
PrettyStackTrace that printed all of the CompilerInvocation context;
I think that's accessible somewhere.  But this is a nice, simple
improvement.
2020-03-09 22:13:36 -04:00
Xi Ge
8c2a041822 Front-end: add an option to not lock interface file when building module
This could help fix a flaky test.

Related to: rdar://58578342
2020-02-25 12:13:14 -08:00
Xi Ge
81fa2ed8a7 ModuleInterface: increase timeout time for .interface file lock
Harlan and Robert mentioned the default timeout time may not suffice
for building the stdlib from the interface file.

rdar://59560260
2020-02-18 12:10:41 -08:00
Robert Widmann
53b368b34f Always write out nested types tables
Remove the option to switch off nested types tables. In a world where
re-entrant direct lookup will cause deserialization to fail (or worse),
disabling these tables will only lead to further instability in the
compiler.
2020-02-10 10:41:23 -08:00
Robert Widmann
f56fee839b [ModuleInterface] Pass Through Flags for Nested Types Tables
When a swift module is generated from a swift interface file, we must
remember to setup the nested types tables. Plumb the flag down from the
frontend options.

In the future, we must remove the ability to turn this off. There's
literally zero reason to have this be a configuration option anymore.

Resolves rdar://59202687 and its many, many dupes.
2020-02-07 14:37:03 -08:00
Xi Ge
e1f6e846ca Re-apply "ModuleInterface: lock .swiftinterface while generating module cache" 2020-01-10 12:25:15 -08:00
Mishal Shah
c769e491e2 Revert "ModuleInterface: lock .swiftinterface while generating module cache" 2020-01-09 22:54:41 -08:00
Xi Ge
a8baeb3670 Merge pull request #29101 from nkcsgexi/lock-interface-gen-module
ModuleInterface: lock .swiftinterface while generating module cache
2020-01-09 17:41:20 -08:00
Xi Ge
8dda0193a6 ModuleInterface: lock .swiftinterface while generating module cache
This ensures only one process is generating module cache from an interface
file so that we don't blow up memory usage when multiple processes are
doing the same. The locking mechanism is similar to that of Clang's.

A better approach is that the build system takes care of the module building
step as a formal dependency.

rdar://52839445
2020-01-09 15:45:48 -08:00
Xi Ge
133e8a186f ModuleInterface: preserve AutolinkForceLoad option when generating .swiftmodule from .swiftinterface
This change ensures using .swiftmodule built from source has the same behavior as
using .swiftmodule built from .swiftinterface.

A swift-ide-test utility is added to print linked libraries from a Swift module for
testing purposes.

rdar://58057556
2020-01-06 21:17:02 -08:00
Xi Ge
3103b5cec1 Frontend: set up output file .swiftsourceinfo
This patch will focus on teaching driver and frontend to emit this file.
The actual content and de-serialization parts will come later.

More details: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation/28794
2019-09-24 13:52:17 -07:00
Harlan Haskins
c82c9b8210 [ModuleInterfaces] Remove references to 'parseable' interfaces everywhere
Now that we've settled on Module Interface as the name, let's remove the
vestiges of "Parseable Interfaces"
2019-09-13 14:55:48 -07:00
Harlan Haskins
dcbfe443ca [ModuleInterfaces] ParseableInterfaceBuilder -> ModuleInterfaceBuilder
Rename ParseableInterfaceBuilder to accompany ModuleInterfaceLoader
2019-09-13 13:52:16 -07:00
Harlan Haskins
2764e64cae [ModuleInterfaces] Split ParseableInterfaceBuilder to its own file
NFC, they were just separate enough to warrant splitting into their own
file.
2019-09-13 11:45:34 -07:00