Commit Graph

4565 Commits

Author SHA1 Message Date
Steven Wu
ca87615b4a [CAS] Allow empty filename for diagnostics location
Fix a bug that an empty filename for diagnostics can trigger an error
in the cached diagnostics. The empty filename can be a virtual file
synthesized, for example, to hold an implicit attribute from clang
importer.

The cached diagnostics can correctly handle such filename now and
cached/replay those diagnostics.

rdar://141961161
2025-01-02 13:18:43 -08:00
Xi Ge
eb6933bbed Merge pull request #78337 from nkcsgexi/141850408
FineModuleTracing/CAS: move the computation of whether fine module trace will be emitted to an early stage.
2025-01-02 09:26:45 -08:00
Ian Anderson
ae753e61a1 [Driver][Frontend] Add a -nostdlibimport argument
Add a -nostdlibimport (analagous to clang's -nostdlibinc) to remove the SDK paths from the import search paths, but leave the toolchain paths.

rdar://139322299
2024-12-28 22:04:56 -05:00
Doug Gregor
d593442cc4 Add module trace information for strict memory safety
Extend the module trace format with a field indicating whether a given
module, or any module it depends on, was compiled with strict memory
safety enabled. This separate output from the compiler can be used as
part of an audit to determine what parts of Swift programs are built
with strict memory safety checking enabled.
2024-12-24 12:27:35 -08:00
Ian Anderson
cdb42c3535 [ClangImporter] clang's -iframework comes before builtin usr/local/include, but Swift's -Fsystem comes after
When Swift passes search paths to clang, it does so directly into the HeaderSearch. That means that those paths get ordered inconsistently compared to the equivalent clang flag, and causes inconsistencies when building clang modules with clang and with Swift. Instead of touching the HeaderSearch directly, pass Swift search paths as driver flags, just do them after the -Xcc ones.

Swift doesn't have a way to pass a search path to clang as -isystem, only as -I which usually isn't the right flag. Add an -Isystem Swift flag so that those paths can be passed to clang as -isystem.

rdar://93951328
2024-12-23 22:15:52 -08:00
Doug Gregor
5b90b8851a Generalize protocol conformance options spelled via attribute and incorporate @unsafe
Protocol conformances have a handful attributes that can apply to them
directly, including @unchecked (for Sendable), @preconcurrency, and
@retroactive. Generalize this into an option set that we carry around,
so it's a bit easier to add them, as well as reworking the
serialization logic to deal with an arbitrary number of such options.

Use this generality to add support for @unsafe conformances, which are
needed when unsafe witnesses are used to conform to safe requirements.
Implement general support for @unsafe conformances, including
producing a single diagnostic per missing @unsafe that provides a
Fix-It and collects together all of the unsafe witnesses as notes.
2024-12-20 23:16:23 -08:00
Doug Gregor
ba3e197841 Diagnose the combination of -Ounchecked with strict memory safety
Aligns with the current proposal and fixes rdar://127128995
2024-12-20 23:15:41 -08:00
Xi Ge
c8fa52b96d FineModuleTracing/CAS: move the computation of whether fine module trace will be emitted to an early stage.
CAS needs to determine if an output is needed very early (when computing supplementary outputs) in the pipeline so we can do caching and replays.

Resolves: rdar://141850408
2024-12-20 19:09:35 -08:00
Steven Wu
2d2dc39047 Merge pull request #78302 from cachemeifyoucan/eng/stevenwu/cache-replay-rewrite
[Caching][NFC] Unify the two cache replay code path
2024-12-20 15:02:18 -08:00
Slava Pestov
3f1491e2b4 Merge pull request #78298 from slavapestov/remove-one-way-bind
Sema: Remove -experimental-one-way-closure-params
2024-12-19 19:37:10 -05:00
Steven Wu
627c64f391 [Caching][NFC] Unify the two cache replay code path
There were two cache replay code exists, one for cache replay from
swift-frontend, the other for replay using C API from libSwiftScan. It
is easy to forget to update one copy when new specialized cache replay
logic is added for some output kinds. Now unify the replay logics to a
single location to avoid confusion. This is a rewrite of the existing
logic and NFCI.
2024-12-19 14:10:46 -08:00
Slava Pestov
bb55d9c59a Sema: Remove -experimental-one-way-closure-params 2024-12-19 13:14:11 -05:00
Allan Shortlidge
0288eaa3b7 AST: Introduce Decl::getSemanticAvailableAttrs().
This new attribute iterator returned from the query makes it simpler to
implement algorithms that need access to both the `AvailableAttr *` and its
corresponding `AvailabilityDomain`. This is also work towards making it
possible to return an optional `AvailabilityDomain` from
`Decl::getDomainForAvailableAttr()`.
2024-12-19 08:40:00 -08:00
Steven Wu
58d71379aa [Caching] Fix cache replay logics for makefile dependency file
Make sure the driver replay logics from C API can replay makefile
dependency file correctly.

rdar://141567785
2024-12-18 14:44:00 -08:00
Xi Ge
64e8f66e4e Merge pull request #78178 from nkcsgexi/fine-trace-opt-out
FineModuleTrace: add a blocklist action for skipping fine module tracing
2024-12-13 19:52:26 -08:00
Xi Ge
c965343f54 Frontend: add a flag to disable fine-grained module tracing 2024-12-13 16:07:15 -08:00
Meghana Gupta
8b1ecb8a71 Add new flag -sil-ownership-verify-all
This flag enables ownership verification after every transform.
2024-12-12 23:55:37 -08:00
Egor Zhdan
282f3b127b [cxx-interop] Support CxxStdlib overlay for libc++ on Linux
This teaches Swift to rebuild the CxxStdlib overlay module from its interface when using a C++ standard library that is not the platform default, specifically libc++ on Linux.

rdar://138838506
2024-12-10 14:19:59 +00:00
Richard Howell
8c49520d45 Merge pull request #77860 from rmaz/sdkrelative
Add IsSDKRelative field to ModuleInterfaceLayout
2024-12-06 12:40:14 -08:00
Egor Zhdan
7704534132 Merge pull request #77754 from swiftlang/egorzhdan/swiftinterface-no-cxx-flag
[cxx-interop] Do not emit C++ interop flag in textual interfaces
2024-12-06 14:30:21 +00:00
Richard Howell
d22a3bdba3 Merge branch 'main' into sdkrelative 2024-12-05 13:23:00 -08:00
Egor Zhdan
7ae2bebfe8 [cxx-interop] Do not emit C++ interop flag in textual interfaces
This makes sure that the compiler does not emit `-enable-experimental-cxx-interop`/`-cxx-interoperability-mode` flags in `.swiftinterface` files. Those flags were breaking explicit module builds. The module can still be rebuilt from its textual interface if C++ interop was enabled in the current compilation.

rdar://140203932
2024-12-05 19:25:09 +00:00
Steven Wu
0dcd87b53d Merge pull request #77934 from cachemeifyoucan/eng/PR-140822432
[Caching] Downgrade output loading error to a warning
2024-12-04 10:37:29 -08:00
Richard Howell
a007833cc0 Add IsSDKRelative field to ModuleInterfaceLayout
When serializing the module interface path of an interface that
is part of the SDK, we serialize relative to the SDK path. During
deserialization we need to know if a path was serialized relative
to the SDK or not. The existing logic assumes any relative path
has been serialized relative to the SDK, which makes it impossible
to compile modules from relative swiftinterface paths that are not
part of the SDK.

Update the swiftmodule file to include an attribute to show if the
path was serialized relative to the SDK or not, which is used
during deserialization to correctly reconstruct the interface path.
2024-12-04 08:14:59 -08:00
Ben Langmuir
e7c37655e4 [CAS] Cache symbol graph outputs
The symbol graph output from a module can contain an arbitrary number of
files, depending on what extensions it contains, so cache a list of
symbol graph files with their base name and contents so that they can be
replayed.

rdar://140286819
2024-12-03 13:11:19 -08:00
Steven Wu
36df6531bf [Caching] Downgrade output loading error to a warning
If the output loading failed after cache key lookup, treat that as a
warning and resume as if that is a cache miss. This is not a valid
configuration for builtin CAS but can happen for a remote CAS service
that failed to serve the output. Instead of failing, we should continue
to compile to avoid disruptive failures.

rdar://140822432
2024-12-03 12:43:31 -08:00
Saleem Abdulrasool
b660d20c85 Frontend: re-serialise static library status
When compiling the swiftmodule from the textual swift interface, ensure
that we re-serialise the static or dynamic nature of the module. This is
required for proper code generation where the static and dynamic linking
is material to symbolic references. This also opens the possibility of
optimizations on other platforms via internalisation of the symbols.

Fixes: #77756
2024-11-27 14:25:17 -08:00
Xi Ge
53557aa254 Merge pull request #77784 from swiftlang/fine-grained-variable
FineModuleTrace: use SWIFT_COMPILER_FINE_GRAINED_TRACE_PATH to indicate where the fine module trace should be emitted to. NFC
2024-11-21 16:59:42 -08:00
Allan Shortlidge
ad7383499b Merge pull request #77758 from tshortli/available-attr-conveniences
AST: `AvailableAttr` cleanup
2024-11-21 13:03:07 -08:00
Hamish Knight
23e3f5f5de Merge pull request #77666 from hamishknight/lets-try-this-again
[AST] Remove `ModuleDecl::addFile`
2024-11-21 20:15:58 +00:00
Xi Ge
77cbc19923 FineModuleTrace: use SWIFT_COMPILER_FINE_GRAINED_TRACE_PATH to indicate where the fine module trace should be emitted to. NFC 2024-11-21 11:50:36 -08:00
Allan Shortlidge
36230cd9c6 AST: Use an accessor to get the PlatformKind from an AvailableAttr. 2024-11-21 09:10:36 -08:00
Xi Ge
f845cc1f37 Merge pull request #77710 from swiftlang/atomic-append 2024-11-20 22:38:01 -08:00
Slava Pestov
8b61c9b442 Merge pull request #77723 from slavapestov/too-complex-stats
Sema: Progress towards an improved "too complex" check
2024-11-20 19:43:32 -05:00
Allan Shortlidge
a8fd7576dd Merge pull request #77741 from tshortli/always-warn-for-redundant-features
SE-0362: Only warn about features that are enabled by the language mode
2024-11-20 16:11:14 -08:00
Arnold Schwaighofer
c5463bdf92 Merge pull request #68985 from antoniofrighetto/feature/load-pass-plugin
[Driver][Frontend] Introduce `load-pass-plugin` option
2024-11-20 14:22:12 -08:00
Xi Ge
4a5d041932 FineModuleTrace: reposition the currently ObjC message specific trace files to be a more general purposed file for tracing fine-grained dependencies. NFC 2024-11-20 12:41:21 -08:00
Allan Shortlidge
d7b2d921e7 SE-0362: Only warn about features that are enabled by the language mode. 2024-11-20 11:36:13 -08:00
Slava Pestov
c8415aeac4 Sema: Record the trail step count in solver statistics
Also introduce two new frontend flags:

The -solver-scope-threshold flag sets the maximum number of scopes, which was
previously hardcoded to 1 million.

The -solver-trail-threshold flag sets the maximum number of trail steps,
which defaults to 64 million.
2024-11-20 13:46:19 -05:00
Xi Ge
51a68ecdd1 ModuleObjCTrace/CAS: compute objc trace file paths via the canoical supplementary output paths computation
CAS support in compiler relies on supplementary paths to decide the mapping between input and output files. Therefore, we
have to compute the paths of the module ObjC trace files in this canonical place to have CAS support for
this newly added ObjC message trace files.
2024-11-20 08:52:15 -08:00
Pavel Yaskevich
4a9d20d877 Merge pull request #77684 from xedin/switch-swiftinterface-version-to-use-Version
[Frontend] Switch `-interface-compiler-version` to `Version`
2024-11-19 08:56:58 -08:00
Pavel Yaskevich
7c8000b3a5 [Frontend] Switch -interface-compiler-version to Version
`SWIFT_COMPILER_VERSION` has more than 4 components and it's
easier to use `Version` API over `VersionTuple` as well.
2024-11-18 15:11:36 -08:00
Artem Chikin
77fde76150 Ignore in-package transitive dependencies when building from non-package textual interface
This change ensures that when loading some module dependency 'Bar' which has a package-only dependency on 'Foo', only the following clients attempt to resolve/load 'Foo':
- Source compilation with package-name equal to that of 'Bar'.
- Textual interface compilation of a *'package'* interface with package-name equal to that of 'Bar'.

Ensuring that the following kinds of clients do not attempt to resolve/load 'Foo':
- Source compilation with package-name different to that of 'Bar'
- Textual interface compilation of a public or private interface, regardless of package name.

This fixes the behavior where previously compilation of a Swift textual interface dependency 'X' from its public or private interface, with an interface-specified package-name, from a client without a matching package-name, resulted in a lookup of package-only dependencies of modules loaded into 'X'. This behavior is invalid if we are not building from the package textual interface, becuase the module dependency graph is defined by the package name of the source client, not individual module dependency package name. i.e. In-package module dependencies are resolved/loaded only if the parent source compile matches the package name.

Resolves rdar://139979180
2024-11-18 13:29:30 -08:00
Hamish Knight
4946c799af [AST] Remove ModuleDecl::addFile
Rather than exposing an `addFile` member on
ModuleDecl, have the `create` members take a
lambda that populates the files for the module.
Once module construction has finished, the files
are immutable.
2024-11-17 14:17:20 +00:00
Hamish Knight
e2ba36f7f4 Factor out ModuleDecl overload of import resolution
This resolves imports for the entire module.
2024-11-17 14:17:20 +00:00
Allan Shortlidge
e76bcac17d Frontend: Introduce -disable-upcoming-feature and -disable-experimental-feature.
To allow feature build settings to be composed more flexibly, allow an
`-enable-upcoming-feature` flag to be overridden by a
`-disable-upcoming-feature` flag. Whichever comes last on the command line
takes effect. Provide the same functionality for `-enable-experimental-feature`
as well.

Resolves rdar://126283879.
2024-11-15 18:20:28 -08:00
Doug Gregor
cb6e3db847 Merge pull request #77579 from DougGregor/revert-abi-comments-printing
Revert "Emit mangled names for public symbols into the .swiftinterface"
2024-11-13 02:24:14 -08:00
Doug Gregor
34c020d5f4 Revert "Emit mangled names for public symbols into the .swiftinterface"
This reverts commit 0aff85ced7.
2024-11-12 22:38:47 -08:00
Allan Shortlidge
67c59279a4 Frontend: Rename -dump-type-refinement-contexts to -dump-availability-scopes. 2024-11-12 11:34:25 -08:00
Allan Shortlidge
239720897a AST: Rename TypeRefinementContext to AvailabilityScope. 2024-11-12 11:34:25 -08:00