Commit Graph

35 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
Alastair Houghton
b2f0d92eaa [Cxx] Build the C++ interop support library for the Static SDK for Linux.
We need the C++ interop support library to make the build work, as
the Runtime module uses C++ interop.

(Also, we should build it, because some user programs might want to
use C++ interop.)

rdar://147201087
2025-05-15 14:30:12 +01:00
Egor Zhdan
16b280862a [cxx-interop] Do not install binary .swiftmodule files for the overlays
This fixes a deserialization failure in the compiler that occurred while loading the CxxStdlib overlay module:
```
Cross-reference to module 'Swift'
... Optional
... some
... with type <τ_0_0 where τ_0_0 : ~Copyable, τ_0_0 : ~Escapable> (Optional<τ_0_0>.Type) -> (τ_0_0) -> Optional<τ_0_0>
```

This was happening because the overlays were built against a different version of the Swift stdlib than is being used. The compiler is able to rebuild the Cxx and CxxStdlib modules from their textual interfaces. Let's use that feature unconditionally in production toolchains to avoid this kind of binary incompatibilities.

rdar://150416863
2025-05-10 22:55:06 +01:00
Doug Gregor
0100104ff7 [stdlib] Reinstate AllowUnsafeAttribute experimental feature on libraries
We need this so that older compilers can handle the .swiftinterface
files we generate. It's unnecessary for newer compilers and can be
removed later.

Fixes rdar://148529962.
2025-04-03 18:07:19 -07:00
Doug Gregor
89d0277a35 Enable strict memory safety in the Cxx/CxxStdlib modules 2025-02-26 14:28:30 -08:00
Egor Zhdan
d5f7f6f3ff Merge pull request #77927 from swiftlang/egorzhdan/bring-back-overlay-flag
[cxx-interop] Bring back `AssumeResilientCxxTypes` flag for CxxStdlib overlay
2024-12-04 13:01:44 +00:00
Egor Zhdan
b6488d3c8c [cxx-interop] Bring back AssumeResilientCxxTypes flag for CxxStdlib overlay
This fixes a CI job that is building the Swift stdlib with a recent nightly compiler.

rdar://140850172
2024-12-03 18:52:45 +00:00
Egor Zhdan
22141b1118 [cxx-interop] Lower iOS deployment target for Cxx and CxxStdlib
The iOS/watchOS/tvOS deployment targets for Cxx and CxxStdlib binaries got unintentionally bumped in b87b263.

This reverts the deployment targets to the older versions.

rdar://140823785 / resolves https://github.com/swiftlang/swift/issues/77909
2024-12-03 16:39:59 +00:00
Egor Zhdan
f420456899 [cxx-interop] Allow using non-resilient C++ symbols in resilient overlays
If a Swift module built with library evolution enabled is an overlay of a C++ module, allow referring to the non-resilient C++ symbols from the Swift code.

Overlays are usually built and shipped along with the C/C++ modules, so library evolution is less of a concern there. A developer providing a Swift overlay for a C++ library would expect to be able to refer to the symbols from the C++ library within the overlay.
2024-12-02 19:44:32 +00:00
Egor Zhdan
242fe5cfac Merge pull request #77677 from swiftlang/egorzhdan/cxxstdlib-builtin-float
[cxx-interop] Declare CxxStdlib dependency on _Builtin_float
2024-11-19 12:57:53 +00:00
Allan Shortlidge
c9c36732be stdlib: Enable upcoming MemberImportVisibility feature.
It was already supposed to be enabled, but I forgot to update the CMake when I
renamed the feature from ExtensionImportVisibility to MemberImportVisibility.

However, leave it disabled on the CxxStdlib module since the C++ standard
library's modularization varies a lot by platform, making it difficult to add
the right conditional imports.
2024-11-18 10:27:14 -08:00
Egor Zhdan
72425fa750 [cxx-interop] Declare CxxStdlib dependency on _Builtin_float
This fixes incremental builds of the overlay.

The CxxStdlib overlay re-exports the entire C++ standard library, which has headers that transitively include Clang builtin headers, bringing in the _Builtin_float module.

rdar://140036608
2024-11-18 13:01:31 +00:00
Egor Zhdan
703e479135 [cxx-interop] Make Cxx and CxxStdlib libraries resilient
This enables library evolution for the two libraries that form the Swift overlay for the C++ standard library.

rdar://129169673
2024-11-12 17:22:03 +00:00
Egor Zhdan
b0a3bb10f0 [cxx-interop] Build Cxx and CxxStdlib modules for macCatalyst
This enables building the C++ stdlib overlays (`Cxx.swiftmodule` and `CxxStdlib.swiftmodule`) for the Mac Catalyst target.

