Commit Graph

184 Commits

Author SHA1 Message Date
Rintaro Ishizaki
f327bf7616 [CMake] Correct dependencies
HeaderDependencies.cpp and the stdlib filelist didn't have dependencies.
That causes issues when the content is changed.
2023-11-16 13:54:14 -08:00
Mike Ash
967c5c6a75 Merge pull request #69542 from mikeash/retain-release-override-optional
[Runtime] Add option to remove override point for retain/release.
2023-11-08 19:51:29 -05:00
Egor Zhdan
f8b5143573 [build] Respect DEPLOYMENT_VERSION_{IOS|TVOS|WATCHOS} for Swift sources
See https://github.com/apple/swift/pull/69512

rdar://117699474
2023-11-06 16:20:24 +00:00
Mike Ash
6606850232 [Runtime] Add option to remove override point for retain/release.
Add a `SWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE` CMake option. When set to true, swift_retain/release and the other functions in InstrumentsSupport.h can be overridden by setting the appropriate global function pointer, as is already the case. When set to false, those function pointers are removed and the functions always go into the default implementation.

Set `SWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE` to false when building the minimal stdlib, and set it to true otherwise by default.

rdar://115987924
2023-10-31 15:26:01 -04:00
Egor Zhdan
e192ee24d1 [build] Respect DEPLOYMENT_VERSION_OSX for Swift-only targets
The CMake flag `DEPLOYMENT_VERSION_OSX` is currently only passed to the C compiler. This change makes sure it is also passed to the Swift compiler, e.g. when building Swift-only targets like Cxx or CxxStdlib.

