Commit Graph

753 Commits

Author SHA1 Message Date
Xi Ge
1115332ab9 ModuleInterface: add a frontend flag to skip printing import statement corresponding to a module name.
Related: rdar://63465931
2022-02-24 15:33:26 -08:00
Rintaro Ishizaki
d91ec5ac1d [SourceKit] Add cancellation points for 'compile' requests
After each stage of the compilation pipeline before the code generation.
Sema, SILGen, SILOptimization, SILLowering, IRGen.
2022-01-24 22:18:10 -08:00
Alex Lorenz
e106551028 [NFC][interop] rename the PrintAsObjC library to PrintAsClang
We're starting to support emission of C++ header interfaces, so a language-agnostic name makes more sense
2022-01-20 11:31:58 -08:00
Alex Lorenz
7aa1cd166e Fix comment typos related to printAsCXX 2022-01-20 11:04:21 -08:00
Alex Lorenz
e0eec4dd7c Merge pull request #40923 from hyp/emit-cxx-interface-option
[interop] add an option to emit C++ header interface for a module
2022-01-20 07:16:53 -08:00
Alex Lorenz
6486c3c1d8 [interop] add an option to emit C++ header interface for a module 2022-01-19 18:55:14 -08:00
swift-ci
35f8b62ffc Merge remote-tracking branch 'origin/main' into rebranch 2022-01-18 13:40:44 -08:00
Zoe Carver
afd640842e Merge pull request #40893 from zoecarver/interop-index-store-crash
[cxx-interop] Fix crash when indexing with C++ interop enabled.
2022-01-18 13:31:26 -08:00
zoecarver
883a9abf53 [cxx-interop] Fix crash when indexing with C++ interop enabled.
This is a stop-gap solution to prevent crashes.
2022-01-18 10:20:09 -08:00
swift-ci
a43a530522 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-12 03:14:28 -08:00
Louis D'hauwe
a89ea380a9 [ASTPrinter] Print expressions
Add new `-print-ast-decl` frontend option for only printing declarations,
to match existing behavior.
Some tests want to print the AST, but don't care about expressions.

The existing `-print-ast` option now prints function bodies and expressions.
Not all expressions are printed yet, but most common ones are.
2022-01-11 14:24:16 -08:00
swift-ci
95586e858c Merge remote-tracking branch 'origin/main' into rebranch 2022-01-04 16:00:29 -08:00
Nuri Amari
130f2de7fd Improve ClangImporter failure diagnostics
This patch introduces new diagnostics to the ClangImporter to help
explain why certain C, Objective-C or C++ declarations fail to import
into Swift. This patch includes new diagnostics for the following entities:

- C functions
- C struct fields
- Macros
- Objective-C properties
- Objective-C methods

In particular, notes are attached to indicate when any of the above
entities fail to import as a result of refering an incomplete (only
forward declared) type.

The new diangostics are hidden behind two new flags, -enable-experimental-clang-importer-diagnostics
and -enable-experimental-eager-clang-module-diagnostics. The first flag emits diagnostics lazily,
while the second eagerly imports all declarations visible from loaded Clang modules. The first
flag is intended for day to day swiftc use, the second for module linting or debugging the importer.
2022-01-02 12:43:59 -05:00
swift-ci
ba0c98ff08 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-21 22:33:02 -08:00
Rintaro Ishizaki
473ecd8c80 Merge pull request #40645 from rintaro/sourcekit-compilerserver
[SourceKit] Add a request to generate object files in SourceKit
2021-12-21 22:29:11 -08:00
Rintaro Ishizaki
7c92a8e555 [SourceKit] Add a request to generate object files in SourceKit
Add 'request.compile'
2021-12-21 14:35:38 -08:00
swift-ci
a7f9d15c2e Merge remote-tracking branch 'origin/main' into rebranch 2021-12-20 06:35:32 -08:00
Erik Eckstein
c55f040308 Add a mechanism to let cross-module-optimization add additional TBD symbols.
PublicCMOSymbols stores symbols which are made public by cross-module-optimizations.
Those symbols are primarily stored in SILModule and eventually used by TBD generation and validation.
2021-12-20 11:33:02 +01:00
swift-ci
5f3249008e Merge remote-tracking branch 'origin/main' into rebranch 2021-12-16 18:53:28 -08:00
Robert Widmann
df563ba5d0 Merge pull request #40414 from drodriguez/tbd-validation-modules 2021-12-16 18:44:12 -08:00
swift-ci
7ff906d730 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-14 04:53:37 -08:00
Alex Hoppen
63c31033fc [Frontend] Load standard libarary in CompilerInstance::setup
Instead of checking that the stdlib can be loaded in a variety of places, check it when setting up the compiler instance. This required a couple more checks to avoid loading the stdlib in cases where it’s not needed.