rdar://126938813
2024-07-05 19:35:29 +01:00
Alex Lorenz
273edcf2a2 build CxxStdlib for Android too 2024-06-04 15:46:39 -07: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
Egor Zhdan
53fb6531f2 [cxx-interop] Add conversions between std::chrono::duration and Swift.Duration
rdar://123696734
2024-03-01 13:15:05 +00:00
Egor Zhdan
e144f607d7 [cxx-interop] Migrate to overlay the new compiler flag
`-enable-experimental-cxx-interop` is deprecated, the new flag for enabling C++ interop is `-cxx-interoperability-mode=enabled`.

NFC intended.
2023-11-28 20:30:12 +00:00
Egor Zhdan
00cdb66d01 [cxx-interop] Lower macOS deployment target version for the Cxx module
The Cxx module does not rely on any modern OS features. It can be deployed to older macOS versions.

rdar://117699474
2023-10-30 19:22:02 +00: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
Rintaro Ishizaki
064cb34015 [CMake] Use add_custom_command_target for copying std.apinotes
`COMMAND` for `add_custom_target` are "always considered out of date"
and executed everytime. Because of that, targets depends on that were
alway marked "dirty". Use `add_custom_command_target` instead.
2023-09-14 16:52:43 -07:00
Egor Zhdan
9b7dbf2599 [cxx-interop] Introduce APINotes file for C++ stdlib
This adds an `std.apinotes` file that is installed into `lib/swift/apinotes` along with existing Darwin apinotes. This new file is installed on all platforms. It replaces a few special cases in the compiler for `cmath` and `cstring` functions.

This does not require the upcoming APINotes support for namespaces, however, this does require https://github.com/apple/llvm-project/pull/7309.

rdar://107572302
2023-08-29 23:34:36 +01:00
Saleem Abdulrasool
2124c01e74 stdlib: enable CxxStdlib module on Windows
Enable this module on Windows for enabling C++ Interop.
2023-08-04 21:19:35 -07:00
Alex Lorenz
3748b0ff1c Merge pull request #65129 from hyp/eng/no-evo-cxx
[interop] Prohibit use of C++ APIs in public interfaces that opt-in i…
2023-07-19 08:10:23 -07:00
Egor Zhdan
60c91aa90a [cxx-interop] Declare CxxStdlib dependency on Darwin when building both
rdar://108188270
2023-06-07 20:17:24 +01:00
Egor Zhdan
b5866040ae [cxx-interop] Fix Linux build with SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=NO
This fixes the Swift LSAN CI job Linux (https://ci.swift.org/job/oss-swift-RA-lsan-linux-ubuntu-18_04/) that started failing after https://github.com/apple/swift/pull/65398.

rdar://108674065
2023-05-02 17:35:29 +01:00
Egor Zhdan
030313213c [cxx-interop] Add missing dependency to CxxStdlib
The CxxStdlib module now relies on the libcxxshim modulemap, so we
need to make sure that the modulemap is copied into the correct location before CxxStdlib is built.

rdar://108007693
2023-04-13 20:28:24 +01: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
Egor Zhdan
14f32312bf [cxx-interop] Do not add a dependency on clang to CxxStdlib
Cxx & CxxStdlib modules are Swift-only, they do not require invoking clang directly.

When building with `SWIFT_INCLUDE_TOOLS=NO`, Clang is not available as a CMake target (see `swift_common_standalone_build_config`).

rdar://107780733
2023-04-11 16:45:39 +01:00
Egor Zhdan
416e2e17df [cxx-interop] Remove CxxStdlib dependency on Darwin
This was causing build errors when building the compiler and the stdlib separately.

rdar://107290998
2023-03-28 16:16:04 +01:00
Egor Zhdan
ee6b9b2a67 [cxx-interop] Disallow import std, require import CxxStdlib
`CxxStdlib` will now be the only accepted module name for the C++ standard library module in Swift.
2023-01-26 14:15:56 +00:00
Egor Zhdan
151c205a29 [cxx-interop] Move C++ standard library overlay to the toolchain
The `swiftCxx` and `swiftstd` modules are currently a part of the SDK, but they should be a part of the toolchain instead.

rdar://103082278
2022-12-12 11:18:30 +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
Daniel Rodríguez Troitiño
036e16810a [Cxx] Make C++ flags configurable for Linux SDK (#59764)
Allow Linux distributions to provide their own C++ flags to compile the
C++ overlay correctly. The default is kept the same for Ubuntu and
CentOS, but other distributions can provide other flags to use their own
distro GCC stdlibc++ or even libc++ if they choose.

This should not change the current compilation, but opens the door for
other maintainers to provide a different value that work on their
systems.
2022-06-29 08:54:56 -07:00
Egor Zhdan
82a90b90aa [cxx-interop] Split C++ stdlib overlay into two modules
This allows projects that don't want to pull in the entire C++ standard library to use stdlib-independent C++ interop utilities like `CxxSequence`.
This also makes the utilities available on platforms where we don't currently have the `std` overlay available, e.g. Windows.
2022-06-28 15:37:20 +01:00