Commit Graph

163 Commits

Author SHA1 Message Date
Anthony Latsis 7887251a0c Basic: Adjust to "Rename wasm32-wasi to wasm32-wasip1. (#165345)"
See https://github.com/llvm/llvm-project/pull/165345.
2026-06-04 13:50:45 +01:00
Anthony Latsis c99064ba4e Basic: Adjust to "[Clang][Hexagon] Add QURT as recognized OS in target triple (#183622)"
See https://github.com/llvm/llvm-project/pull/183622.
2026-06-04 13:50:44 +01:00
Anthony Latsis ed4aed9a8b Basic: Adjust to "Make OpenCL an OSType rather than an EnvironmentType. (#170297)"
See https://github.com/llvm/llvm-project/pull/170297.
2026-06-04 13:50:43 +01:00
Anthony Latsis 9cc87e562f Basic: Adjust to "[Triple] Add "chipstar" OS components (#170655)"
https://github.com/llvm/llvm-project/pull/170655
2026-06-04 13:50:42 +01:00
Anthony Latsis 51d68c01d8 Basic: Adjust to "[Triple] Add target triple support for CheriotRTOS. (#155374)"
Added in https://github.com/llvm/llvm-project/pull/155374.
2026-06-04 13:50:41 +01:00
Kavon Farvardin 7d4e8c7155 Merge pull request #88820 from kavon/noncopyable-field-metadata
IRGen/Runtime: emit noncopyable field metadata
2026-05-22 04:36:04 -07:00
Kavon Farvardin c185332c5d NFC: fix findSwiftRuntimeVersionHelper
If our deployment target is a future release version (99.99+) then
we would end up returning the latest known release version, e.g.,
6.3. That seemed counter to the intention of
eac9b3cb58 and the description in
`findSwiftRuntimeVersion`, which says we should return
`std::nullopt` to indicate that we're not bound to any version.
2026-05-20 14:50:28 -07:00
Max Desiatov e37274c5c8 lib/Basic: Emscripten triple support in swift-frontend (#88732)
- **Explanation**:  Adding support for `swift-frontend -print-target-info -target wasm32-unknown-emscripten`, which is required before this triple is supported in `swiftc`.
- **Scope**: Limited to Emscripten Wasm support.
- **Issues**: rdar://175887675
- **Risk**: Very low due to limited scope.
- **Testing**: Added a new case to the lit test suite.
2026-04-30 10:23:59 +01:00
3405691582 732de1f28e Fix module names on OpenBSD for amd64/x86_64.
In #88224 we moved to unversioned triples. However in using the existing
getUnversionedTriple implementation, we lost the call to
getMajorArchitectureName and just used getArchName on the triple.

On OpenBSD, the spelling is amd64. We make a number of transpositions to
use the LLVM spelling x86_64 in a number of places, but the target
triple by default uses amd64. This means that instead of having a
mismatch between versioned and unversioned triple, we have a mismatch
between architecture spellings.

Here, we call getMajorArchitectureName on OpenBSD to use the LLVM
architecture spellings in getUnversionedTriple for the platform. This is
only a problem for amd64/x86_64; there is no problem on aarch64,
which is why this wasn't spotted earlier.
2026-04-09 07:38:02 -04:00
3405691582 9ca2816557 Use unversioned triples on OpenBSD.
Prior to this change, we used versioned triples on this platform.
However, swift-build and the planned future migrations effectively
constrain the platform to abandon this module naming scheme.

Ideally, we would look for a swiftmodule named after the versioned
triple, then fall back to the unversioned triple, or vice versa.
However, this is not straightforward to do, and/or would induce a larger
change. It transpired that it was more straightforward to just convert,
despite reservations and modules generated on earlier versions requiring
recompilation in the future. Because the install base for the platform
is likely few, tackle the work to implement the fallback later and just
get this quickly done first, especially so we can hopefully make the cut
to have this incorporated in 6.3.
2026-03-31 16:58:41 -04:00
Ian Anderson 69fa949c01 [Triple] Support the new target triple "os" for firmware
Add support for the new Firmware llvm::Triple::OSType, and make a swift::DarwinPlatformKind to go with it.

rdar://165361368
2026-02-03 13:02:44 -08:00
Anthony Latsis 8572b7e38c Address llvm::StringSwitch deprecations in advance
There's a whole bunch of these, e.g.
- https://github.com/llvm/llvm-project/pull/163405
- https://github.com/llvm/llvm-project/pull/164276
- https://github.com/llvm/llvm-project/pull/165119
- https://github.com/llvm/llvm-project/pull/166016
- https://github.com/llvm/llvm-project/pull/166066
2025-12-02 17:13:17 +00:00
3405691582 0158137afc Supply -z,nobtcfi on x86_64 as well.
On older x86_64 hardware, this isn't a problem since CET IBT hardware
support may not have been available. However, newer x86_64 hardware
supports the feature, which will lead to BTCFI failures. Therefore ensure
the same BTCFI disabling logic applies on x86_64 as well as aarch64.
2025-10-20 21:23:45 -04:00
Mads Odgaard c92e5b47f3 Merge pull request #84574 from madsodgaard/android-availability 2025-10-20 10:40:37 +09:00
swift-ci c13a72800d Merge remote-tracking branch 'origin/main' into rebranch 2025-09-22 12:56:40 -07:00
Owen Voorhees e6c9dceae9 Update OS versions requiring stdlib OS rpaths 2025-09-21 09:47:18 -07:00
swift-ci 23eb9d68bb Merge remote-tracking branch 'origin/main' into rebranch 2025-08-11 09:35:30 -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 5e22a5ba64 Merge pull request #82243 from AnthonyLatsis/rebranch
[rebranch] Get Swift almost building with stable/20250601
2025-06-17 12:20:37 +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 dcb905bddd Basic: Conservatively handle new llvm::Triple case
Added in https://github.com/llvm/llvm-project/pull/87845
2025-06-13 21:57:36 +01: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
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
Michael Chiu c6d9efa553 Remove FreeBSD version from SDK triple 2025-02-01 12:05:39 -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
swift-ci c2637adbfb Merge remote-tracking branch 'origin/main' into rebranch 2024-06-25 18:14:25 -07:00
John McCall 6a73d244c3 Implement getSwiftRuntimeCompatibilityVersionForTarget for recent releases
We were relying on this for `@isolated(any)` mangling suppression, but
it actually doesn't generate correct results for recent deployment targets.
As a result, we treated e.g. macOS 14.4 as if it were completely
unconstrained in terms of runtime availability.

I took this data from availability-macros.def; it's unfortunate that
we can't just generate the implementation directly from that.

Fixes rdar://129861211
2024-06-25 13:25:56 -04:00
Xi Ge 736ccef626 Merge remote-tracking branch 'apple/main' into rebranch 2024-06-20 15:16:55 -07:00
Tim Kientzle 1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
swift-ci d4e8274d83 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-07 12:33:55 -07:00
Alastair Houghton a25cd37750 Add support to the compiler for musl and the LINUX_STATIC SDK.
This is really just about setting appropriate defaults (such as
making sure that the static Linux triple causes us to use lld).

rdar://123506306
2024-05-07 16:48:52 +01:00
swift-ci 37f3df4780 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-25 21:14:38 -07:00
Allan Shortlidge 50835e8590 Basic: Add minimum availability version for visionOS.
This fixes an issue where diagnostics were not emitted for missing availability
attributes when compiling for visionOS.

Resolves rdar://127073463
2024-04-25 15:10:51 -07:00
Ben Barham 30ea96064d [Basic] Remove duplicate XROS case 2024-04-23 20:12:48 -07:00
Nate Chandler c43f87101f Merge branch 'main' into rebranch
Conflicts:
      lib/Basic/Platform.cpp

```
diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp
index 240edfa144a..1797c87635f 100644
--- a/lib/Basic/Platform.cpp
+++ b/lib/Basic/Platform.cpp
@@ -200,10 +200,7 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
   case llvm::Triple::CUDA:
   case llvm::Triple::DragonFly:
   case llvm::Triple::DriverKit:
-<<<<<<< HEAD
   case llvm::Triple::ELFIAMCU:
-=======
->>>>>>> main
   case llvm::Triple::Emscripten:
   case llvm::Triple::Fuchsia:
   case llvm::Triple::HermitCore:
```
2024-04-17 13:32:48 -07:00
Artem Chikin 1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Ben Barham 2fc51affb2 [Basic] Handle added/removed triples
Ananas/CloudABI/Contiki/Minix have all been removed from LLVM (in
various commits).

Also adds minimal (ie. necessary for compiling) support for the new
triples.
2024-04-08 08:58:58 -07:00
Ben Barham 1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Max Desiatov 321cc8387a Embedded: enable *-unknown-windows-coff tripels in Platform.cpp (#72217)
This allows the frontend to proceed when building with `-target i686-unknown-windows-coff -enable-experimental-feature Embedded` arguments.
2024-03-11 09:26:39 -07:00
Ben Barham ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Cyndy Ishida 9e2b97c0fd Add xrOS to silence -Wswitch violations (#71432)
To commit the necessary llvm-project changes to land xrOS support,  xrOS as a triple must be understood to swift. Add minimal support such that CI passes.
2024-02-07 21:19:40 -08:00
Evan Wilde 2c216e08eb Add new OS platforms
LLVM added UEFI and LiteOS platforms. We don't currently support them,
so we should crash on the unsupported OS for now to avoid accidents
later.
2023-07-17 10:55:57 -07:00
Evan Wilde 41d59b215a Update Triple.h location
Triple moved from ADT to TargetParser. Updating includes to reflect
that.
2023-07-17 10:53:42 -07:00
Evan Wilde 250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Saleem Abdulrasool 19c7bb5a22 Driver: add support for baremetal targets
This allows building the Swift standard library for targets which may
not have an actual OS running.  This is identified by the OS field in
the target triple being set to `none`.
2023-03-20 17:59:13 -04:00
Erik Eckstein ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Evan Wilde 2ee40ee582 Adding Swift 5.7 compatibility versions
Swift 5.7 corresponds with: macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0
2022-09-13 11:09:42 -07:00
Evan Wilde 1c55135b15 Adding compatibility versions for 5.6
5.6 corresponds with:
5.6: macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4
2022-09-13 11:07:59 -07:00