Commit Graph

44 Commits

Author SHA1 Message Date
Slava Pestov
1d25522ceb cmake: Add NO_SWIFTMODULE option to add_swift_target_library() 2025-04-07 21:32:14 -04:00
Egor Zhdan
7ae2bebfe8 [cxx-interop] Do not emit C++ interop flag in textual interfaces
This makes sure that the compiler does not emit `-enable-experimental-cxx-interop`/`-cxx-interoperability-mode` flags in `.swiftinterface` files. Those flags were breaking explicit module builds. The module can still be rebuilt from its textual interface if C++ interop was enabled in the current compilation.

rdar://140203932
2024-12-05 19:25:09 +00:00
Allan Shortlidge
4c3a009c2b SILGen: Remove triplesAreValidForZippering() assert.
This assert was correctly catching the fact that `-target-variant` is not being
normalized at the same time as `-target` when building arm64e modules from
swiftinterface. That should be fixed, but at the moment it isn't causing any
concrete harm and the assertion fails when building against the SDKs included
with the latest Xcode 16 betas.

Resolves rdar://133020098.
2024-09-04 22:39:21 -07:00
Alex Hoppen
66104395d7 [Sema/SourceKit] Emit same diagnostics for missing protocol requirements on the command line and in SourceKit
Some editors use diagnostics from SourceKit to replace build issues. This causes issues if the diagnostics from SourceKit are formatted differently than the build issues. Make sure they are rendered the same way, removing most uses of `DiagnosticsEditorMode`.

To do so, always emit the `add stubs for conformance` note (which previously was only emitted in editor mode) and remove all `; add <something>` suffixes from notes that state which requirements are missing.

rdar://129283608
2024-08-07 14:01:30 -07:00
Kavon Farvardin
a1e14ae0c7 Sema: ext's must add solo invertible conformances
This helps prevent confusion after not inferring requirements if the
extension adds a Copyable conformance.
2024-06-12 14:44:22 -07:00
Allan Shortlidge
4bc1abb4be Sema: Relax feature check for non-escapable types in swiftinterfaces.
Checking for the presence of a feature flag in order to allow syntax tends to
result in condfails when applied to `.swiftinterfaces`, since older compilers
that have this restriction may be used to compile newer interfaces where the
restriction has been lifted. Remove this restriction for non-escapable types
when typechecking an interface.

Resolves rdar://128577611
2024-05-24 13:53:50 -07:00
Kavon Farvardin
bb51be731e Test: update for NoncopyableGenerics infra. 2024-03-14 23:10:44 -07:00
Allan Shortlidge
841847b009 Revert "[Regex] Really build _RegexParser without resilience."
This reverts commit 8d1b578275.

Resolves rdar://124541877
2024-03-13 16:25:21 -07:00
Doug Gregor
0c9c734f7e Merge pull request #71722 from DougGregor/diagnostic-style-swift-default 2024-02-24 14:42:38 -10:00
Kavon Farvardin
f296d8e158 NCGenerics: mass XFAIL tests
It's easier to get a handle on regressions while working through
failures if the tests that are known to not pass are XFAIL'd for
NoncopyableGenerics.
2024-02-20 18:26:05 -05:00
Doug Gregor
8cd2f34654 Generalize tests for both diagnostic styles, or force the LLVM style
These tests are using FileCheck to check the result of diagnostic
formatting in ways that don't match the new formatter. Force the old
formatter or, where possible, generalize so that they match both
formatters.
2024-02-19 02:48:37 -10:00
Holly Borla
2a18edc178 [NFC][Concurrency] Update validation tests for @MainActor(unsafe) changes. 2024-01-22 08:43:27 -08:00
Allan Shortlidge
8d1b578275 [Regex] Really build _RegexParser without resilience.
This was originally attempted with https://github.com/apple/swift/pull/58810
but `_RegexParser` still ended up being built with library evolution enabled
because the `-enable-library-evolution` flag is added to the command line after
calling `add_swift_target_library` and therefore stripping the flag out of
`SWIFT_COMPILE_FLAGS` does nothing.

The `IS_FRAGILE` flag was introduced to support building C++ interop overlay
modules without library evolution and it can now be used to prevent
`_RegexParser` from being built with library evolution.

Resolves rdar://93067204
2024-01-17 08:03:54 -08:00
Kuba Mracek
884bd6e173 [embedded] Adjust verify_all_overlays.py to avoid checking Cxx and CxxStdlib 2023-09-26 23:02:14 -07:00
Nishith Shah
8e2e625543 [Diagnostics] Use imperative msg for protocol conformance & switch-case fixits
This commit changes fixit messages from a question/suggestion to an
imperative message for protocol conformances and switch-case. Addresses
https://github.com/apple/swift/issues/67510.
2023-08-13 22:34:26 -07:00
Allan Shortlidge
ba422f96be Sema: Fix incorrect assert in TypeCheckProtocol.cpp.
We can't assume that we will always find a viable witness for a protocol
requirement when typechecking a `.swiftinterface` file. The assert that assumed
there would be a match could fail when building a broken interface or building
a valid interface with a broken SDK, causing crashes instead of emitting
diagnostics.

