Commit Graph

36 Commits

Author SHA1 Message Date
Mike Ash
6a383b270e [Runtime] Ignore some global constructor warnings.
We have a few constructor functions that aren't wrapped in SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_BEGIN/SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_END and which have started to produce warnings in a new clang version. Explicitly allow these constructors by adding those.

rdar://147703947
2025-03-24 12:43:03 -04:00
Mike Ash
e4e2b23a71 [Compatibility50] Silence warning about taking the address of objc_setHook_getClass.
Add a & so the compiler doesn't think it always evaluates to true.

rdar://144465537
2025-02-11 17:11:12 -05:00
Allan Shortlidge
a549d0144e stdlib: Resolve -Wmissing-designated-field-initializers warnings. 2024-11-13 09:51:29 -08:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Alastair Houghton
21ac6149e3 Don't use tsd_private.h in compatibility libraries for ARMv7k.
If we include this file, it generates inline assembly, which would be fine
except that when apps are being built with bitcode, that isn't allowed.

rdar://103274667
2023-01-19 16:48:42 +00:00
Eric Miotto
e71eb3322a watchOS: don't target arm64/arm64e for Compatibility50/51 (#62278)
Those architectures were not supported when Swift 5.0/5.1 shipped, so it
makes little sense building those.

Addresses rdar://91128579
2022-11-30 08:41:33 -08:00
John McCall
7f737d235d Synchronize with cancellation when removing a task from a task group
We were detaching the child by just modifying the list, but the cancellation path was assuming that that would not be done without holding the task status lock.

This patch just fixes the current runtime; the back-deployment side is complicated.

Fixes rdar://88398824
2022-10-29 00:10:28 -04:00
Alastair Houghton
df9332795d [Threading] Fix compatibility library deployment target issue.
The threading library is being pulled into the compatibility libraries,
but in order to do that we need to make sure it gets built with the
correct deployment target.  (Which means we need a special version for
the compatibility libraries.)

rdar://96690200
2022-07-12 08:24:05 +01:00
Alastair Houghton
668bcbce4f [Threading] Fix a few things following rebase.
After rebasing, a few things broke.  Fix them.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
c7c1c1be80 [Threading] Fix some problems with the C11 threading code.
These changes are needed to get things building with a C11 threads shim
header on macOS.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
0e9318cec5 [Threading] Put everything through git clang-format.
Just formatting changes.

rdar://90776105
2022-06-07 07:39:53 +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
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
3a5f10356c [Threading] Fix a few things following rebase.
After rebasing, a few things broke.  Fix them.

rdar://90776105
2022-05-24 16:42:36 +01:00
Alastair Houghton
2884ddbc3e [Threading] Fix some problems with the C11 threading code.
These changes are needed to get things building with a C11 threads shim
header on macOS.

rdar://90776105
2022-05-24 14:57:42 +01:00
Alastair Houghton
b5bd267ff1 [Threading] Put everything through git clang-format.
Just formatting changes.

