Commit Graph

194 Commits

Author SHA1 Message Date
Kavon Farvardin
54e71d086a OpaqueValues: provide stdlib build option
Should allow testing with preset:
```
extra-cmake-options=-DSWIFT_STDLIB_EXTRA_SWIFT_COMPILE_FLAGS=TRUE
```
2025-11-20 14:27:48 -08:00
Fabrice de Gans
810588b0c5 line-directive: Stop expanding response files
`line-directive` was expanding response files for the swiftc invocation,
which was causing issues on CI when the file list got too long. This
changes the script to stop expanding response files and pass them as-is
to the swiftc invocation instead. The format for the response files was
also incorrect, with each individual file being quoted, so this fixes
the CMake script generating those.
Finally, this changes `line-directive` to dump the command line on
failure.
2025-06-04 13:16:50 -07:00
Finagolfin
432de55622 [stdlib][cmake] Disable checking for bootstrapping if the host tools aren't being built 2025-05-19 14:39:15 +05:30
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
Kuba Mracek
c5aa98a449 [embedded] Make the CMake setup for Embedded Concurrency distnguish ARCH and SUBDIR for builds products 2025-04-26 07:03:19 -07:00
Guillaume Lessard
3670664ce6 [stdlib] use “LifetimeDependenceMutableAccessors” 2025-04-15 10:41:27 -07:00
Slava Pestov
1d25522ceb cmake: Add NO_SWIFTMODULE option to add_swift_target_library() 2025-04-07 21:32:14 -04:00
Meghana Gupta
ef1e94577f Revert "Merge pull request #80540 from swiftlang/revert-80452-lifetimeinout"
This reverts commit 6eaa07a880, reversing
changes made to e75ee3f4cf.
2025-04-04 09:50:13 -07:00
Artem Chikin
39e1791b67 Revert "Add support for inout lifetime dependence" 2025-04-04 09:00:09 -07:00
Meghana Gupta
493f0b782e Introduce InoutLifetimeDependence feature 2025-04-03 17:32:09 -07:00
Evan Wilde
eeee0dfddd CMake: option to disable swift in swift
Adding `SWIFT_ENABLE_SWIFT_IN_SWIFT` option to enable or disable the
parts of Swift that require a Swift compiler to build. This is meant for
bootstrapping compilers on new platforms and is not guaranteed to result
in a compiler that will pass the test suite.

