Commit Graph

1737 Commits

Author SHA1 Message Date
Owen Voorhees
ff41798687 Update OS versions requiring stdlib OS rpaths 2025-09-22 11:52:44 -07:00
Doug Gregor
09dbbea774 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.

(cherry picked from commit 414adb55ca)
2025-06-04 00:20:41 -07:00
Allan Shortlidge
c99b19e450 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-06-02 07:27:41 -07:00
Allan Shortlidge
0d6a8c8c43 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-06-02 07:27:33 -07:00
Ben Barham
1f53e700fa 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).

(cherry picked from commit 3c098782b4)
2025-05-30 10:04:40 -07:00
Doug Gregor
589fd330e0 Finish comment
(cherry picked from commit 32267f4971)
2025-05-28 16:15:20 -07:00
Doug Gregor
d0cb137778 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.

(cherry picked from commit 7f2649ff33)
2025-05-28 16:15:17 -07:00
Doug Gregor
0c7c1fb1a7 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.

(cherry picked from commit abad2fae0f)
2025-05-28 16:15:15 -07:00
Pavel Yaskevich
e39debae11 [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.

(cherry picked from commit 4909b9baed)
2025-05-28 16:15:10 -07:00
Rintaro Ishizaki
2416b587db [Macros] Terminate macro plugin
Instead of expecting the plugin read `EOF` and exit, proactively
terminate the plugin and `wait` to reap it.

(cherry picked from commit 4a62ef86d4)

[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.

(cherry picked from commit 05948bcb93)
2025-05-15 16:20:51 -07:00
Pavel Yaskevich
61c8e70c66 [Feature] Rename Feature APIs from adoption to migration
(cherry picked from commit 085078dd8a)
2025-05-14 20:28:46 -07:00
Pavel Yaskevich
4e6071c1f8 [Feature] NFC: Rename ADOPTABLE_ with MIGRATABLE_ to match the proposal
(cherry picked from commit 2a479acf9e)
2025-05-14 20:28:46 -07:00
Pavel Yaskevich
8977d80adc [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.

(cherry picked from commit 18703d64d6)
2025-05-14 20:28:46 -07:00
Pavel Yaskevich
e477143d58 [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.

(cherry picked from commit 55bd906906)
2025-05-14 20:28:40 -07:00
Michael Gottesman
e92e9dff0c Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.

(cherry picked from commit 3ff9463957)
2025-05-14 16:07:04 -07:00
3405691582
ac1734c59f 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-25 18:36:14 -04:00
Hamish Knight
15c7467f37 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-18 11:58:14 +01:00
Steven Wu
5ced9bd1e4 [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.

(cherry picked from commit 56778b7209)
2025-04-11 10:18:36 -07:00
Hamish Knight
62898497de [Mangler] Use abortWithPrettyStackTraceMessage for verification errors
Make sure we include the verification error in the crash log.
2025-04-07 17:05:36 +01:00
Hamish Knight
fd7c2595f2 [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-07 17:05:35 +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
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
Tony Allevato
68876a6d4a Merge pull request #76636 from allevato/rich-identifiers
Support raw identifiers (backtick-delimited identifiers containing non-identifier characters).
2025-03-12 14:56:14 -04:00
Tony Allevato
d94bd80c62 Add support for raw identifiers.
Raw identifiers are backtick-delimited identifiers that can contain any
non-identifier character other than the backtick itself, CR, LF, or other
non-printable ASCII code units, and which are also not composed entirely
of operator characters.
2025-03-11 17:18:43 -04:00
Gabor Horvath
22e2276c4f [cxx-interop] Do not require the LifetimeDependence feature in _SwiftifyImport
We use experimental features to let people know that the construct is
subject to change and users should not rely on this unless they are
willing to rewrite the uses of this feature later. However, in compiler
generated code everything should be fair game, we will update the
compiler when these features change. This is a requirement to be able to
turn safe wrapper generation on by default.
2025-03-11 17:38:53 +00:00
Anthony Latsis
ae70d384e0 [NFC] Basic: Restrict adoption mode to upcoming and experimental features 2025-03-11 01:15:33 +00:00
Anthony Latsis
b3df0dcd08 [NFC] Basic: Do not return true in LangOptions::hasFeature if adoption mode
This check is used to enact features, whereas adoption mode should not
change behavior.
2025-03-11 01:14:39 +00:00
Anthony Latsis
b102c986aa [NFC] Basic: Use scoped enum for feature states
To prevent unexpected implicit conversions to integral types.
2025-03-11 01:14:39 +00:00
Anthony Latsis
6a3903bb53 Revert "Revert "Introduce adoption mode for Swift features""
This reverts commit 393c59c078.
2025-03-05 15:21:01 +00:00
Rintaro Ishizaki
393c59c078 Revert "Introduce adoption mode for Swift features" 2025-03-04 19:13:05 -08:00
Anthony Latsis
2771f36ced LangOptions: Refactor feature state and API to account for adoption mode 2025-03-04 13:43:28 +00:00
Anthony Latsis
8dab67bcee Basic: Adjust feature macros for adoption mode 2025-03-04 13:43:28 +00:00
Anthony Latsis
0210872916 [NFC] Basic: Extract feature API definitions into their own file 2025-02-27 20:45:07 +00:00
Doug Gregor
b7b5a2a19d [SE-0458] Enable unsafe expressions / attributes / for..in effects by default
With the acceptance of SE-0458, allow the use of unsafe expressions, the
@safe and @unsafe attributes, and the `unsafe` effect on the for..in loop
in all Swift code.

Introduce the `-strict-memory-safety` flag detailed in the proposal to
enable strict memory safety checking. This enables a new class of
feature, an optional feature (that is *not* upcoming or experimental),
and which can be detected via `hasFeature(StrictMemorySafety)`.
2025-02-26 12:30:07 -08:00
Pavel Yaskevich
bc2a640ce7 [Basic] Limit version::getCompilerversion to major + minor only
At the moment the only user of this method is `-interface-compiler-version`
and it's checked against major + minor only, so this is not going
to affect functionality.

In the future we should switch from `llvm::VersionTuple` to `swift::Version`
because swift tags have five components.

Resolves: rdar://140006577
2025-02-17 08:20:06 -08:00
Saleem Abdulrasool
45032fd4b3 Merge pull request #79223 from compnerd/sizeof-void-star
Basic: query the target pointer width from clang
2025-02-10 16:08:44 -08:00
Saleem Abdulrasool
a04c75a43a Basic: query the target pointer width from clang
Use the `clang::TargetInfo` to query the target pointer size for the
given triple. This is meant to enable us to properly determine
`CMAKE_SIZEOF_VOID_P`.
2025-02-10 09:20:02 -08:00
Qiongsi Wu
f24a1325d3 Ignore -ffile-compilation-dir when processing swift modules. 2025-02-06 15:13:42 -08:00
Steven Wu
c1063d0992 Merge pull request #78623 from cachemeifyoucan/eng/bridging-header-auto-chaining
[BridgingHeader] Auto bridging header chaining
2025-02-05 14:23:26 -08:00
Steven Wu
9d59044bb1 [BrdigingHeader] Auto bridging header chaining
Add ability to automatically chaining the bridging headers discovered from all
dependencies module when doing swift caching build. This will eliminate all
implicit bridging header imports from the build and make the bridging header
importing behavior much more reliable, while keep the compatibility at maximum.

For example, if the current module A depends on module B and C, and both B and
C are binary modules that uses bridging header, when building module A,
dependency scanner will construct a new header that chains three bridging
headers together with the option to build a PCH from it. This will make all
importing errors more obvious while improving the performance.
2025-02-05 09:41:04 -08:00
Rintaro Ishizaki
a619daf12b Merge pull request #79125 from rintaro/astgen-available-attr
[ASTGen] Generate AvailableAttr
2025-02-05 09:41:02 -08:00
Rintaro Ishizaki
df2ada37df [ASTGen] Generate AvailableAttr
* Move `AvailabilitySpec` handling logic to AST, so they can be shared
  between libParse and ASTGen
* Requestify '-define-availability' arguments parsing and parse them
  with 'SwiftParser' according to the 'ParserASTGen' feature flag
* Implement 'AvailableAttr' generation in ASTGen
2025-02-04 23:40:01 -08:00
Michael Chiu
c6d9efa553 Remove FreeBSD version from SDK triple 2025-02-01 12:05:39 -08:00
Kuba Mracek
d36b5e545e [embedded] Explicitly recognize riscv32 as a valid arch conditional 2025-01-30 10:39:45 -08:00
John McCall
eac9b3cb58 Generate getSwiftRuntimeCompatibilityVersionForTarget from
RuntimeVersions.def.

This really *ought* to be NFC, but alas, there are two behavior changes.
The first is that arbitrary future versions (short of the special future
version of 99.99) used to be considered to be free of all deployment
issues, but are now just considered to offer the Swift release that's
attached to the last known release of the target platform. The old behavior
was fine in a sense: deployment issues require updating the compiler anyway,
so if you haven't taught the compiler that iOS 31 provides Swift 8.3, you
probably also haven't taught it about any problems that are fixed in
Swift 8.3. The only problem with this logic is that we often implement
compiler fixes for these deployment issues before that first OS actually
ships (and thus before we've settled on a release number), and so we end
up with a race where we start considering new releases to fix the issue
even without updating the release mapping. The new approach fixes this:
we say that the bug will be fixed in Swift 8.3, and for the time being,
there are simply no platforms that provide that fix yet. Later, we update
the mapping to say that iOS 31 provides it, and compilations targeting that
release will be able to take advantage.

The other issue is that we actually treated "future" releases of macOS 10.x
(starting with 10.16, which ended up being 11.0) the same way, instead of
treating them logically as intermediate between 10.15 and 11.0.

My initial attempt at this generation used a constexpr array of a struct
with a std::initializer_list of platform releases, exactly mirroring the
structure of the .def file and requiring the compiler to parse out the
bits relevant to the target dynamically. The approach I ended up with is
much better, but I was actually forced into it because MSVC miscompiled
those global "temporary" arrays --- they ended up uninitialized.
2025-01-23 02:02:03 -05:00
Robert Widmann
0f94164d3b Replace Hand-Rolled MAX/MIN with std::max/std::min
We're using C++ 14+ at least now across the project so these should not be necessary. It's also kind of wild that the definitions we had across different subsystems had different definitions.
2025-01-22 11:18:35 -07:00