rdar://90776105
2022-05-24 14:57:41 +01: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
Josh Soref
644c18ca9b Spelling stdlib (#42444)
* spelling: against

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: algorithmic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: alignment

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: anything

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: architectural

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: architecture

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: are

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: artificial

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: aside

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: available

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: being

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: bidirectional

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: characters

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: circular

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: compatibility

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: compiled

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: correctly

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: covers

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: declaration

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: dependencies

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: descriptor

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: dictionaries

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: dynamic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: greater

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: hierarchy

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: immortal

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialize

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initializes

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: iterable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: message

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: minimum

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: multiple

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: originally

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: simplified

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: sophisticated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: trivia

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: wasn't

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-19 14:02:43 -07:00
Kuba (Brecka) Mracek
c079c0897b Split SWIFT_DARWIN_PLATFORMS and SWIFT_APPLE_PLATFORMS in CMake. SWIFT_APPLE_PLATFORMS may contain 'FREESTANDING' when building the freestanding SDK and SWIFT_FREESTANDING_FLAVOR is set to 'apple'. (#38997) 2021-08-23 19:16:28 -07:00
Joe Groff
13e6566e2e Compatibility50: Use __dso_handle for cheaper main executable check.
rdar://70959417
2021-04-12 13:01:45 -07:00
Alejandro Alonso
424802fb34 Revert SE-0283 (#34492)
Reverted despite build failures.
2020-10-29 17:32:06 -07:00
Azoy
df9778e2e8 [Compatibility53] Add compatibility library for 5.3 and backport tuple Equatable conformance
Fix some comments

Unnecessary cast
2020-10-22 18:27:03 -04:00
Mike Ash
ecd6d4ddec Add a new ConcurrentReadableHashMap type. Switch the protocol conformance cache
to use it.

ConcurrentReadableHashMap is lock-free for readers, with writers using a lock to
ensure mutual exclusion amongst each other. The intent is to eventually replace
all uses ConcurrentMap with ConcurrentReadableHashMap.

ConcurrentReadableHashMap provides for relatively quick lookups by using a hash
table. Rearders perform an atomic increment/decrement in order to inform writers
that there are active readers. The design attempts to minimize wasted memory by
storing the actual elements out-of-line, and having the table store indices into
a separate array of elements.

The protocol conformance cache now uses ConcurrentReadableHashMap, which
provides faster lookups and less memory use than the previous ConcurrentMap
implementation. The previous implementation caches
ProtocolConformanceDescriptors and extracts the WitnessTable after the cache
lookup. The new implementation directly caches the WitnessTable, removing an
extra step (potentially a quite slow one) from the fast path.

The previous implementation used a generational scheme to detect when negative
cache entries became obsolete due to new dynamic libraries being loaded, and
update them in place. The new implementation just clears the entire cache when
libraries are loaded, greatly simplifying the code and saving the memory needed
to track the current generation in each negative cache entry. This means we need
to re-cache all requested conformances after loading a dynamic library, but
loading libraries at runtime is rare and slow anyway.

rdar://problem/67268325
2020-08-20 13:05:30 -04:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
Saleem Abdulrasool
9dadc0d9c7 standard library: remove use of LLVM.h in the compatibility
Remove the use of the `LLVM.h` forward declarations from the
compatibility shims.  This allows us to fully isolate the target side
from the LLVM namespace ensuring that we prevent ODR violations when
LLVM is linked into the same address space.
2020-05-13 10:46:05 -07:00
Eric Miotto
717eeb912d [build] specify deployment targets for compatibility libraries (#31473)
This is needed in situations where the minimum deployment target is
specified in build-script -- these libraries do not to obey to that
since we need to ensure we are able to back deploy those correctly.

Addresses rdar://59249988
2020-05-04 08:22:35 -07:00
Joe Groff
ca48939816 Compatibility51: Backport the 5.2 implementation of the conformance cache.
The runtime that shipped with Swift 5.1 and earlier had a bug that interfered with backward
deployment of binaries that dynamically check for protocol conformances on conditionally-available
tests. This was fixed in the top-of-tree Swift runtime by https://github.com/apple/swift/pull/29887;
however, that doesn't do much good for running binaries on older OSes that don't have that fix.
In order for binaries built with a newer Swift compiler to run successfully on older OSes,
introduce a compatibility hook that replaces the conformance cache implementation in the original
OS runtime with a version based on the current implementation that has the fix for the protocol
conformance bug. Fixes rdar://problem/59460603
2020-04-24 10:52:29 -07:00
Joe Groff
42514f42e0 Start a Compatibility51 library for backporting fixes to Swift 5.1 runtimes 2020-04-17 10:41:48 -07:00
Joe Groff
4c92234662 Compatibility50: Install objc_getClass hook only in main executable
Xcode and other build systems currently link the compatibility libraries into every executable
or dynamic library, which can cause a chain of objc_getClass compatibility hacks to pile up if
a program loads a lot of dynamic libraries. In the static constructor that installs the
objc_getClass compatibility shim, check whether it's running on behalf of the main executable
before installing the shim.
2020-04-07 16:23:29 -07:00
Mike Ash
c9f9350e74 [Compatibility50] Look up swift_getObjCClassMetadata at runtime.
This is the only dependency it has on libswiftCore. Looking this up at runtime allows its use in programs that don't link libswiftCore but might eventually load and run Swift code, such as xctest.

While we're in there, enable tests in files ending with `.c`.

rdar://problem/55274114
2019-10-10 12:10:39 -04:00
Jonas Devlieghere
61d2efc822 [Compatibility50] Include dlfcn.h 2019-09-18 19:30:03 -07:00
Joe Groff
427ed9c79d Compatibility50: Fix for high-bit characters. 2019-09-06 18:19:19 -04:00
Joe Groff
624ad4fcb0 Compatibility50: Backport objc_getClass hook patch.
We don't want older runtimes trying to chase rogue symbolic references through objc_getClass
either. rdar://problem/55036306
2019-09-05 10:46:15 -07:00
Mike Ash
ce26e7f3fd [Runtime] Fix protocol conformances on NULL types when back deploying.
Add code to the 5.0 compatibility library that scans for conformances pointing to a NULL type and rewrites them to point to a dummy type that the 5.0 protocol conformance checking code will safely ignore.
2019-08-14 11:07:31 -04:00
Alex Langford
a16c71cc86 [CMake] Remove TARGET_LIBRARY option from add_swift_target_library
If you're calling add_swift_target_library, you already know it's a
target library.
2019-07-24 14:55:08 -07:00
Ross Bayer
1a8dff82be [Build System: CMake] Move the Compatibility50 library into the stdlib/toolchain source directory. 2019-07-23 15:34:17 -07:00