Resolves rdar://108688535
2023-05-04 16:24:31 -07:00
Allan Shortlidge
fb03b4aa04 Sema: Relax availability checking for @MainActor.
The `@MainActor` global actor constraint on a declaration does not carry an
inherent ABI impact and therefore use of this constraint should not be limited
to OS versions where Swift concurrency is available.

Resolves rdar://105610970
2023-03-16 14:23:36 -07:00
Ehud Adler
f11e2afe07 [cxx-interop] Always import cxx shim when cxx-interop is enabled (#60336) 2022-08-05 08:28:47 -04:00
Egor Zhdan
6754c3cf82 [cxx-interop] Add CxxSequence protocol to the stdlib overlay
This change adds basic helper protocols and structs that are going to be used for making C++ sequences and collection safe and Swifty by adding conformances to `Swift.Sequence`, `Swift.Collection`, etc.

This is not meant to be a final design.
2022-06-27 20:40:12 +01:00
Egor Zhdan
ff8464fd2a [cxx-interop] Add basic C++ stdlib overlay
This will allow us to add Swift conformances to C++ standard library types, and improve usability of the C++ standard library from Swift.
2022-05-16 13:30:35 +01:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Evan Wilde
6956b7c5c9 Replace /usr/bin/python with /usr/env/python
/usr/bin/python doesn't exist on ubuntu 20.04 causing tests to fail.
I've updated the shebangs everywhere to use `/usr/bin/env python`
instead.
2021-09-28 10:05:05 -07:00
Karoy Lorentey
9cf28dffa2 [SDK] Remove the obsolete XCTest overlay
The actual XCTest overlay has not been maintained in this repository for years. (It is distributed in Xcode (libXCTestSwiftSupport.dylib), along with XCTest.framework itself.)

The code we have here is badly out of date, and the fact that we have it on the module path in CI makes it interfere with the contents of recent SDKs.

Remove the XCTest overlay from this repository; pick it up from the SDK instead.

rdar://76915582
2021-05-21 17:21:12 -07:00
Erik Eckstein
d49de1a982 ModuleInterfaceBuilder: give a more specific error message in case of a compiler mismatch 2021-04-15 14:06:17 +02:00
Alexis Laferrière
b79c7b627b [ModuleInterface] Update wording of the "failed to build module" error
The error shown when the compiler fails to build a module from its
textual interface has been creating some confusion. This is a proposal
to make it more useful to the programmer not working in the SDK, insist
on looking at the previous errors first, put less emphasis on possible
compiler bugs, and always show alternatives to the incompatible
compilers issue as this is the most common case now.
2021-01-26 15:36:46 -08:00
Meghana Gupta
ee1d975da0 Disable test for asan builds
Raises a stackoverflow error in some asan builds even though it is not a
runaway recursion.
2020-08-17 19:28:40 -07:00
Nate Chandler
caca83e9e1 [Test] Un-XFAIL ParseableInterface/verify_all_overlays.py.
The test is passing now--un-XFAIL it.

rdar://problem/50648519
2020-07-08 18:01:46 -07:00
Dan Zheng
dd645d88d1 [AutoDiff] Enable .swiftinterface verification for _Differentiation. (#32110)
Enable .swiftinterface verification for the _Differentiation module to prevent
regressions.
2020-05-30 23:53:13 -07:00
Doug Gregor
b27b4d4bb6 [CMake] Use proper module triples for the names of standard library modules.
The standard library (and other Swift modules built by our CMake build system)
has been building module files with an architecture only (e.g., x86_64.swiftmodule)
rather than a proper module triple (x86_86-apple-macosx10.15,
x86_64-apple-ios13.0-simulator, etc.), unlike every other build
system. There are hacks in the compiler and other tools to cope with
this unnecessary build difference. Fix the module file names so we'll
be able to remove the hacks later.

Fixes rdar://problem/49071536.
2020-04-20 21:16:14 -07:00
marcrasi
ddef9292a6 [AutoDiff upstream] DifferentiationUnittest and some e2e tests (#30915)
Adds 2 simple e2e tests and some lit subsitutions and unittest libraries
necessary to support them.
2020-04-09 14:25:31 -07:00
Marc Rasi
013a66bffc exempt _Differentiation from verify_all_overlays test 2020-03-31 16:25:09 -07:00
Brent Royal-Gordon
a27fdad4e5 Provide fallback SourceLoc for swiftinterface build errors
When a swiftinterface fails to build for any of various reasons, we try to diagnose the failure at the site of the `import` declaration. But if the import is implicitly added—which happens for many SDK modules, like the standard library and ClangImporter overlays—there is no source location for the import, so the error ends up being diagnosed at <unknown>:0. This causes a number of issues; most notably, Xcode doesn’t display the diagnostic as prominently as others.

This change falls back to diagnosing the error at line 1, column 1 of the swiftinterface file itself. This is perhaps not an ideal location, and it won’t help with I/O errors where we can’t open the swiftinterface file (and therefore can’t diagnose an error in it), but it should improve the way we display most module interface building errors.
2020-03-17 18:44:31 -07:00
Brent Royal-Gordon
a7a5e340aa Improve diagnostic for broken module interfaces
Currently, when a swiftinterface file fails to load, we emit the specific diagnostics for the failures, followed by a generic “failed to load module ‘Foo’” message. This PR improves that final diagnostic, particularly when the cause may be that the interface was emitted by a newer compiler using backwards-incompatible syntax.
2020-03-13 20:31:55 -07:00
Jordan Rose
3243f21280 Make sure all failures to load module interfaces are diagnosed (#25636)
...specifically, diagnosed in the parent DiagnosticEngine. This not
only provides a better user experience, but makes sure that the
compiler exits with a nonzero exit code even if the module goes
unused.

rdar://problem/50789839
2019-06-20 14:14:38 -07:00
Saleem Abdulrasool
6f803155d7 validation-test: avoid shell in ParseableInterface.verify_all_overlays
Avoid using shell in the test as not all targets run with a POSIX shell
for the test executor.
2019-06-05 13:57:19 -07:00
Saleem Abdulrasool
655a60af4d validation-test: correct typo in ParseableInterface.verify_all_overlays
The `%{python}` substitution was typoed with the `%` sigil being
replaced with `$`.
2019-06-04 16:36:12 -07:00
Brent Royal-Gordon
781ce5ed5e XFAIL ParsableInterface/verify_all_overlays.py
rdar://problem/50648519
2019-05-09 20:48:43 -07:00
Jordan Rose
c6efc8dc85 Test that the swiftinterface for the stdlib can be compiled (#24128)
...like we've done with the overlays for months. Meant to do this a
long time ago, but at the time we hadn't gotten the stdlib working
yet!
2019-04-19 14:27:23 -07:00
Jordan Rose
43feb9cbe1 On Apple platforms, use swiftmodule directories for the stdlib (#21797)
This changes the Swift resource directory from looking like

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          x86_64/
            Swift.swiftmodule
            Swift.swiftdoc
            Darwin.swiftmodule
            Darwin.swiftdoc

to

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          Swift.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc
          Darwin.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc

matching the layout we use for multi-architecture swiftmodules
everywhere else (particularly frameworks).

There's no change in this commit to how Linux swiftmodules are
packaged. There's been past interest in going the /opposite/ direction
for Linux, since there's not standard support for fat
(multi-architecture) .so libraries. Moving the .so search path /down/
to an architecture-specific directory on Linux would allow the same
resource directory to be used for both host-compiling and
cross-compiling.

rdar://problem/43545560
2019-02-19 14:47:21 -08:00
Jordan Rose
810a7bcd2d [test] Use -build-module-from-parseable-interface to test overlays (#21687)
Previously we used a manual -emit-module command with a hardcoded set
of arguments, but that didn't work properly for all overlays. This is
much better.
2019-01-07 17:07:06 -08:00
Jordan Rose
605c9f619f [CMake] Conditionalize generation of .swiftinterface files
SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES is the new setting.

rdar://problem/44942414
2018-11-26 17:04:46 -08:00
Graydon Hoare
77280b00ea [ModuleInterface] Use 2-arg form of basename(1) in overlay validation tests.
A bunch of .swiftinterface files fail to build into their respective .swiftmodules
if you pass -module-name <foo> for some foo that is not the correct module name.

The two tests in this change were using a shell expansion that incorrectly picked
the first path component with a period in the name as the module name; this caused
the failures.

Rather than using a shell expansion, this change uses the 2-argument form of
basename(1) (which is POSIX) that also removes a suffix from the basename.
2018-10-18 15:01:25 -07:00
Graydon Hoare
5e202697a3 [ModuleInterface] Mop up remaining "textual interface" terminology. 2018-10-11 23:56:19 -07:00
Jordan Rose
73d5ebaad2 Rename "textual interface" to "parseable interface" (#19713)
We already have something called "module interfaces" -- it's the
generated interface view that you can see in Xcode, the interface
that's meant for developers using a library. Of course, that's also a
textual format. To reduce confusion, rename the new module stability
feature to "parseable [module] interfaces".
2018-10-04 17:49:55 -07:00