Commit Graph

454 Commits

Author SHA1 Message Date
Mads Odgaard
c92e5b47f3 Merge pull request #84574 from madsodgaard/android-availability 2025-10-20 10:40:37 +09:00
Erik Eckstein
2f124cf564 Remove the -enable-ossa-modules option.
OSSA modules are enabled by default.
The compiler still accepts this option but it has no effect.
2025-09-26 08:01:08 +02:00
Egor Zhdan
28f9db7bfa [WinSDK] Modularize <guiddef.h>
This fixes modularization errors that arise when importing a C++ header that contains `#include <guiddef.h>`, which might hijack this header from the WinSDK module where it belongs.
2025-08-28 22:21:55 +01:00
Alastair Houghton
857539f3c5 [Build] Fix minimal stdlib build.
We need the new `deployment_version` function to handle the `FREESTANDING`
SDK also.

rdar://155841439
2025-08-01 14:37:34 +01:00
Alastair Houghton
27b1a7d8ee [Build] Fix deployment version handling for StdlibDeploymentTarget.
Where someone has told a target library to build for a _newer_ target
than the current deployment target, we need to respect that newer
target when setting StdlibDeploymentTarget for that target library.

This trips us up when testing against older systems.

rdar://155841439
2025-08-01 12:49:23 +01:00
Marc Prud'hommeaux
663ec9340d 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-07-29 20:42:22 +05:30
Fabrice de Gans
810588b0c5 line-directive: Stop expanding response files
`line-directive` was expanding response files for the swiftc invocation,
which was causing issues on CI when the file list got too long. This
changes the script to stop expanding response files and pass them as-is
to the swiftc invocation instead. The format for the response files was
also incorrect, with each individual file being quoted, so this fixes
the CMake script generating those.
Finally, this changes `line-directive` to dump the command line on
failure.
2025-06-04 13:16:50 -07:00
Alastair Houghton
42ca1b1cc8 Rename SwiftStdlibCurrentOS to StdlibDeploymentTarget.
`StdlibDeploymentTarget` seems to be a better name.

rdar://152498657
2025-06-04 10:40:19 +01:00
Alastair Houghton
d5ed335339 Merge pull request #81440 from al45tair/currentos-availability
[Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it.
2025-06-03 15:01:22 +01:00
Alastair Houghton
cd7701cd82 [Build] Add catalyst support to SwiftStdlibCurrentOS.
Add catalyst support for SwiftStdlibCurrentOS.

Also, set a minimum deployment target when building Concurrency;
this stops the build failing when we're trying to build on older
systems where Concurrency didn't really exist yet.

rdar://150966361
2025-05-23 10:31:56 +01:00
Finagolfin
432de55622 [stdlib][cmake] Disable checking for bootstrapping if the host tools aren't being built 2025-05-19 14:39:15 +05:30
Alastair Houghton
28f96e64ab [Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it.
If you use SwiftStdlibCurrentOS availability, you will be able to
use new types and functions from within the implementation. This
works by, when appropriate, building with the CurrentOS availability
set to the current deployment target.

rdar://150944675
2025-05-12 12:07:24 +01:00
Egor Zhdan
16b280862a [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
2025-05-10 22:55:06 +01:00
Kuba Mracek
c5aa98a449 [embedded] Make the CMake setup for Embedded Concurrency distnguish ARCH and SUBDIR for builds products 2025-04-26 07:03:19 -07:00
Guillaume Lessard
a5c561fb13 Merge pull request #80831 from glessard/rdar149227278-nonescapable-mutating-accessor
[LifetimeDependenceMutableAccessors] defensive feature flag
2025-04-17 09:27:23 -07:00
Guillaume Lessard
3670664ce6 [stdlib] use “LifetimeDependenceMutableAccessors” 2025-04-15 10:41:27 -07:00
QuietMisdreavus
41120da702 [SymbolGraphGen] add flags to filter platforms out of availability metadata (#80778)
* add option to filter availability metadata in symbol graphs

* filter out platform-specific availability in the stdlib docs

rdar://144379124
2025-04-14 15:20:22 -07:00
Slava Pestov
1d25522ceb cmake: Add NO_SWIFTMODULE option to add_swift_target_library() 2025-04-07 21:32:14 -04:00
Meghana Gupta
ef1e94577f Revert "Merge pull request #80540 from swiftlang/revert-80452-lifetimeinout"
This reverts commit 6eaa07a880, reversing
changes made to e75ee3f4cf.
2025-04-04 09:50:13 -07:00
Artem Chikin
39e1791b67 Revert "Add support for inout lifetime dependence" 2025-04-04 09:00:09 -07:00
Meghana Gupta
493f0b782e Introduce InoutLifetimeDependence feature 2025-04-03 17:32:09 -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