Commit Graph

41 Commits

Author SHA1 Message Date
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
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
Evan Wilde
e59326cdd5 CMake: Move installation of binary swiftmodule
To keep things consistent with the target and target-variant swiftmodule
files, moving the installation of the binary swift module into
`install_swift_interface`. CMake implicitly generates the target
swiftmodule, but does not know about zippered binaries, so we need to
ensure that the target-variant module is available for installation when
applicable.
2025-02-18 16:29:37 -08:00
Evan Wilde
35537d449a CMake: Emit catalyst modules
If the driver supports it, emit the swiftmodules and interfaces for the
target-variant slice.
2025-02-18 09:34:17 -08:00
Evan Wilde
aa8138a9d1 CMake: Include zippered catalyst slice
Add the flags to include the zippered catalyst slice if a variant target
triple is set.
2025-02-18 09:34:15 -08:00
Evan Wilde
8fe9c094c3 Fix runtime default variable naming
The names of the variables in `DefaultSettings` should end in `_default`
so that the variable that they are defaulting can be overridden.
Otherwise CMake will just set the value and move on overriding the
setting coming from the commandline/cache file.
2025-02-17 10:44:45 -08:00
Saleem Abdulrasool
1458acb451 Merge pull request #78505 from compnerd/concurrent
Runtimes: introduce `swift_Concurrency`
2025-02-15 08:31:19 -08:00
Saleem Abdulrasool
69a3cd8e29 Apply suggestions from code review
Co-authored-by: Evan Wilde <etceterawilde@gmail.com>
2025-02-14 16:19:45 -08:00
Saleem Abdulrasool
34266f630d Runtimes: make resource embedding work on Windows
The `CMAKE_MT` path does not expand as expected. Add a workaround for
the issue so that we are able to build a dynamically linked version of
the standard library with the new runtimes build.
2025-02-14 15:14:55 -08:00
Saleem Abdulrasool
1ac0007883 Runtimes: introduce swift_Concurrency
This adds the `swift_Concurrency` module to the new runtimes build. This
is sufficient to build the code but will require further fine tuning to
ensure that all the flags entirely identical and that the ABI surface is
also fully replicated.
2025-02-13 16:24:36 -08:00
Saleem Abdulrasool
509c385458 Runtimes: attempt to embed a SxS manifest for swiftCore
This will allow us to have multiple parallel installations of swiftCore
with the same DLL name allowing us to side-step the ABI instability
without resorting to SOVERSIONing.
2025-02-12 21:59:47 -08:00
Eric Miotto
2a367234be Runtimes: support generic metadata prespecialization for all of Core
Also provide a flag to enabled/disable it.

Addresses rdar://144255917
2025-02-07 07:39:21 -08:00
Evan Wilde
95f4f6ff80 Merge pull request #78497 from etcwilde/ewilde/stdlib-rebuild-backtrace-reporting
CMake: SwiftCore: Add back SWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING
2025-01-24 21:59:55 -08:00
Evan Wilde
5aadacee41 CMake: SwiftCore: Add back SWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING
Add an option to enable emitting a stacktrace on calls to `fatalError`.
This is unrelated to the runtime backtracer for diagnosing normal Swift
crashes.

rdar://142440689
2025-01-23 12:42:28 -08:00
Evan Wilde
a9da4a5c1a CMake: Add install platform and architecture subdirs
In some configurations, libraries are installed under
`<install-prefix>/{libdir}/swift/<platform>/<arch>` and module content
is installed under `<install-prefix>/{libdir}/swift/<platform>`.

