Commit Graph

2213 Commits

Author SHA1 Message Date
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
Slava Pestov
5987bbf966 Merge pull request #82321 from slavapestov/rqm-fixes
RequirementMachine: Add more limits to catch runaway computation, and fix a bug
2025-06-18 23:00:38 -04:00
Evan Wilde
91aa7b88f5 FreeBSD: Autolink C++ runtime
This hooks up the autolink mechanism to link the C++ runtime when C++
interop is enabled on FreeBSD.
2025-06-18 16:16:14 -07:00
Slava Pestov
7f8175b3da RequirementMachine: Add two more completion termination checks for concrete type requirements
The concrete nesting limit, which defaults to 30, catches
things like A == G<A>. However, with something like
A == (A, A), you end up with an exponential problem size
before you hit the limit.

Add two new limits.

The first is the total size of the concrete type, counting
all leaves, which defaults to 4000. It can be set with the
-requirement-machine-max-concrete-size= frontend flag.

The second avoids an assertion in addTypeDifference() which
can be hit if a certain counter overflows before any other
limit is breached. This also defaults to 4000 and can be set
with the -requirement-machine-max-type-differences= frontend flag.
2025-06-17 17:51:25 -04:00
Pavel Yaskevich
833b6b19e9 [Frontend] Remove -disable-solver-shrink option
It's folded into a more general "disable performance hacks" one.
2025-06-17 13:52:28 -07:00
Artem Chikin
a78ee29692 [Dependency Scanning] Remove obsolete placeholder module concept
This was used a long time ago for a design of a scanner which could rely on the client to specify that some modules *will be* present at a given location but are not yet during the scan. We have long ago determined that the scanner must have all modules available to it at the time of scan for soundness. This code has been stale for a couple of years and it is time to simplify things a bit by deleting it.
2025-06-12 08:32:25 -07:00
Saleem Abdulrasool
083cb114b3 Merge pull request #82065 from compnerd/import-shims
ClangImporter: import SwiftShims properly for static linking
2025-06-06 15:05:04 -07:00
Saleem Abdulrasool
43b2b596fe ClangImporter: import SwiftShims properly for static linking
When building against the static standard library, we should define
`SWIFT_STATIC_STDLIB` to indicate to the shims that the declarations
should be giving hidden visibility and default DLL storage. This is
required to ensure that these symbols are known to be `dso_local` when
compiling to avoid an unnecessary look up through the PLT/GOT or the
indirection through the synthesized `__imp_` symbol and the IAT. This
corrects a number of incorrect code generation cases on Windows with the
static standard library.
2025-06-06 09:35:51 -07:00
Steven Wu
8d5d758676 [CAS] Allow uncached job from CAS based dependency scanning
Create a path that swift-frontend can execute an uncached job from
modules built with CAS based explicit module build. The new flag
-import-module-from-cas will allow an uncached build to load module
from CAS, and combined with source file from real file system to build
the current module. This allows quick iterations that bypasses CAS,
without full dependency scanning every time in between.

rdar://152441866
2025-06-05 14:55:42 -07:00
Erik Eckstein
c02bc2d421 IRGen: add an option -min-valid-pointer-value to override the target's LeastValidPointerValue
The LeastValidPointerValue is hard-coded in the runtime.
Therefore this option is only available in embedded swift - which doesn't have a runtime.

rdar://151755654
2025-06-03 09:27:35 +02:00
Artem Chikin
5b501ad2c5 Hard-code the 'Darwin' module as having been built without C++ interop
Textual interfaces for 'Darwin' built with recent compilers specify that it is built witout C++ interop enabled. However, to ensure compatibility with versions of the 'Darwin' module built with older compilers, we hard-code this fact. This is required to break the module cycle that occurs when building the 'Darwin' module with C++ interop enabled, where the underlying 'Darwin' clang module depends on C++ standard library for which the compiler brings in the 'CxxStdlib' Swift overlay, which depends on 'Darwin'.
2025-06-02 14:16:57 -07:00
Ian Anderson
1197e2ef2e [Frontend][test] Minor changes from "-nostdimport and -nostdlibimport should remove the default framework search paths"
Put the SDK path in a SmallString instead of a StringRef for ease of downstream merging.
Simplify the command lines for the search path test.
2025-05-23 23:02:51 -07:00
Doug Gregor
abad2fae0f Make the optional feature StrictMemorySafety migratable
This feature is essentially self-migrating, but fit it into the
migration flow by marking it as migratable, adding
`-strict-memory-safety:migrate`, and introducing a test.
2025-05-22 11:07:13 +01:00
Allan Shortlidge
98aac28a3f Frontend: Suppress some unsupported option warnings when verifying interfaces.
The following warnings get emitted every time we build the compiler libraries
that are implemented in Swift:

```
<unknown>:0: warning: ignoring -allow-non-resilient-access (overriden by -compile-module-from-interface or -typecheck-module-from-interface)
<unknown>:0: warning: ignoring -package-cmo (requires -allow-non-resilient-access)
<unknown>:0: warning: ignoring -allow-non-resilient-access (overriden by -compile-module-from-interface or -typecheck-module-from-interface)
<unknown>:0: warning: ignoring -package-cmo (requires -allow-non-resilient-access)
```

These warnings are generated because `-allow-non-resilient-access` and
`-package-cmo` are being passed in with `-Xfrontend` and are therefore copied
into the interface verification jobs, even though they don't apply. Suppress
the warnings under these circumstances; they aren't going to help anyone
understand a problem, so they're just spam.

Resolves rdar://151616909.
2025-05-19 09:02:13 -07:00
Steven Wu
3c81c1ca9f [Caching] Remove CASFS clang module implemenation
Remove the CASFS based clang module implemenation as it is not longer
used.
2025-05-14 09:35:03 -07:00
Steven Wu
7025bf816b Merge pull request #81264 from cachemeifyoucan/eng/PR-148752988
[Caching] Reduce the number of cas ID passed on frontend commandline
2025-05-13 16:15:29 -07:00
Steven Wu
201e4faea7 [Caching] Reduce the number of cas ID passed on frontend commandline
Using IncludeTree::FileList to concat the include tree file systems that
are passed on the command-line. This significantly reduce the
command-line size, and also makes the cache key computation a lot
faster.

rdar://148752988
2025-05-13 09:20:13 -07:00
Ian Anderson
a6e517e943 [Driver][Frontend] -nostdimport and -nostdlibimport should remove the default framework search paths
-nostdimport and -nostdlibimport only remove the toolchain and usr/lib/swift search paths, and they leave the framework search paths intact. That makes it impossible to get a fully custom SDK environment. Make their behavior match clang's -nostdinc/-nostdlibinc behavior: treat framework and non-framework paths the same. In other words, -nostdinc removes *all* compiler provided search paths, and -nostdlibinc removes *all* SDK search paths.

Rename SkipRuntimeLibraryImportPaths to SkipAllImportPaths, and ExcludeSDKPathsFromRuntimeLibraryImportPaths to SkipSDKImportPaths to reflect their updated behavior.

Move the DarwinImplicitFrameworkSearchPaths handling from SearchPathOptions to CompilerInvocation, where RuntimeLibraryImportPaths is managed. Rename it to just ImplicitFrameworkSearchPaths, and filter for Darwin when it's set up so that all of the clients don't have to do Darwin filtering themselves later.

rdar://150557632
2025-05-12 22:33:48 -07:00
Anthony Latsis
4f4141fea8 Frontend: Obsolete -fixit-all and -emit-fixits-path
With `ARCMigrate` and `arcmt-test` removed from clang in
https://github.com/llvm/llvm-project/pull/119269 and the new code
migration experience under way (see
https://github.com/swiftlang/swift-evolution/pull/2673), these options
are no longer relevant nor known to be in use. They were introduced
long ago to support fix-it application in Xcode.

For now, turn them into a no-op and emit a obsoletion warning.
2025-05-07 02:30:30 +01:00
Pavel Yaskevich
1ba077d922 [Feature] Switch migration postfix from :adoption to :migrate 2025-04-28 13:08:24 -07:00
Pavel Yaskevich
085078dd8a [Feature] Rename Feature APIs from adoption to migration 2025-04-28 11:52:46 -07:00
Arnold Schwaighofer
7d72959028 Merge pull request #81037 from aschwaighofer/irgen_coroFrameAlloc_cleanup
IRGen: Centralize logic that decides whether the platform suppports typed malloc
2025-04-24 13:21:16 -07:00