Commit Graph

45 Commits

Author SHA1 Message Date
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
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
Yuta Saito
cdd01f9df2 [wasm][cmake] Add WASI specific stdlib dependencies
WASI target has its own libc module WASILibc, so we need to add it as
well as other libc modules.
2023-09-25 18:18:50 +00: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
Evan Wilde
f8a54181a9 Zipper all the things!
This patch goes through and adds zippering and the swift module
dependencies to a bunch of pieces of the swift runtimes. Here's to
hoping I hit everything that needed to be hit. :D

With this patch, I'm seeing the appropriate modules under
lib/swift/maccatalyst, so things seem to be working right.
2022-12-22 13:41:59 -08:00
Max Desiatov
7b1f0707e9 Gardening: fix typo in SwiftPrivateThreadExtras.swift
`has a only single thread` -> `is single-threaded`
2022-01-12 16:16:29 +00:00
Max Desiatov
372ada0e24 test: add handling for Wasm/WASI (#39519)
This change adds support for WASI in stdlib tests. Some tests that expect a crash to happen had to be disabled, since there's currently no way to observe such crash from a WASI host.
2022-01-12 14:24:50 +00:00
Kuba (Brecka) Mracek
750ba09ef4 Introduce SWIFT_FREESTANDING_FLAVOR to select whether the FREESTANDING stdlib should be built/tested using an Apple SDK, or another SDK (e.g. Linux, not implemented yet) (#34450) 2021-08-19 15:56:04 -07:00
Kuba (Brecka) Mracek
d7dfa3e942 Bring up tests + validation tests for the 'freestanding' build and the standalone_minimal preset (#34386) 2020-10-26 16:32:36 -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
Robert Widmann
cddf73ecdb [Gardening] Clean Up OS-Test Patterns Across The Codebase
Clean up a few general patterns that are now obviated by canImport

This aligns more generally with the cleanup that the Swift Package
Manager has already done in their automated XCTest-plumbing tool in
apple/swift-package-manager#1826.
2020-06-30 22:55:58 -07:00
Saleem Abdulrasool
364981f52c SwiftPrivateThreadExtras: correct misuse of API
Copy out the result rather than form a dangling pointer.  This fixes the
incorrect usage that the compiler flags.
2020-06-28 19:18:32 -07:00
3405691582
f8d0174b85 Build system recognizes OpenBSD.
Commit for CMake and build scripts to recognize OpenBSD. To keep this
commit relatively short, this just deals with the rather simple and
uncontroversial changes to the build system.

Note that OpenBSD calls "x86_64" as "amd64", Since the Swift stdlib will
be put in a subdirectory named after ARCH, to ensure the standard
library is properly found later, we use the native architecture name for
OpenBSD in the build system rather than trying to deal with the
difference the other way around.
2020-04-03 13:34:17 -04:00
3405691582
d69912761a Ensure consistency of ordering in preprocessor conditionals.
Co-Authored-By: Xiaodi Wu <13952+xwu@users.noreply.github.com>
2020-03-03 20:24:06 -05:00
3405691582
c787d50984 Fix typo in SwiftPrivateThreadExtras.
Co-Authored-By: Sergej Jaskiewicz <broadwaylamb@users.noreply.github.com>
2020-03-03 20:24:06 -05:00
3405691582
5847726f51 Preliminary support for OpenBSD in the stdlib.
These should hopefully all be uncontroversial, minimal changes to deal
with progressing the build to completion on OpenBSD or addressing minor
portability issues. This is not the full set of changes to get a
successful build; other portability issues will be addressed in future
commits.

Most of this is just adding the relevant clauses to the ifdefs, but of
note in this commit:

* StdlibUnittest.swift: the default conditional in _getOSVersion assumes
  an Apple platform, therefore the explicit conditional and the relevant
  enums need filling out. The default conditional should be #error, but
  we'll fix this in a different commit.

* tgmath.swift.gyb: inexplicably, OpenBSD is missing just lgammal_r.
  Tests are updated correspondingly.

* ThreadLocalStorage.h: we use the pthread implementation, so it
  seems we should typedef __swift_thread_key_t as pthread_key_t.
  However, that's also a tweak for another commit.
2020-03-01 12:50:06 -05:00
Daniel Rodríguez Troitiño
5e05ce5ff9 [android] Enable SwiftPrivateThreadExtras to build in Android.
Disabled by mistake in #29530.
2020-02-13 14:15:49 -08:00
Max Desiatov
67297904ac [WebAssembly] Add ifdefs for the WASI target 2020-02-08 07:37:10 +00:00
Chris Amanse
e13ea48dcd Private method should be for non-Windows only 2020-01-29 14:14:12 -08:00
Chris Amanse
ffa6bf4729 Fix memory leaks in ThreadBarriers.swift (#12212)
* Fix memory leaks in ThreadBarriers.swift

* Fatal error on pthread cond/mutex destroy failure

* Rename pthread to thread

* Fix pthread init function calls

* Fix guard statement
2020-01-29 08:21:52 -08: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
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
Saleem Abdulrasool
83b290438c Windows: bridge BOOL to Bool
This allows the conversion of the Windows `BOOL` type to be converted to
`Bool` implicitly.  The implicit bridging allows for a more ergonomic
use of the native Windows APIs in Swift.

Due to the ambiguity between the Objective C `BOOL` and the Windows
`BOOL`, we must manually map the `BOOL` type to the appropriate type.
This required lifting the mapping entry for `ObjCBool` from the mapped
types XMACRO definition into the inline definition in the importer.

Take the opportunity to simplify the mapping code.

Adjust the standard library usage of the `BOOL` type which is now
eclipsed by the new `WindowsBool` type, preferring to use `Bool`
whenever possible.

Thanks to Jordan Rose for the suggestion to do this and a couple of
hints along the way.
2019-04-25 17:52:08 -07:00
Mike Ash
4fb99998ae [Build] Use magic linker symbols to specify an @rpath-relative install name when targeting pre-stable-ABI OSes.
Magic symbols of the form $ld$install_name$os9.0$@rpath/libswiftCore.dylib tell the linker to use that install name when targeting that OS version. Use these symbols to specify an @rpath install name for all back-deployment libraries when targeting watchOS 2.0-5.1, iOS 7.0-12.1, and macOS 10.9-10.14.

rdar://problem/45027809
2019-03-22 10:04:39 -04:00
Saleem Abdulrasool
dcc10ba39f SwiftPrivateThreadExtras: address improvement suggestions
Use `ThreadHandle(bitPattern:)` rather than `unsafeBitCast` for the
conversion of the `uintptr_t` to the `HANDLE`.  Convert a variable from
`var` to `let` binding.
2019-02-16 10:31:04 -08:00
Saleem Abdulrasool
59371dba24 SwiftPrivateThreadExtras: fix casting due to API changes
The recent changes to the UnsafemutablePointer prevented the "abuse" of
the type for casting.  Switch to `unsafeBitCast`.  This should repair
the Windows build.
2019-02-13 08:13:47 -08:00
Xiaodi Wu
9fe28c6e55 [gardening] Fix header comments [NFC] 2018-12-02 15:38:41 -05:00
Saleem Abdulrasool
98d71ff38f SwiftPrivateThreadExtras: clean up using WinSDK SDK overlay
Use the constants rather than hardcoding values.
2018-12-01 11:04:13 -08:00
Saleem Abdulrasool
cc49e686cd Merge pull request #20908 from compnerd/thread-corrections
SwiftPrivateThreadExtras: fix windows build
2018-11-30 10:38:09 -08:00
Saleem Abdulrasool
c32daed203 SwiftPrivateThreadExtras: fix windows build
Missed casts and a let vs var issue.  This was missed in the last bundle
of patches.
2018-11-29 22:19:00 -08:00
Saleem Abdulrasool
94173e9cdb SwiftPrivateThreadExtras: correct dependency for Windows
We need the MSVCRT module, add a dependency.
2018-11-29 19:26:59 -08:00
Saleem Abdulrasool
0aec8376da SwiftPrivateThreadExtras: enable on all platforms
This has been generalized enough to permit building on Windows with
Windows threading primitives.
2018-11-26 13:10:00 -08:00
Saleem Abdulrasool
ce40d72641 stdlib: implement _stdlib_pthread_join in terms of Windows threading
Implement `_stdlib_pthread_join` in terms of windows threading.
Additionally, rename it to `_stdlib_thread_join`.
2018-11-26 13:10:00 -08:00
Saleem Abdulrasool
6bf7b9e711 stdlib: implement _stdlib_create_pthread_block in terms of Windows threaing
Port the block based thread constructor to Windows threading model, and
rename it to `_stdlib_create_thread_block`.
2018-11-26 13:10:00 -08:00
Saleem Abdulrasool
e1d7ee79e4 stdlib: implement ThreadBarriers in terms of Windows threading 2018-11-26 13:10:00 -08:00
Saleem Abdulrasool
5e943981c7 stdlib: rename some variables in _stdlib_barrier 2018-11-26 13:10:00 -08:00
Saleem Abdulrasool
65bdce00b6 stdlib: rename _stdlib_PTHREAD_BARRIER_SERIAL_THREAD -> _stdlib_THREAD_BARRIER_SERIAL_THREAD 2018-11-26 13:10:00 -08:00
Saleem Abdulrasool
7b06586fe1 stdlib: rename _stdlib_pthread_barrier_t to _stdlib_thread_barrier_t 2018-11-26 13:09:49 -08:00
Saleem Abdulrasool
940db1b0cf stdlib: remove pthread_attr_t from _stdlib_pthread_create_block
The attributes were not being used currently.  Since this is a private
interface, remove the parameter as it makes it easier to port to
Windows.
2018-11-26 13:09:31 -08:00
Saleem Abdulrasool
82360c6b27 stdlib: remove pthread_barrier attributes
These were not in use, and removing this from the signature makes it
possible to re-use the exact signature on Windows more easily.
2018-11-26 13:09:31 -08:00
Saleem Abdulrasool
0693bec1f1 sdlib: rename SwiftPrivatePthreadExtras to SwiftPrivateThreadExtras
This is in preparation to make the code here more target agnostic for
porting to the Windows threading primitives.  This is used pretty
extensively in the tests, so disabling tests would lose a chunk of
coverage.
2018-11-26 13:09:31 -08:00