This also accounts for the fact that Swift currently looks under
`<install-prefix>/{libdir}/swift_static/**` for the static stdlib
builds.
2025-01-23 12:25:21 -08:00
Saleem Abdulrasool
c7ae8c9377 Apply suggestions from code review
Co-authored-by: Evan Wilde <etceterawilde@gmail.com>
2025-01-22 09:25:24 -08:00
Saleem Abdulrasool
530378ae79 Runtimes: extract platform and arch from the driver
With swiftlang/swift#78717 we now can extract the platform and
architecture subdirectories required for deploying the files.
Restructure the code when adding this functionality to invoke the
command once and then extract the various fields that we need.
2025-01-17 15:47:13 -08:00
Justice Adams
4666a418e0 [CMAKE] Add Plist creation to swiftCore (#77960)
* update Resync to copy plist template

* include Plist in linked library for Darwin platforms

* only embedd plist on apple platforms

* formatting fix
2024-12-17 15:49:54 -08:00
Saleem Abdulrasool
cc27fd0c98 Core: check for -mcx16 flag
The Swift runtime requires the CMPXCHG16B ISA extension on x86. This is
controlled by the `-mcx16` flag when targeting the CPU baseline that we
use. Add a check and pass along the flag to repair the build.
2024-12-13 13:59:41 -08:00
Saleem Abdulrasool
59a9ef5bb7 Merge pull request #78134 from etcwilde/ewilde/x-platform-fixes
[CMake] Fix some issues in new runtime build for Linux and Windows builds
2024-12-12 18:11:07 -08:00
Saleem Abdulrasool
fc27a28411 Merge pull request #78144 from compnerd/threading-the-needle
Core: specify the threading package that is in use
2024-12-12 17:30:03 -08:00
Saleem Abdulrasool
6d678ac01d Core: specify the threading package that is in use
This is required for the non-Darwin targets as `SWIFT_THREADING_DARWIN`
does not enable any additional code. However, that macro is used in
other places that are not yet integrated. This was identified by
building for Windows.
2024-12-12 10:48:43 -08:00
Evan Wilde
979697eb13 CMake: Fix expanding the default variable
`defaulted_set` wasn't expanding the default variable, just setting the
value of the variable the name of the variable that should have been
doing the defaulting.
2024-12-11 19:48:36 -08:00
Justice Adams
f1f3604cca remove cmake color diagnostic flags (#78098) 2024-12-11 13:37:59 -08:00
Evan Wilde
e160e23dde [CMake] Connecting more flags and options
Making a more in-depth pass over the definition macros and flags in
SwiftSource.cmake _add_target_variant_swift_compile_flags.
These are only flags that actually matter for swiftCore though. This
does not include concurrency flags.
2024-11-12 11:31:10 -08:00
Evan Wilde
2df8a185b8 [cmake] Add private build extension points
Adding vendor-specific extension points to the build system, giving
vendors a place to put their internal settings and defaults, without
having to modify the build directly. This helps reduce the chances of
merge conflicts and public changes breaking internal settings.

The location of the macros are set with `SwiftCore_PRIVATE_MODULE_DIR`,
so vendors can keep their private extensions in a separate location if
desired. Otherwise, it defaults to `cmake/modules/private`, which
intentionally does not exist at this time.

Currently, we have extensions for the default settings and global
settings.
2024-11-08 17:05:41 -08:00
Evan Wilde
148a910d7b [nfc] Add documentation to default macros
Adding documentation on the behavior of the `defaulted_option` and
`defaulted_set` macros.
2024-11-08 16:41:30 -08:00
Evan Wilde
9185606027 [cmake] Add macro to create defaulted settings
Adding a macro to tie non-boolean variables into the defaulting
mechanism.
2024-11-08 15:58:27 -08:00
Evan Wilde
2a8bb9db93 Adding ELF swiftrt for BSD and Android
BSD and Android also need to build swiftrt.o so adding it to the
default settings.
2024-11-07 15:23:52 -08:00
Evan Wilde
12fb294cce Remove SwiftCore_SWIFTC_CLANGIMPORTER_RESOURCE_DIR
The SwiftCore_SWIFTC_CLANGIMPORTER_RESOURCE_DIR is not being used so I'm
deleting it for now. This means we only grab the target info once.
2024-11-07 00:11:08 -08:00
Evan Wilde
2c07a23a45 Cleanup WMO forcing
This patch cleans up the handling of WMO-forcing in the workaround file.
`-wmo` is passed in each of the link jobs in the non-CMP0157-enabled
configuration to keep it matching the behavior of the CMP0157-enabled
builds.

This also moves the commentary about num-threads and WMO to the top of
the file to make it clearer what is going on. Ideally the file wouldn't
have to exist, but it does.

The file also contains the target install-name fix that landed in CMake
3.29.8 and CMake 3.30.2, so earlier versions of CMake 3.29 will work
with this build as well.
2024-11-07 00:00:33 -08:00
Evan Wilde
1aeab071d0 Fix rpath flag 2024-11-06 21:27:54 -08:00
Evan Wilde
4f6489f746 Fixing comments
Fixing some of the comments in DefaultSettings.cmake and
PlatformInfo.cmake.

I haven't added any vendor cache files yet, so the comment doesn't point
anywhere. Also fixing the reference to the location of the clang
resource headers in PlatformInfo.cmake.
2024-11-06 21:27:53 -08:00
Evan Wilde
2a3e6d53a0 Moving compiler-src-dir refs
Moving the rest of the references to the compiler source directory to
use the `SwiftCore_SWIFTC_SOURCE_DIR` variable instead of
`${PROJECT_SOURCE_DIR}/../../`.
2024-11-06 21:27:53 -08:00
Evan Wilde
e2b878b4e9 Setup reasonable defaults
This patch makes it simpler to setup reasonable defaults for a given
platform. The standard library has many knobs for configuration
purposes. This is great for providing cache files to configure specific
builds, but the build system should still generally work if someone runs
a minimal CMake invocation against the build without futzing with
various options.
2024-11-06 21:27:53 -08:00
Evan Wilde
03ba118bf3 Add swiftCore library
This patch hooks up the swiftCore library build and gets it installing.
This means that we have library evolution hooked up and vector types.

Building it dynamically found that we had duplicate symbols, so fixed
the swiftDemanglingCR library.

Needed to hook up the availability macros.

The flag configuration is for macOS, so we'll need to go through and
figure out what it should look like for the other platforms too.
2024-11-06 21:27:53 -08:00
Evan Wilde
f3b5fcdc15 Add stubs library to build
Adding stdlib stubs library, which uses gyb and requires knowing about
some of the platform info.

The stubs library pulls in several headers from the compiler repository.
We should probably clean that up, but not right now. I've made a note of
it.
2024-11-06 21:27:53 -08:00
Evan Wilde
96429952bb Build runtime library
Getting the runtime libraries building, while also ironing out more of
the macro definitions and flags.
2024-11-06 21:27:53 -08:00
Evan Wilde
46dfee25d1 Get swiftLLVMSupport building
This patch gets the LLVM Support object files building.
2024-11-05 08:19:43 -08:00