This option is on by default so that folks won't forget.
If the option is off, the resulting compiler does not include the Swift
optimizer sources in SwiftCompilerSources nor does the resulting
compiler have swift macro support.
2025-03-06 13:32:49 -08:00
Doug Gregor
50d3913086 [SE-0458] Enable strict memory safety in the Swift standard library 2025-02-26 14:27:55 -08:00
Hamish Knight
d260bd8ddb [build-script] Remove Xcode generation support
This was quite brittle and has now been superseded
by swift-xcodegen. Remove the CMake/build-script
logic for it, leaving the option behind to inform
users to switch to using xcodegen instead.
2025-02-12 12:19:21 +00:00
Henrik G. Olsson
ef9d2b744d Rename pointer bounds (#78210)
* Make pointer bounds non-experimental

* Rename @PointerBounds to @_SwiftifyImport

* Rename filenames containing PointerBounds

* Add _PointerParam exception to stdlib ABI test

* Add _PointerParam to stdlib API changes

* Rename _PointerParam to _SwiftifyInfo
2024-12-20 11:36:01 +01:00
Egor Zhdan
d1a435c42a [build] Respect DEPLOYMENT_VERSION_{IOS|TVOS|WATCHOS} for Simulator targets
This makes sure that Cxx and CxxStdlib modules are built with consistent deployment targets for iOS Simulator and iOS Device.

rdar://141232269
2024-12-17 15:51:18 +00:00
Meghana Gupta
ddd107911d Add -enable-experimental-feature LifetimeDependence to stdlib 2024-11-18 18:08:32 -08: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
Henrik G. Olsson
0678829cf7 Add @PointerBounds macro (#76969)
Add @PointerBounds macro

@PointerBounds is a macro intended to be applied by ClangImporter when
importing functions with pointer parameters from C headers. By
leveraging C attributes we can get insight into bounds, esapability, and
(eventually) lifetimes of pointers, allowing us to map them to safe(r)
and more ergonomic types than UnsafePointer.

This initial macro implementation supports CountedBy and Sizedby, but
not yet EndedBy. It can generate function overloads with and without an
explicit count parameter, as well as with UnsafeBufferPointer or Span
(if marked nonescaping), and any of their combinations. It supports
nullable/optional pointers, and both mutable and immutable pointers.
It supports arbitrary count expressions. These are passed to the macro
as a string literal since any parameters referred to in the count
expression will not have been declared yet when parsing the macro.

It does not support indirect pointers or inout parameters. It supports
functions with return values, but returned pointers can not be bounds
checked yet.

Bounds checked pointers must be of type Unsafe[Mutable]Pointer[?]<T>
or Unsafe[Mutable]RawPointer[?]. Count expressions must conform to
the BinaryInteger protocol, and have an initializer with signature
"init(exactly: Int) -> T?" (or be of type Int).

rdar://137628612

---------

Co-authored-by: Doug Gregor <dgregor@apple.com>
2024-11-11 14:54:25 -08:00
Daniel Rodríguez Troitiño
d84b23b611 [maccatalyst] Handle macCatalyst static swiftmodules (#76784)
The existing CMake code for macCatalyst swiftmodule only handled the
shared case, and did not have the static pieces that non-macCatalyst
targets are doing.

Try to match as much as possible the non-macCatalyst variables and
structure and allow macCatalyst targets to support static Swift targets.

This is important for the `Cxx.swiftmodule` and `CxxStdlib.swiftmodule`,
since they are only static, and the previous code skipped creating those
files since https://github.com/swiftlang/swift/pull/74994
2024-10-21 22:56:12 -07:00
Meghana Gupta
9184923089 Enable experimental feature NonescapableTypes in the stdlib 2024-09-13 01:54:20 -07:00
Doug Gregor
8378562e12 Adopt @unsafe throughout the standard library
Annotate all of the `Unsafe*` types and `unsafe` functions in the standard
library (including concurrency, synchronization, etc.) as `@unsafe`. Add a
few tests to ensure that we detect uses of these types in clients that
have disabled unsafe code.
2024-08-19 14:33:09 -07:00
Kavon Farvardin
972373b129 NCGenerics: begin process of removing compat hack
The reverse-condfail workaround needs to be removed, and this is the
first step to allowing the stdlib to build with conditionally escapable
types.

resolves rdar://132453000
2024-07-29 17:27:17 -07:00
Alexander Cyon
c21b1e68fd [stdlib] Fix typos 2024-07-06 13:09:57 +02:00
Kuba Mracek
37ed08dc7b Add a build-script + CMake flag to enable/disable building the _Volatile module 2024-06-17 13:18:55 -07:00
Michael Gottesman
b6e9c9cb24 [cmake] Make the hosttools lib SwiftMacros a dependency of the stdlib when we aren't cross compiling.
This just matches the dependency behavior of the stdlib for swift-frontend. So
we should always have SwiftMacros as needed.

rdar://126998047
2024-04-24 13:22:43 -05:00
Allan Shortlidge
78cd1149bd stdlib: Adopt ExtensionImportVisibility experimental feature.
This didn't expose any missing imports in the sources of any of the standard
library modules, but that's not entirely surprising. Still, we should have the
feature enabled to test it and prevent regressions from creeping in before the
behavior becomes the default.

Exclude `ExtensionImportVisibility` from module interfaces.
2024-04-05 09:22:02 -07:00
Kavon Farvardin
30983530b6 NCGenerics: introduce SuppressedAssociatedTypes
The model for associated types hasn't been fully worked-out for
noncopyable generics, but there is some support already that is being
used by the stdlib for an internal-only (and rather cursed) protocol
`_Pointer` to support `UnsafePointer`, etc.

This patch gates the existing experimental support for associated types
behind a feature flag. This flag doesn't emit feature-guards in
interfaces, since support for it is tied closely to NoncopyableGenerics
and has been there from its early days.
2024-04-02 16:53:36 -07:00
Eric Miotto
93d64e973d Merge pull request #72590 from edymtt/edymtt/no-darwin-binary-swiftmodule-in-toolchain
Do not install binary swiftmodule for Darwin
2024-03-28 09:22:32 -07:00
Allan Shortlidge
2813fbe309 Frontend: Introduce an alias for the NoncopyableGenerics experimental feature.
The `.swiftinterface` of the standard library must remain compatible with some
older compilers. Unfortunately, some of those older compilers do not allow the
experimental feature `NoncopyableGenerics` to be enabled in production. To
allow the stdlib to build with non-copyable generics enabled and still have the
older compilers consume its interface, we have to use a new experimental
feature identifier that they do not know about.

Partially resolves rdar://125138945
2024-03-27 22:20:25 -07:00
Eric Miotto
0cac358fe5 Do not install binary swiftmodule for Darwin
This is needed to support Apple internal configurations that would fail
consuming such binary swiftmodule (but work as expected when rebuilding
from the swiftinterface).

Addresses rdar://124390643
2024-03-27 10:56:55 -07:00
Eric Miotto
649618dc36 Remove duplicate call to install() for stdlib modules
Also amend the installation code handling macCatalyst to match the one
for regular swiftmodules.
2024-03-26 09:48:36 -07:00
Doug Gregor
922e3daaea Remove build infrastructure for globally enabling noncopyable types
Now that the compilation model of noncopyable types is enabled everywhere,
and one can enable the feature for specific modules, we no longer need a
separate build-script/CMake option to enable it globally. Remove it all.
2024-03-19 13:35:31 -07:00
Kavon Farvardin
76c6510519 Merge pull request #72276 from kavon/ncgenerics-xfails-3 2024-03-16 04:18:35 -07:00
eeckstein
9504de5ed7 Merge pull request #71552 from finagolfin/cross-compile
[CMake] Add broader support for cross-compiling the portions of the compiler that are written in Swift to non-Darwin Unix
2024-03-15 16:28:38 +01:00
Kavon Farvardin
149c052ec5 use new noncopyable types infrastructure
The infrastructure underpinning the new feature NoncopyableGenerics is
mature enough to be used.
2024-03-14 23:10:44 -07:00
Arnold Schwaighofer
7196c9c9ea Merge pull request #72296 from aschwaighofer/build_config_fix_fragile_resilient
Don't set enable-library evolution under SWIFT_STDLIB_USE_FRAGILE_RESILIENT_PROTOCOL_WITNESS_TABLES
2024-03-13 15:28:06 -07:00
Arnold Schwaighofer
2bd3feeeee Don't set enable-library evolution under SWIFT_STDLIB_USE_FRAGILE_RESILIENT_PROTOCOL_WITNESS_TABLES
Rather, for the purpose of testing set this under an individual build
preset configuration.
2024-03-13 10:27:40 -07:00
Arnold Schwaighofer
315a763c28 Merge pull request #72218 from aschwaighofer/fragile_resilient_protocols
IRGen: Add code to support building fragile resilient protocol witnesses
2024-03-13 08:40:44 -07:00
Arnold Schwaighofer
9639e007d8 Teach TBD that in fragile resilient protocol mode the protocol table is visible 2024-03-11 09:49:38 -07:00
Arnold Schwaighofer
ea70aea43c IRGen: Add code to support building fragile resilient protocol witnesses
We don't currently support building resilient relative protocol witness tables.
One might want to build with relative witness tables but not need
resilient protocols. Allow for that scenario.

Add a test configuration to test library-evolution + fragile resilient
protocols + relative protocol witness tables.
2024-03-10 09:14:08 -07:00
Slava Pestov
123045f825 Merge pull request #71780 from slavapestov/remove-non-experimental-assoc-type-inference
Remove old associated type inference implementation
2024-03-07 22:14:06 -05:00
Slava Pestov
af8c8f1671 Sema: Remove non-experimental associated type inference 2024-03-07 17:30:17 -05:00
Meghana Gupta
f3a85b118f Add build-script option and lit config for nonescapable_types
With this build-script has a flag --enable-experimental-nonescpable-types=1
to enable this feature in stdlib.

Also we can now add // REQUIRES: nonescapable_types to tests which run only when
the compiler is built with this feature turned on.
2024-03-06 21:57:03 -08:00
Xi Ge
834ade5f99 cmake: avoiding generating ABI baseline files when building stdlib
We have a regression test checked in the compiler repository to detect ABI breakges as the
stdlib evolves, therefore we don't need to generate these side car files for ABI checking
purposes that could be potentially done externally.

Related to: rdar://118465899
2024-02-29 11:36:57 -08:00
Finagolfin
fcf7614638 [CMake] Add broader support for cross-compiling the portions of the compiler that are written in Swift to non-Darwin Unix
Add cross-compilation flags for the newly added Swift source in `lib/ASTGen/`,
similar to how `SwiftCompilerSources/` is already cross-compiled for other
platforms. Make sure the Swift source in the compiler builds and links against
`SWIFTLIB_DIR` in this cross-compilation build directory, not the one that comes
with the native host compiler.

This requires changing the dependency chain in `CROSSCOMPILE` mode, as normally
the Swift compiler is built first when building natively for the host, then it's
used to build the stdlib. However, when cross-compiling the toolchain, the stdlib
must be cross-compiled first by the host compiler, then the portions of the
Swift compiler written in Swift must be cross-compiled with that new stdlib. All
these dependency changes simply change that compilation order when cross-compiling,
including removing the dependency that the Swift compiler is built before the
stdlib when cross-compiling the Swift compiler.

All changes in this pull are gated on the `CROSSCOMPILE` mode, so they will
not affect any of the existing CI or build presets.
2024-02-13 12:24:24 +05:30
Kavon Farvardin
ee12fd6655 NCGenerics: reenable round-trip for mangling 2024-02-06 08:15:26 -08:00
Michael Gottesman
42a4d2d0cd Merge pull request #71236 from gottesmm/pr-213cb762cfa24a27de8dc40f5c2929451d1825cb
[stdlib] Add an option SWIFT_STDLIB_ENABLE_STRICT_CONCURRENCY_COMPLETE to enable building the stdlib with strict-concurrency=complete.
2024-01-31 11:20:32 -08:00
Michael Gottesman
2db4b5ca52 [stdlib] Add an option SWIFT_STDLIB_ENABLE_STRICT_CONCURRENCY_COMPLETE to enable building the stdlib with strict-concurrency=complete.
It is currently by default off.
2024-01-29 21:21:05 -08:00
Saleem Abdulrasool
1864caad5e build: migrate to CMake based build of swift-format
This allows us to build swift-format with dynamic linking against the
toolchain build of the swift-syntax and swift-argument-parser packages.
Wire up the swift-markdown build and hoist the swift-format build prior
to sourcekit-lsp. This sets us up for supporting swift-format based
formatting in the LSP.
2024-01-26 15:51:29 -08:00
Kavon Farvardin
fc9575cda9 [NCGenerics] enable new associated type inference
The experimental-associated-type-inference flag is needed to correctly
build programs when NoncopyableGenerics is enabled.
2024-01-23 22:41:59 -08:00