Commit Graph

141 Commits

Author SHA1 Message Date
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
Evan Wilde
a7806db9fe Fix version bugs
Swift 5.3 was the Swift stdlib from 11.0 up to and including 11.2, not
11.3.

Swift 5.3 was active from watchOS 7.0 up to and including 7.3, not 7.4.
2022-09-13 11:04:16 -07:00
Ben Barham
cbcd6c75f5 [next] Handle new LLVM triples 2022-05-05 16:25:10 -07:00
Ben Barham
114b4d96e4 [next] Use new VersionTuple API
The `VersionTuple` API was changed llvm/llvm-project
219672b8dd06c4765185fa3161c98437d49b4a1b to return `VersionTuple`
from `get*Version` rather than pass in major, minor, and subminor output
parameters. Update uses to the new API.

Note that `getMacOSXVersion` is slightly different in that it returns a
boolean while taking a `VersionTuple` output parameter to match its
previous behaviour. There doesn't seem to be any use that actually
checks this value though, so we should either update the API to return
an `Optional` and actually check it *or* remove the "failure" case and
return a `VersionTuple` like all the others.
2022-05-05 16:25:10 -07:00
Allan Shortlidge
c6410645cc Frontend: Add a separate inlining version floor for the macCatalyst platform, which was introduced as 13.1. Create a variant of the tests for -target-min-inlining-version specifically for macCatalyst (unfortunately, covering the macCatalyst platform in the same test file is prohibitively difficult because the tests never run with macCatalyst as the host OS and therefore the target triple substitutions need to be explicit).
Resolves rdar://90858579
2022-03-29 11:40:52 -07:00
Allan Shortlidge
b563dc0736 Frontend: Replace the abi magic value accepted by -target-min-inlining-version with a min magic value instead. The new value corresponds to the OS versions in which Swift was introduced. The introduction OS is a better floor for availability checking than the OS in which Swift became ABI stable because inlinable functions may reference clang declarations which have availability between Swift's introduction and ABI stability and framework developers ought to get diagnostics for unguarded use of those APIs in inlinable code. 2022-03-14 19:26:36 -07:00
Allan Shortlidge
e25b822f7a Merge pull request #41673 from tshortli/inlining-availability-checking
Add -target-min-inlining-version to aid type checking for inlinable functions in resilient libraries
2022-03-07 17:30:59 -08:00
Alsey Coleman Miller
b85e673a78 [stdlib] Added Armv5 support 2022-03-06 00:56:32 -05:00
Becca Royal-Gordon
bbcd980aff Add flag for minimum inlining version 2022-03-04 10:54:52 -08:00
Ben Barham
624337148b [NFC] Formatting cleanup to help with next conflicts 2021-10-15 17:15:51 +10:00
Doug Gregor
a91feb3309 Update the OS runtime mapping for Apple OS versions.
Fixes the rest of rdar://84065193, makingn sure we don't link against
compatibility libraries we don't need.
2021-10-13 23:02:11 -07:00
swift-ci
c51550f30e Merge remote-tracking branch 'origin/main' into rebranch 2021-09-30 15:11:41 -07:00
Doug Gregor
f4aa6266df arm64 macOS was introduced with version Swift
Generalize the check from arm64e to also include arm64. Fixes
rdar://83502661.
2021-09-27 14:05:25 -07:00
swift-ci
220daa4c05 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-24 10:53:33 -07:00
Kuba Mracek
b073df2c6d 64-bit watchOS should imply a 5.3 minimum version of the Swift runtime 2021-09-23 18:02:56 -07:00
swift-ci
5f454ca504 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-21 21:13:29 -07:00
Kuba (Brecka) Mracek
942b0e8a63 The concurrency compat library should not be unconditionally used in arm64e builds (#39385) 2021-09-21 21:01:21 -07:00
swift-ci
cd7ed018bf Merge remote-tracking branch 'origin/main' into rebranch 2021-09-02 11:56:28 -07:00
Varun Gandhi
4a16261c4d [Driver] Update OS versions for rpath checks.
Make sure that we add the appropriate rpaths so that the appropriate
_Concurrency back-deployment library can be picked up.

We don't need to update the Swift driver since it uses the C++ driver
as the source of truth to determine if the relevant rpath should be
added or not.
2021-09-01 15:37:24 -07:00
Arnold Schwaighofer
de0218bf09 Adjust to LLVM's DarwinSDKInfo.h changes 2021-08-05 12:15:22 -07:00
Robert Widmann
22f3e9620b Remap aarch64_32 to arm64_32 When Searching for Modules
The triple name aarch64_32 does not actually name a valid platform. The
actual platform (and valid triple arch string, confusingly enough) is
arm64_32. Remap between the two to correct for this difference.

rdar://77281393
2021-04-28 17:39:06 -07:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
swift_jenkins
d73adae0f2 Merge remote-tracking branch 'origin/main' into next 2020-10-29 18:01:19 -07:00