Commit Graph

1761 Commits

Author SHA1 Message Date
Allan Shortlidge
eb4b049c20 Basic: Fix -print-supported-features.
The check to only include experimental features that are available in
production was inverted.

Resolves rdar://158273047.
2025-08-13 21:33:11 -07: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
Anthony Latsis
90f9fce339 Merge pull request #82665 from swiftlang/jepa4
Bridging: Bridge some basic classes like `swift::SourceLoc` directly
2025-07-16 08:27:12 +01:00
Anthony Latsis
5620abbad8 Bridging: Bridge swift::CharSourceRange directly 2025-07-15 21:34:48 +01:00
Anthony Latsis
6eb5d7d857 Bridging: Bridge swift::SourceLoc directly 2025-07-15 21:33:06 +01:00
Anthony Latsis
06a5670c8f Basic: Untie swift::SourceLoc from llvm::SMLoc
Storing a `llvm::SMLoc` is a superfluous indirection, and getting rid of
it enables us to unconditionally import `SourceLoc` into Swift.
2025-07-11 18:48:42 +01:00
Allan Shortlidge
0a86d007e8 Basic: Stop enabling NoncopyableGenerics, BorrowingSwitch, and MoveOnlyPartialConsumption.
These features are baseline features and therefore are considered to be
implicitly enabled. They don't need to be explicitly enabled or queried for in
any part of the compiler.
2025-07-10 12:17:46 -07:00
Anthony Latsis
faa7f67960 Merge pull request #82165 from AnthonyLatsis/jepa
{AST,Basic}Bridging: Use  `<swift/bridging>` and try directly bridging one of our enums
2025-06-17 04:52:41 +01:00
Cyndy Ishida
64168edbf5 [Modules] Allow implicit conversions when loading interfaces with invalid os versions (#82228)
Initially, the compiler rejected building dependencies that contained OS
versions in an invalid range. However, this happens to be quite
disruptive, so instead allow it and request that these versions be
implicitly bumped based on what `llvm::Triple::getCanonicalVersionForOS`
computes.

resolves: rdar://153205856
2025-06-16 12:46:32 -07:00
Anthony Latsis
106d5f4461 {AST,Basic}Bridging: Use SWIFT_COMPUTED_PROPERTY 2025-06-16 19:11:32 +01:00
Allan Shortlidge
aca604660f AST/Sema: Make MemberImportVisibility a migratable feature.
The migration to `MemberImportVisibility` can be performed mechanically by
adding missing import declarations, so offer automatic migration for the
feature.

Resolves rdar://151931597.
2025-05-30 15:34:08 -07:00
Allan Shortlidge
522fee4a14 Basic: Fix a bug in LangOptions::hasFeature().
Don't skip checking if a feature is enabled for migration when the feature also
has an associated language version.
2025-05-30 15:34:08 -07:00
Hamish Knight
6d3455f52b Merge pull request #81849 from hamishknight/message-in-an-error
[Basic] Always dump message to stderr in `_abortWithMessage`
2025-05-30 20:53:37 +01:00
Ben Barham
b0d5e0e8f1 Merge pull request #81697 from bnbarham/use-toolchain-version
Add the distribution tag to `-print-target-info`
2025-05-30 09:51:03 -07:00
Hamish Knight
b9b2cb25c2 [Basic] Always dump message to stderr in _abortWithMessage
This allows it to be seen while e.g attached with a debugger.
2025-05-30 16:08:37 +01:00
Ben Barham
3c098782b4 Add the distribution tag to -print-target-info
Ideally this would also update the `--version` output to be overridden
by `SWIFT_TOOLCHAIN_VERSION`, but unfortunately various tools rely on
the current format (eg. swift-build).
2025-05-28 17:29:17 -07:00
Anthony Latsis
e7b2bc0d08 Basic: Adjust condition for include after macro removal in upstream LLVM
`HAVE_SYS_RESOURCE_H` was removed in
https://github.com/llvm/llvm-project/pull/123288, so this header is no
longer included at this particular location on rebranch, which breaks
the Linux build, where it is not transitively included either.

Use the same condition as in the use site
(`getChildrenMaxResidentSetSize`) instead.

Also, don't wrap `HAVE_GETRUSAGE` in `defined()` in case it does get
defined to 0.
2025-05-28 23:02:15 +01:00
Doug Gregor
32267f4971 Finish comment 2025-05-22 12:15:53 +01:00
Doug Gregor
414adb55ca Add optional language features to the supported features output
Optional language features don't have a specific "-enable-*" flag, because
they're rare and don't fit the same upcoming/experimental distinction. Add
a flag_name field to provide the flag name as well.
2025-05-22 11:07:13 +01:00
Doug Gregor
7f2649ff33 Add the set of diagnostic categories to each migratable feature
The name of a migratable feature might differ from the names of the
diagnostic groups containing the diagnostics that are used to drive
migration for that feature. Provide the set of diagnostic categories
that are associated with each migratable feature as part of the
supported features list.
2025-05-22 11:07:13 +01: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
Hamish Knight
be8604959e [Basic] Switch ASSERT and friends to _abortWithMessage
Ensure the message gets printed to the pretty stack trace, allowing
it to be picked up by CrashReporter.
2025-05-19 20:55:01 +01:00
Hamish Knight
a6e94ab0bd [Basic] Fallback to dumping to stderr when backtracing is disabled
Make sure we still output the error message when pretty backtracing
is disabled.
2025-05-19 20:55:01 +01:00
Hamish Knight
d672f750e7 [Basic] Rename abortWithPrettyStackTraceMessage to ABORT
Turn it into a wrapping macro that includes the file location, and
move into `Assertions.h`.
2025-05-19 20:55:01 +01:00
Hamish Knight
92641253f7 [Basic] NFC: Remove ASSERT_help from header
It's not clear this is a useful utility to expose since it will only
print the message once.
2025-05-19 20:55:01 +01:00
Hamish Knight
d46aec9f00 [Basic] Handle multiline strings in abortWithPrettyStackTraceMessage
Improve the formatting by indenting to match the rest of the
pretty stack trace.
2025-05-19 20:55:01 +01:00
Rintaro Ishizaki
a0aad5c0b0 Merge pull request #81517 from rintaro/macros-wait-rdar150474701
[Macros] Mitigate plugin process 'wait' failure
2025-05-15 11:06:18 -07:00
Rintaro Ishizaki
05948bcb93 [Macros] 'close' unnecessary file descriptors in plugin process
Close all the pipe file descriptors in the child process after duping
them to the standard I/O. This is not necessary but it's a good thing to
do anyway.
2025-05-14 12:54:26 -07:00
Hamish Knight
691b8c874c [Basic] Upgrade assert in findBufferContainingLocInternal
Almost all clients would crash for an invalid location, let's
always assert.
2025-05-14 11:15:42 +01:00
Pavel Yaskevich
085078dd8a [Feature] Rename Feature APIs from adoption to migration 2025-04-28 11:52:46 -07:00
Pavel Yaskevich
2a479acf9e [Feature] NFC: Rename ADOPTABLE_ with MIGRATABLE_ to match the proposal 2025-04-28 10:42:22 -07:00
Pavel Yaskevich
92184584eb Merge pull request #80981 from xedin/supported-features-enabled-in-tweak
[Frontend] SupportedFeatures: print "enabled_in" as a string
2025-04-23 00:18:10 -07:00
Pavel Yaskevich
4909b9baed [Frontend] SupportedFeatures: print "enabled_in" as a string
This is future-proofing the version part of the upcoming
feature. There currently no features that require that
but it's possible that they'd be added in the future.
2025-04-22 00:09:28 -07:00
3405691582
d54e67cae1 Use LLVM-default spellings for amd64 on OpenBSD.
OpenBSD spells the common 64-bit x86 architecture as amd64, while LLVM
defaults it to x86_64. A while back we tried to stick with the amd64
spelling, but this was difficult to make the change properly and
consistently. A while back we decided to just stick with LLVM spellings,
but there are a few minor cases missing.

This change is necessary for properly finding swiftrt.o.
2025-04-18 15:57:02 -04:00
Hamish Knight
3c302349ee Merge pull request #80853 from hamishknight/macro-async-warning 2025-04-18 16:22:28 +01:00
Pavel Yaskevich
18703d64d6 [Frontend] Rework -emit-supported-features mode into -emit-supported-arguments
The "featues" part was never actually implemented and Swift Driver
is replying on information about arguments, so instead of removing
this mode, let's scope it down to "arguments" to be deprecated in
the future.
2025-04-17 12:33:23 -07:00
Pavel Yaskevich
55bd906906 [Frontend] Add -print-supported-features option
This is a replacement for `-emit-supported-features` that prints
all of the upcoming/experimental features supported by the compiler
with some additional meta information in JSON format to stdout.
2025-04-16 16:34:47 -07:00
Hamish Knight
14bd41159e NFC: Abstract away the use of '7' to represent the next language mode
Introduce `Version::getFutureMajorLanguageVersion` to make it easier
to find clients that will need to be updated once we have a new
language mode.
2025-04-16 19:22:52 +01:00
Steven Wu
56778b7209 [BlockList] Fix a crash if block is empty
Check if the root node is a mapping node before iterating. This fixes a
crash when the YAML file is not the expected format.
2025-04-10 12:46:09 -07:00
Michael Gottesman
77a86a525b Merge pull request #79891 from gottesmm/pr-9df6772bb44656cbd85cad72ee5c3637caab8956
Make Feature a struct enum so we can put methods on it.
2025-04-07 10:32:23 -07:00
Hamish Knight
8834f6c4c7 Merge pull request #80496 from hamishknight/message-in-a-crash-log
[Mangler] Include verification errors in the crash log
2025-04-07 17:03:18 +01:00
Michael Gottesman
3ff9463957 Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.
2025-04-05 10:08:29 +01:00
Doug Gregor
e49afc8797 Merge pull request #80389 from 3405691582/nobtcfi
Add a build flavor to opt-out of BTCFI on OpenBSD.
2025-04-03 13:29:04 -07:00
Hamish Knight
abf8a81a18 [Mangler] Use abortWithPrettyStackTraceMessage for verification errors
Make sure we include the verification error in the crash log.
2025-04-03 16:03:55 +01:00
Hamish Knight
54023f85e7 [Basic] Introduce abortWithPrettyStackTraceMessage
Introduce a convenience for aborting while printing a given message
to a frame of the pretty stack trace. Use this in the existing places
where we're currently doing this.
2025-04-03 15:59:48 +01:00
3405691582
a341ce5570 Add a build flavor to opt-out of BTCFI on OpenBSD.
To work-around #80059, we need to stop return address signing and
opt-out of BTCFI enforcement via enabling a platform linker option.

We don't want to completely undo the BTCFI work in the rare case that
we later figure out how to properly address the above issue, or allow
users who might want to benefit from BTCFI enforcement and won't use
Concurrency. To do this, condition the existing BTCFI flag enforcement
into a configuration option that defaults to off for now.

Because the new swift-driver needs to "know" whether the frontend is
configured to opt-out or not, and since the new driver communicates with
the frontend via the target info JSON to begin with, we add a field
that emits the build flavor to signal the right behavior.
2025-03-29 10:47:23 -04:00
Hamish Knight
b63ed2bf01 Merge pull request #80339 from hamishknight/macroscope
[ASTScope] Re-enable `checkSourceRangeBeforeAddingChild`
2025-03-29 00:36:50 +00:00
Hamish Knight
a0c3632f95 [Basic] Bail in isBeforeInSource if root source files mismatch
This case is currently being hit for code completion, possibly due
to an invalid ASTScope node range. Let's bail in non-asserts builds
rather than crashing when attempting to access the generated source
info.

rdar://134522702
2025-03-27 21:22:02 +00:00
Hamish Knight
801079bd94 [Basic] Use start loc for original source range in isBeforeInSource
Given we're working with CharSourceRanges, the end location is past
the end of the actual range, so when checking if e.g a function body
macro is contained within the function decl, we fail since the end
location is past the closing `}`. Check the start location instead,
which is part of the range.
2025-03-27 11:31:24 +00:00
Michael Gottesman
13c9e9c994 [gardening] Remove this-> from LangOpts that was added by mistake. 2025-03-17 15:37:15 -07:00