rdar://117699474
2023-10-30 19:22:02 +00:00
Kavon Farvardin
3da894d704 [NoncopyableGenerics] provide stdlib build option
This helps set the stage for getting the stdlib building
correctly with `NoncopyableGenerics` enabled. Disabled by
default for now so this is an NFC.
2023-10-25 09:27:36 -07:00
Eric Miotto
03c490cc11 [CMake] add option to generate API descriptors for the standard library (#69228)
This would be needed to stop using `swift-api-extract` in some
internal configurations.

Given the limited scope, only add this as a CMake flag.

Addresses rdar://117019309
2023-10-18 07:23:27 -07:00
Kuba (Brecka) Mracek
75838507d8 Merge pull request #68929 from kubamracek/embedded-sdk3
[embedded] Resolve empty -sdk path warning in embedded stdlib build, take 3
2023-10-03 07:02:19 -07:00
Kuba Mracek
d579c62fee [embedded] Resolve empty -sdk path warning in embedded stdlib build, take 3 2023-10-02 17:55:02 -07:00
Kuba Mracek
268a1e3556 Revert "[embedded] Resolve empty -sdk path warning in embedded stdlib build, take 2"
This reverts commit a1a48b5c83.
2023-10-02 09:35:21 -07:00
Kuba Mracek
a1a48b5c83 [embedded] Resolve empty -sdk path warning in embedded stdlib build, take 2 2023-09-28 09:17:32 -07:00
Kuba Mracek
0962d826b3 Revert "[embedded] Resolve empty -sdk path warning in embedded stdlib build"
This reverts commit 1b1db053d5.
2023-09-27 23:10:31 -07:00
Kuba Mracek
1b1db053d5 [embedded] Resolve empty -sdk path warning in embedded stdlib build 2023-09-27 14:50:25 -07:00
Kuba Mracek
3cacb3659d [embedded] Do not emit .swiftinterface files for fragile modules (embedded stdlib, Cxx.swiftmodule) 2023-09-26 17:59:19 -07:00
Rintaro Ishizaki
18d791ccfd [CMake] Avoid add_custom_command output being used from multiple target
without a target. Because Xcode generator  doesn't like it.
Use add_custom_command_target instead.
2023-09-19 16:58:12 -07:00
Kuba Mracek
ae2e903574 [embedded] Build an initial embedded Swift standard library
This isn't a "complete" port of the standard library for embedded Swift, but
something that should serve as a starting point for further iterations on the
stdlib.

- General CMake logic for building a library as ".swiftmodule only" (ONLY_SWIFTMODULE).
- CMake logic in stdlib/public/core/CMakeLists.txt to start building the embedded stdlib for a handful of hardcoded target triples.
- Lots of annotations throughout the standard library to make types, functions, protocols unavailable in embedded Swift (@_unavailableInEmbedded).
- Mainly this is about stdlib functionality that relies on existentials, type erasure, metatypes, reflection, string interpolations.
- We rely on function body removal of unavailable functions to eliminate the actual problematic SIL code (existentials).
- Many .swift files are not included in the compilation of embedded stdlib at all, to simplify the scope of the annotations.
- EmbeddedStubs.swift is used to stub out (as unavailable and fatalError'd) the missing functionality.
2023-09-16 12:38:46 -07:00
Rintaro Ishizaki
a182bdf584 [CMake] Update source file list only if different
Use 'copy_if_different' instead of 'file(GENERATE'. Somehow
'file(GENERATE' failed with

  CMake Error: Files to be generated by multiple different commands:
2023-09-15 13:46:49 -07:00
Rintaro Ishizaki
b888abfd38 [CMake] Update source file list only if different
Write source file list using 'file(GENERATE' so that they are updated
only if thier content is changed. Otherwise stdlib modules are rebuild
everytime cmake configuration happens.
2023-09-15 10:37:40 -07:00
Rintaro Ishizaki
ca41171be5 [CMake] Copy '.private.swiftinteface' to swift_static.
'.private.swiftinterface' should be a part of the module. And it's
declared as `OUTPUT` file list, but they were never created. Because of
that the target was always rebuilt.
2023-09-15 10:35:16 -07:00
Ben Barham
afd3f172cb [stdlib] Set PYTHONIOENCODING when building the stdlib
Ubuntu 18.04 seems to be defaulting to 'ascii', causing an error when
using line-directive combined with the utf-8 diagnostic output used when
early swift syntax is enabled.
2023-08-30 11:41:11 -07:00
Rintaro Ishizaki
0aa0aac72e [CMake] Always use builder's runtime for building Swift code in Linux
Some non-stdlib thing e.g. swift-backtrace still might be built before
the runtime is built. For building Swift code in Linux "hosttools",
always set 'LD_LIBRARY_PATH' to the runtime in the builder.
2023-08-29 16:36:24 +00:00
Saleem Abdulrasool
3f828e915a build: ensure that we push -static into the flags
The CxxStdlib module is built statically only.  We would previously
build the static library but indicate dynamic linking.  This would
incorrectly code generate in the client on Windows making it impossible
to use the module.
2023-08-07 08:51:55 -07:00
Evan Wilde
669285fd17 Merge pull request #65534 from stephank/fix/cmake-3.25
build: fix accidental cmake expansions
2023-07-24 09:44:14 -07:00
Stéphan Kochen
7b460ce495 build: fix accidental cmake expansions
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:

- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
  expands to 1, where it would previously coerce to a string.

- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
  left-hand side expands twice.

In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:

- Quoted right-hand side of `STREQUAL` where I was confident it was
  intended to be a string literal.

- Removed manual variable expansion on left-hand side of `STREQUAL`,
  `MATCHES` and `IN_LIST` where I was confident it was unintended.

Fixes #65028.
2023-07-17 21:50:50 +02:00
Alex Lorenz
045fcf3ff5 [interop] Prohibit use of C++ APIs in public interfaces that opt-in into library evolution
The CxxStdlib overlay now has to be built without library evolution enabled.
2023-04-13 10:48:09 -07:00
Evan Wilde
e5bbffc38b Handle catalyst interface swap
Need to swap out the private interface for catalyst builds.
2023-04-03 15:48:44 -07:00
Evan Wilde
14956ef82b Build private swift interface files from stdlib
We have various pieces of SPI that are getting used in tests that are
failing occasionally. The swiftmodule file has the SPI, so if the
compiler loads from the swiftmodule file, everything works fine. If the
compiler loads the interface from the swiftinterface file, it fails to
find the `startOnMainActor` declaration.
2023-03-23 10:45:04 -07:00
Alejandro Alonso
09b1476ddf Stop building Reflection 2023-03-14 11:49:38 -07:00
Evan Wilde
2785d18061 Enable swift color diagnostics in stdlib
I want pretty colors. I will have my pretty colors. :)
2023-03-04 23:40:13 -08:00
Philippe Hausler
8a7f6009b9 Initial draft of observation 2023-02-27 17:09:00 -08:00
Arnold Schwaighofer
e12130c19c Add swift-async-frame-pointer=never when relative protocol witness tables is on
Building a static library in debug does not work when using
swift-async-frame-pointer.
2023-02-01 07:12:49 -08:00
Arnold Schwaighofer
770648f161 Initial runtime changes to support relative protocol witness tables 2023-01-31 10:59:37 -08:00
Alejandro Alonso
c7a9360806 [Reflection] Build the _Runtime and Reflection modules (#62973)
* Move Runtime into _Runtime

Fix more _Runtime names

* Add availability to all API

* Build _Runtime and Reflection modules

* Use threading's mutex for all platforms

add stdlib include
2023-01-17 09:30:16 -08:00
Egor Zhdan
42c7ce1a34 [cxx-interop] NFC: Remove unused CMake build logic 2022-12-08 11:22:34 +00:00
Egor Zhdan
c2c3ea7e07 [cxx-interop] Make Cxx Swift library static
Instead of a dynamic `swiftCxx.dylib` library, let's build a static library to simplify backdeployment and reduce potential compatibility difficulties in the future.

This also adds `NO_LINK_NAME` option to `add_swift_target_library` to prevent the CMake scripts from passing `-module-link-name` to swiftc when building a given module. This fixes linker errors, which would otherwise occur due to the force-load symbol name (`_swift_FORCE_LOAD_$xyz`) being emitted for the libraries that are now static (`swiftCxx`, `swiftstd`).
2022-12-07 12:37:25 +00:00
Matt Jacobson
61cf0970a1 build: support bootstrapped build on FreeBSD
Fixes failures to link and run the bootstrapping1 compiler.
2022-11-03 17:34:26 -04:00
Kuba (Brecka) Mracek
6f77e8bb70 Split out SWIFT_ENABLE_REFLECTION into a separate SWIFT_STDLIB_REFLECTION_METADATA CMake flag to control whether stdlib is built with reflection metadata or not (#61496) 2022-10-13 17:26:25 -07:00
Alexis Laferrière
875c0a0d41 [cmake] Ignore required explicit availability in Swift stdlib 2022-09-19 09:06:37 -07:00
Alexis Laferrière
20fb48167f Revert "[cmake] Ignore required explicit availability in Swift stdlib"
This reverts commit 4bec9d54e7.
2022-09-16 09:49:59 -07:00
Alexis Laferrière
4bec9d54e7 [cmake] Ignore required explicit availability in Swift stdlib 2022-09-14 17:00:18 -07:00
Nate Chandler
b03904d704 [Freestanding] Use task-to-thread concurrency model.
Defined SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY to describe
whether the standard library will use the task-to-thread model for
concurrency.  It is true only for freestanding non-Darwin stdlibs.

When it is true, SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL is defined
during stdlib compilation of both Swift and C++ sources.

Added an option to LangOptions to specify which concurrency model is
used, either standard or task-to-thread.  When
SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY is true, the model is
specified to be task-to-thread.
2022-07-06 11:51:14 -07:00
Alastair Houghton
b5735559eb [Threading] Fix threading package defaults.
These are better done via the SwiftConfigureSDK mechanism rather than
how I was doing them previously.  Additionally, I've changed the way
that the swift-threading-package option works.  In addition to
specifying just a single package name, you can specify it as a CMake
list (i.e.  separate by semicolons) of colon-separated `sdk:package`
pairs, e.g.  `osx:darwin;linux:pthreads`.  You can also override it
for all SDKs and then specify for a given SDK; specifications for a
particular SDK take precedence over the global override.  For instance
`pthreads;osx:darwin` says to use `pthreads` except on the OS X SDK
where we should use `darwin`.
2022-06-30 16:07:00 +01:00
Alastair Houghton
f5bdb858e0 [Threading] Create new threading library and use it.
Moved all the threading code to one place.  Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.

rdar://90776105
2022-06-07 07:39:51 +01:00
Alastair Houghton
0cf687aa2b [Build][Runtime] Replace SWIFT_STDLIB_SINGLE_THREADED_RUNTIME.
SWIFT_STDLIB_SINGLE_THREADED_RUNTIME is too much of a blunt instrument here.
It covers both the Concurrency runtime and the rest of the runtime, but we'd
like to be able to have e.g. a single-threaded Concurrency runtime while
the rest of the runtime is still thread safe (for instance).

So: rename it to SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY and make it just
control the Concurrency runtime, then add a SWIFT_STDLIB_THREADING_PACKAGE
setting at the CMake/build-script level, which defines
SWIFT_STDLIB_THREADING_xxx where xxx depends on the chosen threading package.

This is especially useful on systems where there may be a choice of threading
package that you could use.

rdar://90776105
2022-06-07 07:39:51 +01:00
Alex Hoppen
4aa2bbbf06 Revert "Merge pull request #42447 from al45tair/eng/PR-90776105"
This reverts commit 8bcb71140f, reversing
changes made to c4dd271d36.
2022-06-02 18:03:23 +02:00
Alastair Houghton
63a09007a1 [Threading] Create new threading library and use it.
Moved all the threading code to one place.  Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.

rdar://90776105
2022-05-24 14:57:39 +01:00
Alastair Houghton
dadcb04ae2 [Build][Runtime] Replace SWIFT_STDLIB_SINGLE_THREADED_RUNTIME.
SWIFT_STDLIB_SINGLE_THREADED_RUNTIME is too much of a blunt instrument here.
It covers both the Concurrency runtime and the rest of the runtime, but we'd
like to be able to have e.g. a single-threaded Concurrency runtime while
the rest of the runtime is still thread safe (for instance).

So: rename it to SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY and make it just
control the Concurrency runtime, then add a SWIFT_STDLIB_THREADING_PACKAGE
setting at the CMake/build-script level, which defines
SWIFT_STDLIB_THREADING_xxx where xxx depends on the chosen threading package.

This is especially useful on systems where there may be a choice of threading
package that you could use.

rdar://90776105
2022-05-24 14:57:38 +01:00
Karoy Lorentey
1e6bab05f7 [build] Add build options to force-enable debug preconditions and to set a trap function in the stdlib
(The underlying functionality was added in #41445 and #41449, respectively.)
2022-05-06 18:39:39 -07:00
Xi Ge
f7f7baa874 cmake: specify stdlib and overlays with an API library-level 2022-04-10 19:34:23 -07:00
Slava Pestov
ed23f4fd9d Merge pull request #42113 from slavapestov/gsb-off
Turn off the GenericSignatureBuilder
2022-04-02 11:04:24 -04:00