Commit Graph

2184 Commits

Author SHA1 Message Date
Doug Gregor
b9f00ef923 Warn about the use of internal bridging headers without library evolution
It's very, very easy to make a mistake that will cause broken
serialized modules. Until that's no longer true, at least tell folks
that they are heading into uncharted waters, as we do with
`@_implementationOnly` imports.
2025-09-19 16:49:22 -07:00
Doug Gregor
2383d7ab2d Introduce "-internal" variant of bridging header import flags
The flags "-import-bridging-header" and "-import-pch" import a bridging
header, treating the contents as a public import. Introduce
"internal-" variants of both flags that provide the same semantics,
but are intended to treat the imported contents as if they came in
through an internal import. This is just plumbing of the options for
the moment.
2025-09-19 16:49:11 -07:00
Doug Gregor
ffa6d65f12 [Options] Make -import-bridging-header the canonical spelling instead of -import-objc-header
This command-line option hasn't been Objective-C specific ever, really.
Make the language-independent spelling the primary one to make that
more obvious.
2025-09-19 16:49:11 -07:00
Doug Gregor
5a46664954 Merge pull request #84359 from DougGregor/diagnose-untyped-throws-in-embedded 2025-09-18 06:11:55 -07:00
Doug Gregor
f2ffd3771e [Embedded] Enable Embedded Swift restrictions diagnostics (as warnings) in embedded builds
These restrictions will generally manifest as failures of various forms
later in the compiler process. Enable the diagnostics to give earlier
feedback to help stay within the bounds of Embedded Swift.

