Commit Graph

253 Commits

Author SHA1 Message Date
Evan Wilde
1dc97c2c43 [CMake] Use CXX linker for Core and Concurrency
swiftCore and swift_Concurrency libraries use C++ and Swift. The C++
does not use the Swift C++ interop. Swift driver only uses clang++ to
link when building in C++ interop mode and there currently isn't a flag
to change that. Since we're explicitly linking the runtime registration
when necessary and do not need compatibility libraries, it is safe to
use clang++ as the linker directly, instead of going through swiftc.

In versions of CMake older than 3.29, Swift is always used as a linker
and has no compile stage. By using clang++ as the linker, we require the
split build model (CMP0157), so we cannot allow versions of CMake older
than 3.29.
2025-03-24 14:20:07 -07:00
Saleem Abdulrasool
db51658e3f Runtimes: add additional interface flags
Explicitly add the path to the Swift module to the interface include
directories. It is unclear why this is not propagating implicitly from
the module definition. For now, this ensures that the client is able to
load the standard library.
2025-03-24 13:10:35 -07:00
Saleem Abdulrasool
7a15ea09ad Runttimes: always build the runtime as PIC
When building the runtime, we do not know how it will be loaded even if
it is static. Default to building in PIC mode for non-Windows targets
(Windows is always implicit PIC).
2025-03-24 13:08:20 -07:00
Saleem Abdulrasool
f0b27bcd58 Merge pull request #80208 from compnerd/reorganise
Runtimes: reorganise flags for swiftCore
2025-03-24 13:07:48 -07:00
Saleem Abdulrasool
817a34c1b9 Merge pull request #80235 from compnerd/quotes
Runtimes: quote the path for module map files
2025-03-24 11:37:29 -07:00
Guillaume Lessard
c21de062bb Merge pull request #78561 from glessard/rdar137710901-span-properties-prototype
[SE-0456] Span properties (part 1)
2025-03-24 08:47:47 -07:00
Saleem Abdulrasool
0c632bb17f Runtimes: quote the path for module map files
The install path may contain spaces which will be processed improperly
when wired through the dependency. Add quotes to handle such paths.
2025-03-23 20:11:14 -07:00
Saleem Abdulrasool
564191e07c Merge pull request #80205 from compnerd/location
Runtimes: adjust path for referencing SwiftCoreTargets.cmake
2025-03-23 15:10:15 -07:00
Saleem Abdulrasool
f0c4a5c986 Merge pull request #80206 from compnerd/defaults
Runtimes: adjust the default settings for Windows
2025-03-23 11:14:49 -07:00
Saleem Abdulrasool
bb2c93571e Runtimes: add an export for ConcurrencyInternalShims
This is required to use the SwiftCore package externally via
`find_package` when Concurrency is enabled. We are otherwise unable to
process the CMakeLists due to the missing dependency from the export
set.
2025-03-21 13:17:51 -07:00
Saleem Abdulrasool
d19fd71174 Runtimes: reorganise flags for swiftCore
This re-organises the file a small amount to put the source listing and
additions together. Subsequently, apply compile definitions, options,
and then link libraries and finally options
2025-03-21 12:15:19 -07:00
Saleem Abdulrasool
3106f15165 Runtimes: adjust the default settings for Windows
This adjusts the default settings for the Windows build of the Swift
runtime to include reflection and to re-order them to match the Darwin
configuration to make it easier to identify differences.
2025-03-21 12:11:41 -07:00
Saleem Abdulrasool
440a66a7f6 Runtimes: adjust path for referencing SwiftCoreTargets.cmake
This is loaded by the CMake package configuration so that you can add
cross-package dependencies. Adjust the path so that the lookup succeeds
on all targets.
2025-03-21 11:57:30 -07:00
Saleem Abdulrasool
bc45db16fd Runtimes: properly link in swiftrtT?.obj on Windows
`swiftrtT.obj` should be used for statically linking the standard
library (or within the standard library itself). For the other modules,
we need to differentiate between `swiftrt.obj` and `swiftrtT.obj`. This
fixes that oversight. This was not caught by the CI builds as we do not
currently build both the static and dynamic variants of the new
runtimes.
2025-03-20 11:07:46 -07:00
Alejandro Alonso
25b10ebf76 Merge pull request #78092 from Azoy/enumerated-collection
[stdlib] Conditionally conform EnumeratedSequence to Collection(s)
2025-03-18 09:24:08 -07:00
Alejandro Alonso
a55c9c792d Add EnumeratedSequence to new build system 2025-03-17 18:11:48 -07:00
Evan Wilde
d280b1438a Merge pull request #80023 from etcwilde/ewilde/new-runtime-build-sccache-module
[CMake] Add cache for enabling sccache builds
2025-03-14 17:55:05 -07:00
Evan Wilde
98cf8d2b64 [CMake] Add cache for enabling sccache builds
Add cmake cache for enabling sccache while building with the new runtime
build when sccache is available.

To build with sccache, pass the `sccache.cmake`

