Commit Graph

14 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
swift-ci
8e584a61cc Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-10 14:43:41 -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
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
Jonas Devlieghere
a3455f3aa0 Update Swift for upstream LLVM/Clang changes.
It seems like some headers were reorganized. Add the missing includes.
2019-11-18 09:57:32 -08: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