Commit Graph

42 Commits

Author SHA1 Message Date
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
Mike Ash
7f2d4be642 [Runtime] Use CMake variable to control os_trace_lazy_init usage.
SWIFT_BNI_OS_BUILD isn't exactly what we need. Use an option to turn it on/off instead.

rdar://128408295
2024-05-20 17:39:01 -04:00
Doug Gregor
922e3daaea Remove build infrastructure for globally enabling noncopyable types
Now that the compilation model of noncopyable types is enabled everywhere,
and one can enable the feature for specific modules, we no longer need a
separate build-script/CMake option to enable it globally. Remove it all.
2024-03-19 13:35:31 -07:00
Kavon Farvardin
149c052ec5 use new noncopyable types infrastructure
The infrastructure underpinning the new feature NoncopyableGenerics is
mature enough to be used.
2024-03-14 23:10:44 -07:00
Arnold Schwaighofer
ea70aea43c IRGen: Add code to support building fragile resilient protocol witnesses
We don't currently support building resilient relative protocol witness tables.
One might want to build with relative witness tables but not need
resilient protocols. Allow for that scenario.

Add a test configuration to test library-evolution + fragile resilient
protocols + relative protocol witness tables.
2024-03-10 09:14:08 -07:00
Kavon Farvardin
b92fe5f2e9 [build-script] fix NoncopyableGenerics option
This patch introduces `--enable-experimental-noncopyable-generics` for
the build script. It replaces
`--swift-stdlib-experimental-noncopyable-generics`

The old build option only enables the feature when building the
stdlib, but if we've built the stdlib with NoncopyableGenerics, the
compiler should be hardwired to have that feature enabled, too.

This patch also introduces the `noncopyable_generics` lit parameter, so
that tests assuming the system was built with the feature can live
in-tree and be tested, if they specify `REQUIRES: noncopyable_generics`.
2024-01-23 22:41:59 -08:00
Rokhini Prabhu
6dbf4d2e20 Add support for task-to-thread model to be specified on as part of build presets 2023-12-21 16:00:25 -08:00
Rokhini Prabhu
ed8ed32dba Clean up Concurrency build system so that all the logic around choice of
which executor for which type of setting, is consolidated and we have a
single knob we use to determine when to use dispatch as our global
executor.