Fixes rdar://121205043.
2025-09-17 13:09:48 -07:00
Doug Gregor
56f60635b1 Merge pull request #84328 from DougGregor/coroframealloc-backdeploy 2025-09-16 20:15:50 -07:00
Doug Gregor
f7264e327f [IRGen] Only use a stub for swift_coroFrameAlloc when we need it
swift_coroFrameAlloc was introduced in the Swift 6.2 runtime. Give it
the appropriate availability in IRGen, so that it gets weak
availability when needed (per the deployment target). Then, only
create the stub function for calling into swift_coroFrameAlloc or
malloc (when the former isn't available) when we're back-deploying to
a runtime prior to Swift 6.2. This is a small code size/performance
win when allocating coroutine frames on Swift 6.2-or-newer platforms.

This has a side effect of fixing a bug in Embedded Swift, where the
swift_coroFrameAlloc was getting unconditionally set to have weak
external linkage despite behind defined in the same LLVM module
(because it comes from the standard library).

Fixes rdar://149695139 / issue #80947.
2025-09-16 10:51:12 -07:00
Allan Shortlidge
9067051c29 Frontend: Require explicit language mode when emitting swiftinterfaces.
If a .swiftinterface file does not include an explicit `-language-mode` option
(or its predecessor `-swift-version`) and needs to be built as a dependency of a
client compilation, then the invocation to build the module from interface
would end up inheriting the language mode that the client code is built with.
This can result in spurious type checking diagnostics or even mis-compilation.
To ensure that a module interface is always built using the language mode that
its source code was originally built with, require an explicit `-language-mode`
option when emitting swiftinterface files.

In https://github.com/swiftlang/swift/pull/84307 this diagnostic was downgraded
to a warning. The failures it caused in PR testing should now be resolved.

Resolves rdar://145168219.
2025-09-16 10:25:14 -07:00
Allan Shortlidge
e2c8235a2c Frontend: Temporarily downgrade 'error_module_interface_requires_language_mode'.
Downgrade the new error in https://github.com/swiftlang/swift/pull/84244 to a
warning.

The PR smoke test build is using a different build system that is failing to
pass `-swift-version` arguments when building various stdlib modules. That
needs to be fixed, but for now we also need to unblock CI.
2025-09-15 14:10:24 -07:00
Allan Shortlidge
cfe9f90347 Merge pull request #84244 from tshortli/require-swift-version-in-module-interfaces
Frontend: Require `-language-mode` option when emitting swiftinterfaces
2025-09-15 10:08:23 -07:00
Hamish Knight
8e460d1e6c Merge pull request #84225 from hamishknight/access-noted
Requestify the loading of access notes
2025-09-13 12:06:43 +01:00
Allan Shortlidge
13d61b0709 Frontend: Require -language-mode option when emitting swiftinterfaces.
If a `.swiftinterface` file does not include an explicit `-language-mode`
option (or its predecessor `swift-version`) and needs to be built as a
dependency of a client compilation, then the invocation to build the module
from interface would end up inheriting the language mode that the client code
is built with. This can result in spurious type checking diagnostics or even
mis-compilation. To ensure that a module interface is always built using the
language mode that its source code was originally built with, require an
explicit `-language-mode` option when emitting swiftinterface files.

Resolves rdar://145168219.
2025-09-12 09:10:23 -07:00
Hamish Knight
6ef8f45659 NFC: Move AccessNotesPath to LangOptions 2025-09-11 16:54:08 +01:00
Chris McGee
e71009b3ff Add symbol graph option for skipping inherited docs 2025-09-10 19:01:29 -04:00
Chris McGee
1380a3e2a9 Merge pull request #83044 from cmcgee1024/add_more_symbol_graph_opts_swiftc
Add pretty print and skip synthesized members to the frontend options
2025-09-09 15:24:27 -04:00
Doug Gregor
66a730b638 [Embedded] Remove -mergeable-symbols
This option is no longer necessary, because we emit weak definitions
for any imported modules. Fixes rdar://158364032.
2025-09-08 17:44:51 -07:00
Chris McGee
b8ab5d548d Set driver options for frontend too and propagate them in compiler invocation 2025-09-08 16:41:11 -04:00
Arnold Schwaighofer
df5a8cd3cc Add a flag to annotate all functions with the optremark (@_assemblyVision) attribute
rdar://159291169
2025-08-29 09:26:13 -07:00
Steven Wu
94f7c5471a Merge pull request #83878 from cachemeifyoucan/eng/PR-134363755
[Caching] Do not infer default on disk cas path when parsing options
2025-08-26 12:36:51 -07:00
Steven Wu
492f5ab611 [Caching] Do not infer default on disk cas path when parsing options
Currently, swift-frontend will always try to infer a default CASPath if
no `-cas-path` is passed. The function `getDefaultOnDiskCASPath` called
to infer the default path can fatal error in some environment where no
caching directory and home directory, no matter if caching is used or
not.

Remove the inferred path during parsing since that is not strictly
necessary. If caching is enabled and no CASPath is passed, error can be
issued during CAS construction time.

rdar://158899187
2025-08-22 12:32:24 -07:00
Michael Gottesman
bfecaa357f [frontend] Expose via a LangOption whether or not the compiler is compiling for a triple that supports AArch64 TBI.
Just breaking down layers of a larger patch to make it easier to review.
2025-08-21 12:52:49 -07:00
Chris McGee
eed54bb4b0 Reduce change to compiler invocation and remove options from frontend 2025-08-12 12:04:02 -04:00
Evan Wilde
3fcca83d07 Refactor getMinPlatformVersion
The definitions of how version numbers were extracted from target
triples split between the minimum platform version and for determining
the minimum inlining version.

This resulted in inlinable and transparent functions not being imported
correctly on non-Apple platforms where the version number is retained as
part of the target triple.
Specifically, `_checkExpectedExecutor` was found in the module, but
didn't have the appropriate availability version assigned, resulting in
it failing to import and the compiler silently omitting the check in
SILGen when compiling for FreeBSD.

This patch refactors the implementation of `getMinPlatformVersion` into
a separate function that is used in both places so that they cannot get
out of sync again.

Note: This changes how Windows is handled. getMinPlatformVersion
returned an empty version number for Windows, while the availability
implementation returned the OS version number. This makes both
consistently return the OS version number.
2025-08-08 15:10:04 -07:00
Chris McGee
6a38bbe73d Qualify the skip synthesized members option with symbol graph for the compiler frontend
Rollback the additional usages of the new options and test cases
2025-08-07 15:44:33 -04:00
Hamish Knight
fb7f2d0ff2 [CS] Limit the number of chained @dynamicMemberLookup lookups
Set an upper bound on the number of chained lookups we attempt to
avoid spinning while trying to recursively apply the same dynamic
member lookup to itself.

rdar://157288911
2025-08-01 19:08:04 +01:00
Chris McGee
26168f57cc Create tests for the two new symbol graph options
Add options to the driver and frontend options
2025-07-30 10:24:56 -04:00
Doug Gregor
436e965b66 [SE-0466] Under main actor default isolation, explicit nonisolated is not special
Given an explicitly-nonisolated type such as

    nonisolated struct S { }

all extensions of S were also being treated as nonisolated. This meant
that being implicitly nonisolated (i.e., when you're using nonisolated
default isolation) was different from explicitly-writing nonisolated,
which is unfortunate and confusing. Align the rules, such that an
extension of S will get default isolation:

    extension S {
      func f() { } // @MainActor if we're in main actor default isolation
    }
2025-07-25 09:46:34 -07:00
Artem Chikin
b60bc39ee5 [APINotes] Add support for handling Clang modules carrying all versions of APINotes
Controlled from Swift with '-version-independent-apinotes', which, for the underlying Clang invocation enables '-fswift-version-independent-apinotes', results in PCMs which aggregate all versioned APINotes wrapped in a 'SwiftVersionedAttr', with the intent to have the client pick and apply only those that match its current Swift version, discarding the rest.

This change introduces the configuration flags for this mode as well as the corresponding logic at the beginning of `importDeclImpl` to canonicalize versioned attributes, i.e. select the appropriate attributes for the current target and discard the rest.
2025-07-24 09:08:31 -07:00
Kuba Mracek
6ec280d4e1 [ClangImporter] Skip importing values for CGFloat typedefs on top of CGFloats direct 2025-07-22 10:10:15 -07:00
Slava Pestov
bb4f61e97b Merge pull request #83141 from slavapestov/fix-rdar82992151
Sema: Improve the infinite opaque return type check
2025-07-19 09:30:17 -04:00
Slava Pestov
4eaa7e3b47 AST: Add -max-substitution-count= and -max-substitution-depth= frontend flags 2025-07-18 20:03:03 -04:00
Slava Pestov
f909ca6921 Frontend: Clean up integer option parsing in ParseLangArgs() 2025-07-18 20:03:03 -04:00
Artem Chikin
bd14089551 Warn on multiple '-swift-module-file' options 2025-07-18 10:05:55 -07:00
Artem Chikin
e08b78226c [Dependency Scanning] Consider '-swift-module-file' inputs when looking for dependencies
Previously this flag was only used to pass explicit dependencies to compilation tasks. This change adds support for the dependency scanner to also consider these inputs when resolving dependencies.

Resolves https://github.com/swiftlang/swift-driver/issues/1951
2025-07-18 09:48:02 -07:00
Gábor Horváth
4b9ef8c53c Merge pull request #83130 from Xazax-hun/objc-configurable-from-frontend
[cxx-interop] Configure requires ObjC from frontend option
2025-07-18 02:29:48 +01:00
Gabor Horvath
4b64abdc45 [cxx-interop] Configure requires ObjC from frontend option
We sometimes don't have the information in the modulemaps whether a
module requires ObjC or not. This info is useful for reverse interop.
This PR introduces a frontend flag to have a comma separated list of
modules that we should import as if they had "requires ObjC" in their
modulemaps.
2025-07-17 21:29:50 +01:00
Steven Wu
fbfc7a6f71 Merge pull request #82745 from sina-mahdavi/sina-mahdavi/new-scanner-prefix-map-option
Add `-scanner-prefix-map-paths` to the frontend
2025-07-17 11:35:06 -07:00
Sina Mahdavi
03843475c1 Add -scanner-prefix-map-paths to the frontend 2025-07-15 10:46:50 -07:00
Chris McGee
b27bc18d36 Add pretty print and skip synthesized members options to swiftc 2025-07-14 16:09:55 -04:00
Allan Shortlidge
c6dad96492 Make LayoutPrespecialization a baseline feature instead of experimental.
Since LayoutPrespecialization has been enabled by default in all compiler
invocations for quite some time, it doesn't make sense for it to be treated as
experimental feature. Make it a baseline feature and remove all the
checks for it from the compiler.
2025-07-10 11:25:28 -07:00
Egor Zhdan
569ca005e8 Merge pull request #82680 from swiftlang/egorzhdan/enable-c-frt
[cxx-interop] Enable foreign reference types in C interop
2025-07-07 19:42:06 +01:00
Egor Zhdan
9178af3ec7 [cxx-interop] Enable foreign reference types in C interop
Most of the logic for C++ foreign reference types can be applied to C types as well. Swift had a compiler flag `-Xfrontend -experimental-c-foreign-reference-types` for awhile now which enables foreign reference types without having to enable C++ interop. This change makes it the default behavior.

Since we don't expect anyone to pass `experimental-c-foreign-reference-types` currently, this also removes the frontend flag.

rdar://150308819
2025-07-01 18:46:22 +01:00
Pavel Yaskevich
2957da3591 [ConstraintSystem] Disable performance hacks by default
This also changes the flag to `-enable-constraint-solver-performance-hacks`.
2025-06-27 23:43:09 -07:00
Slava Pestov
34253a8606 Merge pull request #82506 from slavapestov/warn-long-expression-type-checking
Sema: Fix the -warn-long-expression-type-checking flag
2025-06-27 01:10:25 -04:00
Slava Pestov
84d1d115e1 Sema: Change -solver-memory-threshold into a frontend flag for consistency with the others 2025-06-25 22:07:23 -04:00
Argyrios Kyrtzidis
d385e8c87a Merge pull request #81792 from sina-mahdavi/sina-mahdavi/fix-llvm-prefix-mapping-calls
fix calls to llvm prefix mapping functions to use space-separated opt…
2025-06-25 13:19:21 -07:00
Sina Mahdavi
7090b7e145 fix calls to llvm prefix mapping functions to use space-separated option format 2025-06-24 13:32:55 -07:00
Alex Azarov
b72cda2cfb [Diagnostics] Fix typo in 'overridden' warning message and identifier 2025-06-24 13:41:36 +02:00
Evan Wilde
7f3fdb322d Merge pull request #82355 from etcwilde/ewilde/fbsd-cxx-interop-runtime
FreeBSD: Link C++ runtimes when Cxx interop is enabled
2025-06-23 14:21:02 -07:00
Pavel Yaskevich
286f975c29 Merge pull request #82320 from xedin/hide-solver-hacks-behind-a-flag
[ConstraintSystem] Guard all the performance hacks with a flag
2025-06-20 00:12:16 -07:00