Commit Graph

12 Commits

Author SHA1 Message Date
Gábor Horváth
816290f0cd [6.2.1][cxx-interop] Do not consider function types fragile
Explanationion: Function pointer types wee always considered fragile in C++ mode,
this manifested as a regression when interfacing with glibc.
Issues: rdar://159184118
Original PRs: #84040
Risk: Low, this only removes a spurious error for library evolution.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-09 09:55:52 +01:00
Arnold Schwaighofer
f9b551d9cd Hard disabled some test/Interop/Cxx/library-evolution tests
They also fail on internal CI PR bots

rdar://r144000451
2025-02-04 11:43:45 -08:00
Arnold Schwaighofer
82d13bbdbd Temporarily disable tests on anything but macosx
They brake multiple bots.

rdar://144000451
2025-02-01 09:18:57 -08:00
Egor Zhdan
00e6b360d5 [cxx-interop] Assume that plain-C enums are resilient
This fixes sudden compiler errors that are emitted when trying to use CoreText.framework with C++ interop enabled.

When Swift is trying to rebuild a dependency module from its textual interface, it should not complain on usages of C enums in public Swift APIs.

This still leaves the resilience safety guardrail enabled for C++ scoped enums.

rdar://143215914
2025-01-21 18:57:10 +00:00
Egor Zhdan
e67f2b72d2 [cxx-interop] Allow some C++ fields in public Swift interfaces
This is a follow-up to 8859b629.

This resolves compiler errors when trying to rebuild System.swiftmodule from its textual interface with Xcode 16.1.

rdar://140203932
rdar://141124318
2024-12-09 19:20:20 +00:00
Egor Zhdan
8859b629fa [cxx-interop] Allow using C-like structs in public Swift interfaces
When compiling with C++ interop enabled, we enable extra safety checks to prevent library authors from accidentally exposing ABI-fragile C++ symbols in resilient Swift interfaces.

The heuristic we use is overly strict, and it prevents the compiler from being able to typecheck various modules from their interfaces when C++ interop is enabled. Darwin and System are two of such modules.

The underlying challenge is that there isn't a good distinction between C structs and C++ structs: whenever parsing a header file in C++ language mode, Clang assumes that every struct is a C++ struct.

This relaxes the heuristic to allow exposing C-like structs in resilient interfaces.

rdar://140203932
2024-12-06 20:18:53 +00:00
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Gábor Horváth
a9d59034b3 Merge pull request #76956 from swiftlang/gaborh/treat-c-struct-as-resilient
[cxx-interop] Consider extern "C" structs as resilient
2024-10-14 12:31:16 +01:00
Gabor Horvath
625f45a928 [cxx-interop] Consider extern "C" structs as resilient
Changing the members of these structs are still API and ABI breaking
changes but they are not as fragile as C++ classes where adding/removing
virtual functions or doing other changes can also result in breaking the
ABI.

rdar://119319825
2024-10-10 17:58:09 +01:00
Gabor Horvath
cf3b333eb6 [cxx-interop] Add flag to assume C++ types are resilient
Currently, C++ types cannot appear in resilient interfaces. There are
some cases where this is overly restrictive. We plan to improve the
logic to detect what types should not appear on resilient moduel
boundaries. In the meantime, this PR introduces a flag to disable these
errors. Users relying on this flag are on their own, this should only be
a temporary workaround until we land further improvements to this
diagnostic.

rdar://137457118
2024-10-09 11:47:10 +01:00
artemcm
ec4e0e23aa Allow users to opt-out of implicit Cxx import with -disable-implicit-cxx-module-import 2024-05-20 11:18:45 -07: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