To be able to differentiate stdlib loading failures from other setup errors, make `CompilerInstance::setup` return an error message on failure via an inout parameter. Consume that error on the call side, replacing a previous, more generic error message, adding error handling where appropriate or ignoring the error message, depending on the context.
2021-12-13 15:32:08 +01:00
Daniel Rodríguez Troitiño
8a0e5129b1 [frontend] Fix TBD validation almost always done for modules
The logic to do or not the validation of TBD against IR was incorrect.
In the case of modules, the comment described what was supposed to
happen (skipping the validation if the module had SIB files), but the
code was returning if the module had or not SIB files, which would have
returned true for any module without SIB files without checking if the
compiler was build in a debug configuration or not.

This was only visible in the case of non-debug builds, and it only
appeared for us in a convoluted mix of optimized builds with
-enable-testing on some modules.
2021-12-10 12:39:41 -08:00
swift-ci
1bd5fccf9e Merge remote-tracking branch 'origin/main' into rebranch 2021-12-03 18:13:57 -08:00
Ben Barham
efcb5e38ca [Frontend] Add whether allowing compiler errors to the pretty stacktrace
While this will be in the compiler arguments, it's easy to miss when
skimming over the pretty stacktrace. Add an explicit message to make it
easier to see while looking over crashes.
2021-11-30 15:46:52 +10:00
Ben Barham
11f28196bc Merge pull request #40168 from bnbarham/rebranch-failures
[rebranch] Fix compilation failures
2021-11-17 08:50:11 +10:00
Ben Barham
c676dfc2fa [rebranch] Update uses of ErrorHandling.h functions
llvm-project `ErrorHandling.h` was updated to remove std::string. This
added a new `report_fatal_error` overload taking a `const Twine &`,
removed the overload that took `const std::string &`, and updated
`fatal_error_handler_t` to use `const char *` rather than `const
std::string &`.

Fix uses of these functions to take into account these updates. Note
that without the `const std::string &` overload, passing a `std::string`
into `report_fatal_error` now results in an ambiguous match between the
`StringRef` and `Twine` overloads so we need to be explicit about one or
the other.
2021-11-13 15:33:09 +10:00
Artem Chikin
40a1b321f5 Add libSwiftScan entry-point to query target info.
This provides the library with functionality to answer `-print-target-info` queries in place of calls to `swift-frontend`.
2021-11-12 11:01:45 -08:00
Erik Eckstein
5321a7cae8 SIL: Only enable instruction leaks checking in the frontend's and SILOpt's modules.
Leaks checking is not thread safe and e.g. lldb creates multiple SILModules in multiple threads, which would result in false alarms.
Ideally we would make it thread safe, e.g. by putting the instruction counters in the SILModule, but this would be a big effort and it's not worth doing it. Leaks checking in the frontend's and SILOpt's SILModule (not including SILModules created for module interface building) is a good enough test.

