Commit Graph

446 Commits

Author SHA1 Message Date
Marc Prud'hommeaux
7f09af24cf Support 16 KB page sizes on Android (#81596)
Android 15+ requires that native libraries be compiled with a linker
flag to support 16 KB page sizes. See:
https://developer.android.com/guide/practices/page-sizes#compile-r26-lower
2025-08-11 04:31:19 +05:30
Saleem Abdulrasool
8bf3af09a6 Merge pull request #82166 from Steelskin/fabrice/6.2-line-directive
🍒 [6.2] line-directive: Stop expanding response files
2025-07-15 11:40:13 -07:00
Alastair Houghton
8eb879831c Merge pull request #81940 from al45tair/eng/PR-152498657
Rename SwiftStdlibCurrentOS to StdlibDeploymentTarget.
2025-07-07 12:04:38 +01:00
Alastair Houghton
0813e95569 Merge pull request #81440 from al45tair/currentos-availability
[Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it.
2025-07-07 12:04:00 +01:00
Saleem Abdulrasool
3407cecfaf Merge pull request #81996 from Steelskin/fabrice/line-directive-stop-expanding-rsp
line-directive: Stop expanding response files
2025-06-10 14:31:15 -07:00
Konrad `ktoso` Malawski
c8a8183d26 [6.2][Concurrency][SE-review update] Task names update (#81132)
**Description**: This adds "task name" parameter to all task creating
functions.

This is done in a few ways, e.g. we can backdeploy this to 5.1 in APIs
which do not accept the `TaskExecutor` but it they do we provide a
version for 6.0+ etc. This was requested in the SE acceptable of this
proposal [Acceptance post
SE-0469](https://forums.swift.org/t/accepted-with-modifications-se-0469-task-naming/79438).

This moves all these declarations to gyb since going through them one by
one has become unmaintainable otherwise.

**Scope/Impact**: All task creation APIs now gain a new task name
parameter.
**Risk:** Medium, changes existing APIs rather than adding "even more
overloads" though this risk was discussed in the team and accepted. This
has a potential to be source breaking it someone used Task.init and
friends as function.
**Testing**: CI testing, source compatibility suite testing
**Reviewed by**: 

**Original PR:** 
- https://github.com/swiftlang/swift/pull/81107 build changes required
for this
- https://github.com/swiftlang/swift/pull/80984


**Radar:**

---------

Co-authored-by: Kuba Mracek <mracek@apple.com>
2025-05-29 07:52:33 +09:00
Egor Zhdan
10ab242b64 [cxx-interop] Do not install binary .swiftmodule files for the overlays
This fixes a deserialization failure in the compiler that occurred while loading the CxxStdlib overlay module:
```
Cross-reference to module 'Swift'
... Optional
... some
... with type <τ_0_0 where τ_0_0 : ~Copyable, τ_0_0 : ~Escapable> (Optional<τ_0_0>.Type) -> (τ_0_0) -> Optional<τ_0_0>
```

This was happening because the overlays were built against a different version of the Swift stdlib than is being used. The compiler is able to rebuild the Cxx and CxxStdlib modules from their textual interfaces. Let's use that feature unconditionally in production toolchains to avoid this kind of binary incompatibilities.

rdar://150416863
(cherry picked from commit 16b280862a)
2025-05-12 19:30:15 +01:00
Guillaume Lessard
e9b21cff7d Merge pull request #80847 from glessard/rdar149227278-nonescapable-mutating-accessor-62
[6.2, LifetimeDependenceMutableAccessors] defensive feature flag
2025-04-29 12:30:10 -07:00
Slava Pestov
a10356aa27 Merge pull request #80680 from slavapestov/compatibility-span-6.2
[6.2] Cherry-pick recent CompatibilitySpan work
2025-04-23 01:00:29 -04:00
QuietMisdreavus
61c4a0311f [6.2] [SymbolGraphGen] add flags to filter platforms out of availability metadata (#80806)
rdar://144379124
2025-04-21 14:48:43 -06:00
Slava Pestov
4af982902c cmake: Add NO_SWIFTMODULE option to add_swift_target_library() 2025-04-21 15:01:28 -04:00
Guillaume Lessard
e81fbe5f48 [stdlib] use “LifetimeDependenceMutableAccessors” 2025-04-15 22:25:24 -07:00
Meghana Gupta
00bda986a9 Introduce InoutLifetimeDependence feature 2025-04-09 10:19:11 -07:00
Evan Wilde
eeee0dfddd CMake: option to disable swift in swift
Adding `SWIFT_ENABLE_SWIFT_IN_SWIFT` option to enable or disable the
parts of Swift that require a Swift compiler to build. This is meant for
bootstrapping compilers on new platforms and is not guaranteed to result
in a compiler that will pass the test suite.

This option is on by default so that folks won't forget.
If the option is off, the resulting compiler does not include the Swift
optimizer sources in SwiftCompilerSources nor does the resulting
compiler have swift macro support.
2025-03-06 13:32:49 -08:00
Doug Gregor
50d3913086 [SE-0458] Enable strict memory safety in the Swift standard library 2025-02-26 14:27:55 -08:00
Hamish Knight
d260bd8ddb [build-script] Remove Xcode generation support
This was quite brittle and has now been superseded
by swift-xcodegen. Remove the CMake/build-script
logic for it, leaving the option behind to inform
users to switch to using xcodegen instead.
2025-02-12 12:19:21 +00:00
Alastair Houghton
884cf75fb2 [Backtracing] Add missing CxxStdlib dependency.
To do this we also need to fix AddSwiftStdlib because if you set the
`INSTALL_WITH_SHARED` flag, the CMake scripts don't make a target
with the `-static` suffix, but AddSwiftStdlib also assumes that it
should dad `-static` to any module dependencies when building a
static library.
2025-01-31 14:52:48 +00:00
Alastair Houghton
18496c5626 [Backtracing] Remove support for implicit import of _Backtracing.
We're going to rename the module to Runtime, and it isn't going to be an
implicit import, so we don't need any of this.

rdar://124913332
2025-01-17 10:09:36 +00:00
Meghana Gupta
a9b998bbce Fix cmake function parameter name while querying for IMPORTS_NON_OSSA option 2025-01-07 01:21:43 -08:00
Henrik G. Olsson
ef9d2b744d Rename pointer bounds (#78210)
* Make pointer bounds non-experimental

* Rename @PointerBounds to @_SwiftifyImport

* Rename filenames containing PointerBounds

* Add _PointerParam exception to stdlib ABI test

* Add _PointerParam to stdlib API changes

* Rename _PointerParam to _SwiftifyInfo
2024-12-20 11:36:01 +01:00
Egor Zhdan
d2801ecee9 Merge pull request #78242 from swiftlang/egorzhdan/simulator-deployment-target
[build] Respect `DEPLOYMENT_VERSION_{IOS|TVOS|WATCHOS}` for Simulator targets
2024-12-18 18:28:55 +00:00
Egor Zhdan
d1a435c42a [build] Respect DEPLOYMENT_VERSION_{IOS|TVOS|WATCHOS} for Simulator targets
This makes sure that Cxx and CxxStdlib modules are built with consistent deployment targets for iOS Simulator and iOS Device.

rdar://141232269
2024-12-17 15:51:18 +00:00
Finagolfin
632e7a7ea1 [android] Detect the NDK version by reading source.properties, not by checking the NDK name 2024-12-17 20:27:11 +05:30
3405691582
301a0c49fc Swift on OpenBSD supports arm64.
However, to do this, we end up changing how amd64 is supported too.
Previously, I had tried to keep some meaningful separation between
platform spelling and LLVM spelling, but this is becoming more difficult
to meaningfully maintain.

Target specifications are trivially converted LLVM triples, and the
module files are looked up by LLVM triples. We can make sure that the
targets align, but then the Glibc to SwiftGlibc import breaks. That could
also be addressed, but then we get to a point where the targets set up
by build-script and referenced by cmake begin to misalign. There are
references in build-script-impl for a potential renaming site, but it's
not quite enough.

It's far simpler to give up and rename to LLVM spellings right at the
beginning. This does mean that this commit is less constrained to just
adding the necessary parts to enable arm64, but it should mean less
headaches overall from differing architecture spellings.
2024-11-30 16:33:46 -05:00
Meghana Gupta
ddd107911d Add -enable-experimental-feature LifetimeDependence to stdlib 2024-11-18 18:08:32 -08:00
Allan Shortlidge
c9c36732be stdlib: Enable upcoming MemberImportVisibility feature.
It was already supposed to be enabled, but I forgot to update the CMake when I
renamed the feature from ExtensionImportVisibility to MemberImportVisibility.

However, leave it disabled on the CxxStdlib module since the C++ standard
library's modularization varies a lot by platform, making it difficult to add
the right conditional imports.
2024-11-18 10:27:14 -08:00
Finagolfin
22833fbc54 [android] Update to LTS NDK 27c
Add a new bits/ header to the Android overlay, include runtime libraries that are
auto-extracted and listed many times to the list of libraries to be de-duplicated,
enable a C++ interop test that's working again, and update the doc with new
libraries that need to be available to run a simple executable.
2024-11-14 00:11:53 +05:30
Henrik G. Olsson
0678829cf7 Add @PointerBounds macro (#76969)
Add @PointerBounds macro

@PointerBounds is a macro intended to be applied by ClangImporter when
importing functions with pointer parameters from C headers. By
leveraging C attributes we can get insight into bounds, esapability, and
(eventually) lifetimes of pointers, allowing us to map them to safe(r)
and more ergonomic types than UnsafePointer.

This initial macro implementation supports CountedBy and Sizedby, but
not yet EndedBy. It can generate function overloads with and without an
explicit count parameter, as well as with UnsafeBufferPointer or Span
(if marked nonescaping), and any of their combinations. It supports
nullable/optional pointers, and both mutable and immutable pointers.
It supports arbitrary count expressions. These are passed to the macro
as a string literal since any parameters referred to in the count
expression will not have been declared yet when parsing the macro.

It does not support indirect pointers or inout parameters. It supports
functions with return values, but returned pointers can not be bounds
checked yet.

Bounds checked pointers must be of type Unsafe[Mutable]Pointer[?]<T>
or Unsafe[Mutable]RawPointer[?]. Count expressions must conform to
the BinaryInteger protocol, and have an initializer with signature
"init(exactly: Int) -> T?" (or be of type Int).

rdar://137628612

---------

Co-authored-by: Doug Gregor <dgregor@apple.com>
2024-11-11 14:54:25 -08:00
Saleem Abdulrasool
87d4966d8c build: add -Xfrontend to -strict-implicit-module-context
When building with the early swift driver we need to add the explicit
`-Xfrontend` to make the option take effect.
2024-11-08 11:53:07 -08:00
Meghana Gupta
02a58738a0 Remove -enable-ossa-module for Synchronization and Distributed
These modules import Darwin which is not in ossa. -enable-ossa-modules
results in a one-time recompilation of dependencies when they are not in ossa.
This is not compatible with Explicit Build Modules when the original invocation
did not have -enable-ossa-modules.
2024-10-31 10:55:35 -07:00
Daniel Rodríguez Troitiño
d84b23b611 [maccatalyst] Handle macCatalyst static swiftmodules (#76784)
The existing CMake code for macCatalyst swiftmodule only handled the
shared case, and did not have the static pieces that non-macCatalyst
targets are doing.

Try to match as much as possible the non-macCatalyst variables and
structure and allow macCatalyst targets to support static Swift targets.

This is important for the `Cxx.swiftmodule` and `CxxStdlib.swiftmodule`,
since they are only static, and the previous code skipped creating those
files since https://github.com/swiftlang/swift/pull/74994
2024-10-21 22:56:12 -07:00
Egor Zhdan
b1c3ddb322 [build] Do not implicitly bump macCatalyst deployment target
This fixes linker warnings that look like this:
```
ld: warning: object file (libswiftCompatibility56.a) was built for newer 'macOS' version (XYZ) than being linked (ABC)
```

These were caused by the compatibility binary being incorrectly built with a newer `-target` than desired: the CMake logic was overriding the requested minimum macOS deployment version (10.9) with a much newer macOS SDK version.

rdar://137565964
2024-10-15 15:53:41 +01:00
Meghana Gupta
9184923089 Enable experimental feature NonescapableTypes in the stdlib 2024-09-13 01:54:20 -07:00
Vera Mitchell
b4529a69eb add build-stdlib-docs flag that generates stdlib symbol graphs 2024-09-03 13:52:42 -06:00
Doug Gregor
8378562e12 Adopt @unsafe throughout the standard library
Annotate all of the `Unsafe*` types and `unsafe` functions in the standard
library (including concurrency, synchronization, etc.) as `@unsafe`. Add a
few tests to ensure that we detect uses of these types in clients that
have disabled unsafe code.
2024-08-19 14:33:09 -07:00
Evan Wilde
cae88d3344 Fix add_swift_target_library for the static SDK
add_swift_target_library was missing pieces for passing sources and
flags to the static SDK build. As a result, the static SDK was missing
pieces (specifically Mutex).

Also adding the Musl import to the Linux Mutex implementation.
2024-08-13 15:59:31 -07:00
Alastair Houghton
02f87e3d8e [Build][Backtracing] Make sure the deployment target for OS X is over 10.14.4.
We need to make sure that we build swift-backtrace with a deployment target
newer than 10.14.4 in order that we get linked against
`/usr/lib/swift/libswiftCore.dylib` rather than using an `@rpath`-based
path.

If we fail to do that, dyld becomes confused and we end up crashing with
weird errors about missing method implementations on `Swift.__StringStorage`.

To make this work, add support for `DEPLOYMENT_VERSION_*` in the
`add_swift_target_executable()` CMake function.  And since I spotted a bug
in it, fix the existing support in `add_swift_target_library()` while I'm
there.

rdar://132710670
2024-08-06 15:03:01 +01:00
Eric Miotto
5c31c10dcf Merge pull request #75566 from edymtt/edymtt/promote-concurrency-stringprocessing-to-core-libraries
Promote _Concurrency and StringProcessing to core subset of the stdlib
2024-08-01 11:06:41 -07:00
Kavon Farvardin
972373b129 NCGenerics: begin process of removing compat hack
The reverse-condfail workaround needs to be removed, and this is the
first step to allowing the stdlib to build with conditionally escapable
types.

resolves rdar://132453000
2024-07-29 17:27:17 -07:00
Eric Miotto
5512833d18 Promote _Concurrency and StringProcessing to core subset of the stdlib
This is needed to support Apple internal configurations.

Addresses rdar://125909114
2024-07-29 08:58:04 -07:00
Alexander Cyon
c21b1e68fd [stdlib] Fix typos 2024-07-06 13:09:57 +02:00
Alastair Houghton
7268640b60 Merge pull request #74731 from al45tair/eng/PR-116525111
[Build][Linux] Set `--build-id=sha1` for the linker.
2024-06-28 11:31:36 +01:00
Alastair Houghton
35f123bbbf [Build][Linux] Set --build-id=sha1 for the linker.
This means we will get build IDs in the tools and standard library,
which is useful for debugging (it lets us associate debug symbols with
the binaries later on, as well as allowing us to reliably identify
exactly which binary we are looking at).

rdar://116525111
2024-06-27 12:21:50 +01:00
Kuba Mracek
37ed08dc7b Add a build-script + CMake flag to enable/disable building the _Volatile module 2024-06-17 13:18:55 -07:00
Alex Lorenz
c8b5344d3e Merge pull request #72014 from compnerd/android
utils: support building android SDKs on Windows
2024-06-07 12:37:00 -07:00
Alex Lorenz
5aa63fc93e Merge pull request #72634 from hyp/eng/android/ndk-overlay
[android] add an Android NDK Swift overlay
2024-06-05 19:35:13 -07:00
Alejandro Alonso
6b29e779e4 Support visionOS for Mutex 2024-06-04 09:06:37 -07:00
Alejandro Alonso
9b389a3df5 Fix tests and toolchain build 2024-06-04 09:06:37 -07:00
Alejandro Alonso
1f206ec58e Attempt to release the lock and wake when we can't 2024-06-04 09:06:36 -07:00
Alejandro Alonso
2a60c88457 Implement Mutex in Synchronization 2024-06-04 09:06:34 -07:00