Radar-Id: rdar://problem/119416196
2023-12-13 16:09:51 -08:00
Eric Miotto
3d71dbb04b CMake: allow to only build Core and Onone when building the stdlib (#69747)
This is needed for some Apple internal configurations that needs to build the
standard library in pieces to construct an SDK.
Given the limited audience, only introduce this flag in CMake.

Addresses rdar://118178539
2023-11-09 14:06:42 -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
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
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
Volodymyr Sapsai
4c480d5fa7 Add and install a parent module map for Swift shims. NFC intended.
Header search path for Swift shims is "usr/lib/swift". Don't rely on
clang looking for module maps in immediate subdirectories like "shims"
but add a module map to "usr/lib/swift" sourcing "shims" modules.

rdar://106677321
2023-08-22 12:16:46 -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
Alastair Houghton
e5ece81cc9 [Freestanding] Remove uses of stat() and dlsym().
We shouldn't be using stat() or dlsym() in the freestanding
runtime.

rdar://111214571
rdar://106555012
2023-06-23 17:05:59 +01:00
Mike Ash
110f428780 [Runtime] Add tracing for section scans.
Section scans (for metadata, protocols, etc.) can be costly. This change adds tracing calls to those scans so we can more easily see how much time is spent in these scans and where they're initiated.

This adds an os_signpost implementation controlled by SWIFT_STDLIB_TRACING, and a default empty implementation for when that's disabled.

rdar://110266743
2023-06-14 12:07:44 -04:00
Max Desiatov
f4937efcbe [NFC] fix option description typo in StdlibOptions.cmake
`Concurrency require libdispatch` -> `Concurrency requires libdispatch`
2023-05-31 15:22:23 +01:00
Dario Rexin
e18d71c2ad [Build] Only require libdispatch source on non-Darwin (#66081) 2023-05-23 13:17:14 -07:00
Max Desiatov
5275255d58 Move SWIFT_CONCURRENCY_USES_DISPATCH to StdlibOptions.cmake
It is only used in the stdlib build, so really has no business being set in the root `CMakeLists.txt`.
2023-05-10 19:36:27 +01:00
Alastair Houghton
0261a29fee [Backtracing] Support specifying a hard-coded path for swift-backtrace.
Add a way to disable dynamic lookup of the backtracer path, for situations
where a hard-coded path makes more sense.

rdar://107360391
2023-03-29 15:08:48 +01:00
Arnold Schwaighofer
770648f161 Initial runtime changes to support relative protocol witness tables 2023-01-31 10:59:37 -08:00
Kuba (Brecka) Mracek
e9d1d3096a Stop using SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY under SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY (#62735)
Using single-threaded concurrency was a temporary solution, now that the task-to-thread model actually supports multiple threads, let's switch off of it. Instead, let's introduce a "global executor none" option (implicitly set under the task-to-thread model) to denote that the concurrency model is not using a global executor.

rdar://99448771
2023-01-03 15:24:57 -08: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
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
Yuta Saito
8c598e98f7 [Wasm][Runtime] Interpret absolute function pointer in runtime structures
When SWIFT_COMPACT_ABSOLUTE_FUNCTION_POINTER is enabled, relative direct
pointers whose pointees are functions will be turned into absolute
pointer at compile-time.
2022-04-02 04:32:41 +00:00
Alastair Houghton
f204f0634b Add a build option for the concurrency tracing feature.
Concurrency tracing was enabled depending on the presence of a header
file, but if a similarly named header was found somewhere in the path
that didn't do the same thing, that might cause problems.

Instead, we should have a build time configuration option.

rdar://89787540
2022-03-09 12:53:10 +00:00
Kuba (Brecka) Mracek
05a17cc622 Enable -disable-preallocated-instantiation-caches for the freestanding stdlib (#41170) 2022-02-04 06:53:32 -08:00
Kuba (Brecka) Mracek
e6a1e23a9f Add SWIFT_STDLIB_ENABLE_VECTOR_TYPES to take away support for SIMD (#41149) 2022-02-02 12:06:45 -08:00
Eric Miotto
447a1673d5 Migrate more options to StdlibOptions.cmake
At the same time, convert the conditions that test for Darwin platforms
to use `SWIFT_DARWIN_PLATFORMS` instead.

Addresses rdar://87147214
2022-01-13 10:45:48 -08:00
Eric Miotto
b349f0953b Ensure SWIFT_DARWIN_PLATFORMS is defined when loading stdlib options
This was missed when working on #40723 and will prevent
`SWIFT_STDLIB_HAS_ASL` having a wrong default.
2022-01-06 12:51:14 -08:00
Eric Miotto
127528a3d0 Move more Standard Library options to dedicated file (#40723)
This addresses most of the options with computed defaults.

Addresses rdar://86723940
2022-01-06 07:12:18 -08:00
Eric Miotto
526e77cbe3 Migrate options from stdlib/CMakeLists.txt into dedicated file (#40640)
Focus on options that are not defined in `StandaloneOverlay.cmake` and
which defaults are not computed.

Addresses rdar://86723819
2021-12-23 07:10:04 -08:00
Kuba (Brecka) Mracek
663a6fb771 Introduce SWIFT_STDLIB_HAS_TYPE_PRINTING flag to remove the ability to print types at runtime (to save codesize) (#40649) 2021-12-21 17:47:54 -08:00
Eric Miotto
871c6b9b6c [CMake] Begin moving Standard Library options in a separate file (#40610)
This allows the file to be easily included where needed (e.g.
`StandaloneOverlay.cmake`) and reduce the likelihood of miscompilation
due to missing sensible defaults.

As a start, focus on a handful of parameters that got added/modified in
recent PRs.

Addresses rdar://85978195
2021-12-20 07:36:27 -08:00