rdar://84688015
2021-11-02 10:23:46 +01:00
Slava Pestov
0eb66222e2 AST: Move expensive generic signature checks to GenericSignature.cpp
This removes the final dependency on GenericSignatureBuilder.h.
2021-10-30 00:35:59 -04:00
Victoria Mitchell
156e58d69a use symbol graph opts instead of serialization opts for SGFs 2021-10-21 17:12:49 -06:00
Xi Ge
2d43a9259e Frontend: teach final module emitting jobs to dump a placeholder file for module semantic info
This additional supplement output should capture semantic info the compiler has
captured while building a Swift module. Similar to the source info file, the content of
the semantic info file should only be consumed by local tooling written in Swift.
2021-10-11 18:19:26 -07:00
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
Alexis Laferrière
69ce3ec41f [Frontend] Don't ask to report bugs to us in immediate mode
rdar://81233463
2021-10-06 14:13:58 -07:00
swift-ci
37f2574af6 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-07 13:54:58 -07:00
Argyrios Kyrtzidis
a382f589a5 Merge pull request #39141 from akyrtzi/opt-record-via-supplemental-outputs
[frontend] Support passing the optimization record file via the supplemental outputs map
2021-09-07 13:44:05 -07:00
swift-ci
cd7ed018bf Merge remote-tracking branch 'origin/main' into rebranch 2021-09-02 11:56:28 -07:00
Argyrios Kyrtzidis
d3ba531e64 [frontend] Support passing the optimization record file via the supplemental outputs map
The Swift driver is passing the optimization record file path via the supplementals output, instead of the flag, on certain circumstances.
Enhance the frontend to check supplemental outputs otherwise the record file will not get emitted when using the new swift driver.
2021-09-02 11:13:34 -07:00
Varun Gandhi
4a16261c4d [Driver] Update OS versions for rpath checks.
Make sure that we add the appropriate rpaths so that the appropriate
_Concurrency back-deployment library can be picked up.

We don't need to update the Swift driver since it uses the C++ driver
as the source of truth to determine if the relevant rpath should be
added or not.
2021-09-01 15:37:24 -07:00
swift-ci
86f6f2e622 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-22 14:34:00 -07:00
Xi Ge
1a660c08ca Frontend: teach -compile-module-from-interface action to emit ABI descriptor as byproduct
We have implemented a libSwiftDriver-based tool to generate prebuilt module cache for
entire SDKs. Anchored on the same infrastructure, we could also generate ABI baselines
for entire SDKs.
2021-08-20 15:47:10 -07:00
swift-ci
44195c4ce3 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-13 22:13:27 -07:00
Alexis Laferrière
577886408b [Frontend] Emit incr compilation info from emit-module jobs
Enable emitting the module-level incremental fine-grained compilation
information from the emit-module job for incremental compilation to
work with emit-module-separately.
2021-08-13 16:53:42 -07:00
swift-ci
53147b2ccb Merge remote-tracking branch 'origin/main' into rebranch 2021-08-06 14:13:40 -07:00
Artem Chikin
9429136112 [Dependency Scanning] Split the ModuleDependencyCache into two: current scan cache & global.
This change causes the cache to be layered with a local "cache" that wraps the global cache, which will serve as the source of truth. The local cache persists only for the duration of a given scanning action, and has a store of references to dependencies resolved as a part of the current scanning action only, while the global cache is the one that persists across scanning actions (e.g. in `DependencyScanningTool`) and stores actual module dependency info values.

Only the local cache can answer dependency lookup queries, checking current scanning action results first, before falling back to querying the global cache, with queries disambiguated by the current scannning action's search paths, ensuring we never resolve a dependency lookup query with a module info that could not be found in the current action's search paths.

This change is required because search-path disambiguation can lead to false-negatives: for example, the Clang dependency scanner may find modules relative to the compiler's path that are not on the compiler's direct search paths. While such false-negative query responses should be functionally safe, we rely on the current scanning action's results being always-present-in-the-cache for the scanner's functionality. This layering ensures that the cache use-sites remain unchanged and that we get both: preserved global state which can be queried disambiguated with the search path details, and an always-consistent local (current action) cache state.
2021-08-06 09:13:42 -07:00
Arnold Schwaighofer
5a83172a55 Merge remote-tracking branch 'upstream/main' into rebranch 2021-08-05 12:04:56 -07:00
Xi Ge
9a7ac2c5be Frontend: remove -emit-ldadd-cfile-path. NFC
ld should now fully support $ld$previous$, so we shouldn't need this workaround
to generate a C source file to include $ld$add$ definitions.
2021-08-01 15:37:15 -07:00
swift-ci
1538e30794 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-27 15:33:34 -07:00
Ben Barham
12018bebb9 [Frontend] Always output the version being compiled for
Outputting the effective version in the pretty stack trace was skipped
if the current version was the same as the effective version. This would
result in an empty line, which is somewhat confusing. Output a line
regardless.

Resolves rdar://81140703
2021-07-27 11:32:31 +10:00
swift-ci
fa22d03adb Merge remote-tracking branch 'origin/main' into rebranch 2021-07-26 16:53:31 -07:00