```
cmake \
  -B build \
  -S Runtime/Core \
  -C Runtimes/Core/cmake/cache/sccache.cmake
```
2025-03-14 10:38:39 -07:00
Michael Gottesman
04bb69f426 Merge pull request #79727 from gottesmm/pr-025c1133954b74e7b4eda77e1a6f3bcafd4eb6cf
[concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
2025-03-10 22:35:00 -07:00
Michael Gottesman
f64dd5a8d5 [concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
We introduce a new macro called #SwiftSettings that can be used in conjunction
with a new stdlib type called SwiftSetting to control the default isolation at
the file level. It overrides the current default isolation whether it is the
current nonisolated state or main actor (when -enable-experimental-feature
UnspecifiedMeansMainActorIsolated is set).
2025-03-10 17:33:45 -07:00
Guillaume Lessard
96e9945d10 [stdlib] only enable “AddressableTypes” for the core stdlib 2025-03-10 14:24:59 -07:00
Saleem Abdulrasool
c3604743de Runtimes: tweak incorrect case (NFC)
This adjusts the spelling for the architecture specifier for the Windows
compilers. Take the opportunity to further restrict the compiler check
to micro-optimize the CMake configure phase.
2025-03-08 08:22:15 -08:00
Konrad `ktoso` Malawski
fda7f539fb Reapply "Task names" (#79562) (#79600) 2025-03-08 10:58:49 +09:00
Saleem Abdulrasool
0d8e005185 Merge pull request #79754 from compnerd/cx16
build: only apply `-mcx16` on X86 CPUs
2025-03-04 09:18:14 -08:00
Saleem Abdulrasool
40bf17c00d build: only apply -mcx16 on X86 CPUs
This is required to support compilation for non-X86 architectures.
2025-03-03 15:51:43 -08:00
Evan Wilde
0c5455ebad Fix missing PROPERTIES keyword in Finddispatch
Was missing the `PROPERTIES` keyword on the `Finddispatch` cmake
module resulting in failures to load it correctly.
2025-03-03 10:45:23 -08:00
Evan Wilde
7679b6e08f CMake: Fix swiftrt.o install location on Linux
Flipped the conditional here. Was installing swiftrt.o to `swift_static`
when building dynamic libraries and `swift` when building static
archives.
2025-02-28 15:00:51 -08:00
Evan Wilde
f6edc3d7d0 CMake: Allow setting optimization remark type
Optimization remarks were always emitted on Darwin but not on the other
platforms and were forced to use the bitstream format. Adding a flag to
enable or disable them as desired and specify the desired output format.

Fixes: https://github.com/swiftlang/swift/issues/79279
2025-02-27 20:36:19 -08:00
Evan Wilde
25186b2182 Merge pull request #79677 from etcwilde/ewilde/vanilla-extract
Extract experimental feature flags
2025-02-27 20:29:19 -08:00
Evan Wilde
3102bc0334 Extract experimental feature flags
Extracting experimental feature flags into a separate file so that we
can add Allan as a code owner of just that file. He has to deal with
breakage when folks remove these flags improperly.
2025-02-27 14:16:44 -08:00
Saleem Abdulrasool
bab2e673d6 Runtime: correct install rules for runtime component
We missed a `$<` leader for the generator expression. Adjust the install
rules to account for that.
2025-02-27 11:13:31 -08:00
Konrad `ktoso` Malawski
f55964df26 [Concurrency] Initial steps for startSynchronously for Task (#79608)
* [Concurrency] Initial steps for startSynchronously for Task

* [Concurrency] Rename to _startSynchronously while in development

* [Concurrency] StartSynchronously special executor to avoid switching

* startSynchronously bring back more info output

* [Concurrency] startSynchronously with more custom executor tests

* add missing ABI additions to test for x86

* [Concurrency] gyb generate _startSynchronously

* [Concurrency] %import dispatch for Linux startSynchronously test

* [Concurrency] Add TaskGroup.startTaskSynchronously funcs

* [Concurrency] DispatchSerialQueue does not exist on linux still
2025-02-27 02:34:33 -08:00
Doug Gregor
3001177e2b Merge pull request #78372 from DougGregor/strict-safety-stdlib
[SE-0458] Adopt strict memory safety in the standard libraries
2025-02-26 23:30:32 -08:00
Evan Wilde
38069136d7 Merge pull request #79642 from etcwilde/ewilde/fix-linux-swiftrt-location
CMake: Fix swiftrt.o install location
2025-02-26 17:15:28 -08:00
Doug Gregor
50d3913086 [SE-0458] Enable strict memory safety in the Swift standard library 2025-02-26 14:27:55 -08:00
Evan Wilde
7011a4091d Writing a readme on using the new build
Adding a quick readme to get folks started with using the new build and
the different ways to configure it.
2025-02-26 11:25:02 -08:00
Evan Wilde
7ed975aac2 CMake: Fix swiftrt.o install location
The driver just changed where it looks for swiftrt.o when performing a
static-stdlib build from always looking under `/usr/lib/swift` to
`/usr/lib/swift_static`.

This change of behavior comes from:
7156812d251d0f4dd6e7c605940f7e5497eaa795
2025-02-26 10:32:07 -08:00
Evan Wilde
71f9aac6e3 Merge pull request #79548 from etcwilde/ewilde/stdlib-rebuild-install-story
CMake: SwiftCore Install Story
2025-02-26 09:53:02 -08:00
Evan Wilde
2ea75b0499 Merge pull request #79455 from etcwilde/ewilde/stdlib-rebuild-macos-concurrency
CMake: Find Dispatch module
2025-02-25 11:15:41 -08:00
Evan Wilde
a0682cb54c CMake: dispatch is required for dispatch executor
The dispatch global executor depends on finding dispatch. If dispatch is
not found, it will fail to build. Mark it as required to get a
configuration failure early.
2025-02-24 16:31:41 -08:00
Evan Wilde
c4ad920475 Declare SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR
We need to define the defaulted setting so that it pulls in the default
value. Otherwise we hit a configuration failure in
`Concurrency/CMakeLists.txt` when it includes the config file specific
to the global executor because `SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR`
is an empty string.
2025-02-24 16:31:41 -08:00
Evan Wilde
6afa780fdd Add Finddispatch module
Implementing an initial `Finddispatch.cmake` module to find Dispatch
from the system SDK on Apple platforms. Still should implement a basic
mechanism for finding it on Windows and Linux. Note that those platforms
will likely use the dispatch config mechanism most frequently, but this
should still work as a fallback.

This mechanism is the only one that works for Apple platforms though as
those use libdispatch from the SDK rather than building it with
corelibs-libdispatch.

When building for Linux and Windows, it is possible to build a custom
corelibs-libdispatch runtime with `dispatch_DIR` and avoid this module.
This module makes it possible to use a pre-built corelibs-libdispatch
when one is available without needing to build it. The module uses
the `Swift_SDKROOT` filepath as a hint on where to look for the runtime
libraries and the `dispatch_STATIC` boolean to specify whether it should
find the dynamic library or the static archive.
2025-02-24 16:31:39 -08:00
Konrad `ktoso` Malawski
09003d6f11 Revert "Merge pull request #77609 from ktoso/wip-task-names" (#79562)
This reverts commit 4ab5d2604f.
2025-02-23 22:59:21 -08:00
Evan Wilde
7870db67f8 CMake: Runtime Installation Story
Starting to work on a full installation story for the Swift runtimes.
This involves generating the SwiftCoreConfig cmake files to allow
importing the just-built runtimes into the overlays and supplemental
libraries, setting up the flags appropriately for the given SwiftCore
build configuration.

This also separates out the development and runtime components to allow
installing just the runtimes without the headers.

Component List:
 - SwiftCore_runtime

  The runtime libraries that are required for running code.

 - SwiftCore_development

  The interface with the runtime libraries that are required for
  building code against the runtimes.

 - SwiftCore_cmake

  Files for interfacing CMake projects with the built runtimes.
  This includes the target list and flags needed to use the targets
  built by the specific configuration used to build the runtime
  libraries.

  These files are used for mapping flags, definitions, and locations
  into the overlay libraries and supplemental libraries.

This adds install commands for the object libraries contributing to
libswiftCore so that they are represented in SwiftCoreTargets.cmake.
Object libraries do not contribute anything to the files actually
installed.
2025-02-22 10:33:17 -08:00
Saleem Abdulrasool
10c804b0bb runtime: adjust the program name reference
`__progname` is not available on Windows, and is provided by libbsd on
Linux. This provides a replacement for the functional aspect of the
symbol on Windows.
2025-02-22 07:14:26 -08:00
Konrad `ktoso` Malawski
4ab5d2604f Merge pull request #77609 from ktoso/wip-task-names
[Concurrency] Task names
2025-02-21 22:28:33 +09:00
Evan Wilde
b1fb62de34 Merge pull request #79499 from etcwilde/ewilde/apple-swift-version-5
Set Swift language version to 5
2025-02-20 13:43:30 -08:00
Evan Wilde
f490e611e1 Merge pull request #79335 from etcwilde/ewilde/catalyst-support
CMake: Catalyst Support
2025-02-19 17:16:09 -08:00
Evan Wilde
ebc0a37760 Set Swift language version to 5
The stdlib needs to build in Swift-5 mode, and ensure that
`-swift-verion 5` be included in the commandline explicitly. While the
compiler defaults to 5 mode, if it's not included explicitly, it won't
be included in the swift interface, which then means that modules that
import it will influence how the textual interface is processed.
The interface for the stdlib must be processed in the Swift 5 language
mode due to sendability. Set it explicitly to ensure that importing
modules do not change the Swift language mode.

Fixes: rdar://145118843
2025-02-19 16:57:43 -08:00
Eric Miotto
b98ca03086 Merge pull request #79464 from edymtt/edymtt/enable-onone-support-on-apple-platforms
Runtimes: enable build of `SwiftOnoneSupport` on Apple platforms.
2025-02-19 13:24:51 -08:00