Commit Graph

93 Commits

Author SHA1 Message Date
Ian Anderson
15345ef2d5 [CMake][Darwin] Remove support for building the SDK overlays on Apple platforms
The SDK overlays have been provided in the Apple SDKs for many years, and the interface and implementation has diverged in more recent years such that trying to build the Swift version no longer works. Remove all of the dead code.

rdar://151889154
2025-05-23 23:38:08 -07:00
Eric Miotto
8c7e8550aa CMake: add explicit dependency to _Builtin_float to targets...
... that would import that as a result of importing Darwin from the SDK.

Amend my previous change to Differentiation and Distributed in this
sense.

Addresses rdar://150400049
2025-05-05 10:39:14 -07:00
Mike Ash
e3057031da [RemoteMirror] Fix AsyncTask child iteration.
Iterating child tasks depends on knowing the size of AsyncTask, and changing the size of the task broke it. Instead of relying on mirroring the full structure in our out-of-process definitions, add a debug variable to libswift_Concurrency that contains the size of AsyncTask.

While we're there, add some more validation to child task enumeration. Check each child task's metadata pointer to make sure that it actually points to the AsyncTask metadata, and have the inner loop also increment and check ChildTaskLoopCount to stop runaway iteration in that loop.
2025-04-08 13:09:29 -04:00
Allan Shortlidge
17fd27554b stdlib: Adopt internal imports to suppress some warnings in tests. 2024-11-13 09:51:29 -08:00
Daniel Rodríguez Troitiño
63022333d8 [unittest] Disambiguate references to errno (#77155)
In Xcode 16 SDKs there seem to be two `errno` visible for some files,
one in the `Darwin` module, and one in the `_errno` module (which seems
new for this Xcode version).

Disambiguate the references by prepending `Darwin`, which should be the
one that was being used before Xcode 16 SDKs.
2024-10-22 15:48:56 -07:00
Alexander Cyon
c21b1e68fd [stdlib] Fix typos 2024-07-06 13:09:57 +02:00
Alex Lorenz
57b89d5303 [android] add an android NDK Swift overlay module, and use it instead of Glibc 2024-05-28 12:57:38 -07:00
Alastair Houghton
0fa5e65bb2 [Stdlib][Build] Fix the standard library build for fully static Linux.
Mostly this just means adding `Musl` as a module dependency of various
things and making sure that we build things for `swift_static` even
if `SWIFT_BUILD_STATIC_STDLIB` isn't enabled.

There's also a slight difference in the declaration of `memcmp()`;
musl's declaration is more like the one we have on Darwin.

rdar://123508245
2024-05-07 16:56:20 +01: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
Finagolfin
09ef130457 [android] Update to LTS NDK 26c
NDK 26 renamed the directory in which it places the Android compiler-rt from
`lib64/`, and added a bunch of nullability annotations to the Bionic libc.
2024-02-28 22:11:38 +05:30
Guillaume Lessard
50b83c8e69 Merge pull request #68423 from glessard/se0405-take2
[se-0405] rename `String.init(validatingUTF8:)`
2024-01-22 09:29:21 -08:00
Nate Chandler
10ce0c6b16 [SILGen] Used move_value for lexical lets.
Instead of using begin_borrow [lexical] + copy_value.
2023-12-14 13:35:26 -08:00
Ian Anderson
4dbc58723a [CMake] [Darwin] Don't add the Darwin overlay as a dependency if the overlays aren't being built
Allow for the overlays to not be built in Darwin by respecting SWIFT_BUILD_SDK_OVERLAY.
2023-10-17 11:03:57 -07:00
Guillaume Lessard
0c916f507d [stdlib] replace uses of String(validatingUTF8:)
- use the new name `String(validatingCString:)`
2023-09-11 14:17:05 -07:00
Max Desiatov
21a2b78801 stdlib/benchmark: add canImport(Musl) where needed (#67120)
This allows compiling stdlib and benchmarks when targeting musl instead of Glibc.
2023-07-05 19:55:08 +01:00
Yuta Saito
21d1e961bc [build] Fix cmake config for reflection test without dynamic stdlib
Build SwiftReflectionTest only if swift-reflection-test is available
because it depends on the tool and the tool is not available when no
dynamic stdlib is built
2023-06-29 11:22:38 +00:00
Matt Jacobson
894abd5c3e SwiftReflectionTest: add dependency on Glibc module on FreeBSD 2022-11-18 04:46:52 -05:00
Guillaume Lessard
1cd2c5fba0 [stdlib] remove incorrect uses of pointer conversion 2022-04-01 12:10:16 -06:00
Alejandro Alonso
7e0eaf7b99 Remove metadata section functions from the stdlib (#39236)
add aliases in test suite
2021-09-14 11:55:39 -07:00
Augusto Noronha
f41d192b48 Implement projectExistentialAndUnwrapClass
Implement a version of projectExistential tailored for LLDB. There are 2
differences when projecting existentials for LLDB:

1 - When it comes to existentials, LLDB stores the address of the error
    pointer, which must be dereferenced.
2 - When the existential wraps a class type, LLDB expects the address
    returned is the class instance itself and not the address of the
    reference.

This patch also adapts the swift reflection test machinery to test
projectExistentialAndUnwrapClass as well. This is done by exposing
the new functionality from swift reflection test.  It is tested in
existentials.swift, and ensures that the typeref information is
exactly the same as what is expected from projectExistential,
except the out address.

(cherry picked from commit 55e971e06750c3ba29722d558cc5400298f6bdaf)
2021-06-16 08:54:50 -03:00
Mike Ash
31f68b1687 [RemoteMirror] Add a call for iterating over the allocations belonging to an AsyncTask.
rdar://72907056
2021-02-11 17:14:38 -05:00
3405691582
6adaf48e96 [stdlib] Add missing Glibc dependency for OpenBSD.
Otherwise, the build may fail as the build attempts to build
SwiftReflectionTest before Glibc has been built.
2021-01-24 18:10:02 -05:00
Saleem Abdulrasool
09fc82aac3 Merge pull request #34299 from compnerd/i-dont-visual-c-you
stdlib: remove `swiftMSVCRT`, replace with `swiftCRT` on Windows
2020-10-20 11:05:03 -07:00
Andrew Trick
7554a6aa31 Fix a pointer addition bug in SwiftReflectionTest. 2020-10-16 15:00:09 -07:00
Saleem Abdulrasool
2fc5cbdc14 stdlib: remove swiftMSVCRT, replace with swiftCRT on Windows
This replaces swiftMSVCRT with swiftCRT.  The big difference here is
that the `visualc` module is no longer imported nor exported.  The
`visualc` module remains in use for a singular test wrt availability,
but this should effectively remove the need for the `visualc` module.

The difference between the MSVCRT and ucrt module was not well
understood by most.  MSVCRT provided ucrt AND visualc, combining pieces
of the old MSVCRT and the newer ucrt.  The ucrt module is what you
really wanted most of the time, however, would need to use MSVCRT for
the convenience aliases for type-generic math and the deprecated math
constants.

Unfortunately, we cannot shadow the `ucrt` module and create a Swift SDK
overlay for ucrt as that seems to result in circular dependencies when
processing the `_Concurrency` module.

Although this makes using the C library easier for most people, it has a
more important subtle change: it cleaves the dependency on visualc.
This means that this enables use of Swift without Visual Studio for the
singular purpose of providing 3 header files.  Additionally, it removes
the need for the installation of 2 of the 4 support files.  This greatly
simplifies the deployment process on Windows.
2020-10-15 16:02:01 -07:00
Augusto Noronha
3cb8f9b6fc Add entrypoints to the runtime that exposes metadata necessary for reflection tests on Linux (#32339) 2020-07-24 15:26:15 -07:00
Cody Brocious
d2bd596c15 Fixed incorrect comment in SwiftReflectionTest
This code directly references several sections in the __TEXT segment but the comment refers to __DATA.
2020-03-28 17:44:00 -04:00
tbkka
0d361bd3ea Teach RemoteMirror how to project enum values (#30161)
Teach RemoteMirror how to project enum values

This adds two new functions to the SwiftRemoteMirror
facility that support inspecting enum values.

Currently, these support non-payload enums and
single-payload enums, including nested enums and
payloads with struct, tuple, and reference payloads.
In particular, it handles nested `Optional` types.

TODO: Multi-payload enums use different strategies for
encoding the cases that aren't yet supported by this
code.

Note: This relies on information from dataLayoutQuery
to correctly decode invalid pointer values that are used
to encode enums.  Existing clients will need to augment
their DLQ functions before using these new APIs.

Resolves rdar://59961527

```
/// Projects the value of an enum.
///
/// Takes the address and typeref for an enum and determines the
/// index of the currently-selected case within the enum.
///
/// Returns true iff the enum case could be successfully determined.
/// In particular, note that this code may fail for valid in-memory data
/// if the compiler is using a strategy we do not yet understand.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_projectEnumValue(SwiftReflectionContextRef ContextRef,
                                      swift_addr_t EnumAddress,
                                      swift_typeref_t EnumTypeRef,
                                      uint64_t *CaseIndex);

/// Finds information about a particular enum case.
///
/// Given an enum typeref and index of a case, returns:
/// * Typeref of the associated payload or zero if there is no payload
/// * Name of the case if known.
///
/// The Name points to a freshly-allocated C string on the heap.  You
/// are responsible for freeing the string (via `free()`) when you are finished.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_getEnumCaseTypeRef(SwiftReflectionContextRef ContextRef,
                                        swift_typeref_t EnumTypeRef,
                                        unsigned CaseIndex,
                                        char **CaseName,
                                        swift_typeref_t *PayloadTypeRef);
```


Co-authored-by: Mike Ash <mikeash@apple.com>
2020-03-06 13:17:40 -08:00
Saleem Abdulrasool
a41b4a8f14 SwiftReflectionTest: enable builds on non-Apple targets
Ensure that the swift-reflection-test binary is built for Windows by
default.  This is preventing tests from executing on Windows.  There are
dependencies which were already specified for Linux even, the tool just
was disabled due to an invalid check.
2019-10-29 08:37:49 -07:00
Alexander Shaposhnikov
6febe07dec Introduce SWIFT_COMPILE_FLAGS_LINUX 2019-07-31 16:28:04 -07:00
Puyan Lotfi
6691fda8ec Appending SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS to SWIFT_COMPILE_FLAGS.
There are situations where you want to build against a libc that is out
of tree or that is not the system libc (Or for cross build scenarios).
This is a change for passing the -sdk and include paths for things like
this.
2019-07-01 09:43:47 -07:00
Ross Bayer
23a868e9f2 Merge pull request #24382 from Rostepher/usr-lib-install-name-dir
[Build System: CMake] Update the default install_name_dir to /usr/lib/swift for the standard library and overlays.
2019-05-13 15:05:22 -07:00
Mike Ash
5b2df468fc [Reflection] Include TargetConditionals.h for WatchOS detection, not Availability.h.
While we're in there, make SwiftReflectionTest's debugLog function take an @autoclosure so we don't waste a ton of time constructing log messages that are never logged.
2019-05-08 17:51:33 -04:00
Ross Bayer
dfb2d31e74 Rename the LIBRARY_INSTALL_NAME_DIR argument in add_swift_target_library to DARWIN_INSTALL_NAME_DIR which better explains that this argument only controls the install_name_dir for Darwin platforms. 2019-04-29 16:46:09 -07:00
Ross Bayer
b855119fbe Added a new CMake cache variable to control the private standard library install_name_dir. Those libraries are not going to be installed in /usr/lib/swift and thus need to be controlled via a separate mechanism. 2019-04-29 16:46:09 -07:00
Doug Gregor
2a3b237a82 [swift-reflection-test] Strings read here are not always valid UTF-8.
The “string length” primitive was validating the string data as valid UTF-8
to get the length. However, mangled names, which get read by this operation,
are not always valid UTF-8. Just count the bytes until a ‘0’ and don’t
validate.
2019-01-27 22:03:37 -08:00
Michael Gottesman
3f17bb6ddf Carefully split the build's invocation of add_swift_library into host/target variants.
The key thing here is that all of the underlying code is exactly the same. I
purposely did not debride anything. This is to ensure that I am not touching too
much and increasing the probability of weird errors from occurring. Thus the
exact same code should be executed... just the routing changed.
2018-10-27 12:58:51 -07:00
Arnold Schwaighofer
cc7f207cec Rename swift sections from swift4 to swift5
rdar://38465220
2018-05-23 12:18:08 -07:00
Arnold Schwaighofer
0c11e1a0a3 Mark swift sections as swift4 for Swift 4.2
rdar://36363251
2018-03-14 10:27:28 -07:00
Mike Ash
6c59410943 [ReflectionMirror] Change swift-reflection-test.c to use addReflectionInfo on non-Macho platforms. 2018-03-02 17:36:33 -05:00
Mike Ash
1dcdd939ca [Reflection] Implement swift_reflection_addImage which takes care of looking up reflection info on behalf of the client.
rdar://problem/37538580
2018-02-20 16:47:07 -05:00
Arnold Schwaighofer
17cd95efa4 Rename swift3 section and global names to swift5
Such that old and new runtimes can co-exists
rdar://36363251
2018-01-22 10:04:46 -08:00
Maxim Moiseev
128092a7d6 Rename filterMap to compactMap 2017-12-18 09:22:41 -08:00
Max Moiseev
8ec6c45d2d Use filterMap to avoid deprecation warnings 2017-12-18 09:16:37 -08:00
taylor swift
c85880899d implement SE 184: add allocation methods to Unsafe buffer pointers, drop all parameters from deallocation, adjust namings, and add repeated-value assignment methods 2017-11-17 21:28:03 -08:00
Michael Gottesman
8437819b5a [CMake] Revert recent changes.
These changes caused a number of issues:

1. No debug info is emitted when a release-debug info compiler is built.
2. OS X deployment target specification is broken.
3. Swift options were broken without any attempt any recreating that
functionality. The specific option in question is --force-optimized-typechecker.

Such refactorings should be done in a fashion that does not break existing
users and use cases.

This reverts commit e6ce2ff388.
This reverts commit e8645f3750.
This reverts commit 89b038ea7e.
This reverts commit 497cac64d9.
This reverts commit 953ad094da.
This reverts commit e096d1c033.

rdar://30549345
2017-02-15 22:26:06 -08:00
Chris Bieneman
e096d1c033 [CMake] Simplify add_swift_library
This patch splits add_swift_library into two functions one which handles
the simple case of adding a library that is part of the compiler being
built and the second handling the more complicated case of "target"
libraries, which may need to build for one or more targets.

The new add_swift_library is built using llvm_add_library, which re-uses
LLVM's CMake modules. In adapting to use LLVM's modules some of
add_swift_library's named parameters have been removed and
LINK_LIBRARIES has changed to LINK_LIBS, and LLVM_LINK_COMPONENTS
changed to LINK_COMPONENTS.

This patch also cleans up libswiftBasic's handling of UUID library and
headers, and how it interfaces with gyb sources.

add_swift_library also no longer has the FILE_DEPENDS parameter, which
doesn't matter because llvm_add_library's DEPENDS parameter has the same
behavior.
2017-02-14 14:28:10 -08:00
Max Moiseev
44f0cb9daf Fix the force unwrapping of a nil pointer 2017-01-11 10:22:01 -08:00
Max Moiseev
195691523f [stdlib] Eliminating some 'unsafeBitcast' related warnings 2017-01-10 12:36:22 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00