Commit Graph

483 Commits

Author SHA1 Message Date
Doug Gregor 4332654b7b Address code review feedback 2026-05-14 21:57:15 -07:00
Doug Gregor 1c3290cbf4 [CMake] Put the creation of .swiftsourceinfo files behind SWIFT_STDLIB_ENABLE_SOURCE_INFO
We've been hitting some issues where having the .swiftsourceinfo files
in the toolchain can cause hangs on macOS. Provide CMake-level control
for their generation so we can selectively enable them.

Fixes rdar://176894222
2026-05-12 22:20:20 -07:00
Steven Wu 72c8c21104 [build-script] Add --enable-caching support with clang-cache and Swift compilation caching
Add a new --enable-caching option that enables compilation caching for both
C/C++ (via clang-cache as compiler launcher) and Swift code (via
-cache-compile-job flags when bootstrapping=hosttools).

New options:
- --enable-caching: main toggle, incompatible with --sccache/--distcc
- --caching-cas-path: CAS directory (default: $BUILD_ROOT/cas)
- --caching-depscan-socket: depscan daemon socket path
- --caching-plugin-path: CAS plugin library path
- --caching-plugin-option: CAS plugin options (repeatable)
- --caching-prefix-map: enable source/SDK/toolchain prefix mapping
- --caching-remote-service-path: remote caching service with auto
  plugin inference from Xcode and implied prefix mapping

The build script starts a clang-cache depscan daemon with reliable cleanup
via atexit and SIGTERM handlers. Per-product build directories get .cas-config
and compilation-prefix-map.json files written automatically.

Caching flags are applied to all Swift host compilation targets: compiler
sources, pure-swift host libraries (ASTGen, macros), swift-syntax, and
the new runtime build when --build-runtime-with-host-compiler is used.

When not using --caching-remote-service-path, enables CAS backend
(-Xfrontend -cas-backend -Xllvm -cas-friendly-debug-info) unless
SWIFT_CACHE_DISABLE_MCCAS is set.

A ninja wrapper is generated at build/<subdir>/build-utils/ninja for
cached incremental builds outside the build-script.

rdar://155876033

Assisted-By: Claude
2026-04-29 14:42:17 -07:00
Allan Shortlidge 3affc66abf stdlib: Adopt anyAppleOS availability.
Resolves rdar://171558256.
2026-03-26 06:02:58 -07:00
Doug Gregor 20e65b713e Merge pull request #84474 from DougGregor/stdlib-swiftsourceinfo
Build and install .swiftsourceinfo files for the standard library + friends
2026-03-18 21:56:38 -07:00
Eric Miotto 1a602c4ad8 Merge pull request #87834 from edymtt/edymtt/ensure-we-can-use-older-cmake
Embedded Swift stdlib: ensure #87627 is compatibile with CMake 3.20
2026-03-12 23:45:27 -07:00
Eric Miotto 27942326e0 Embedded Swift stdlib: ensure #87627 is compatibile with CMake 3.20
* to check for the presence of the archiver, use `EXISTS`/`IS_DIRECTORY`
  instead of `IS_EXECUTABLE`
* use `$<JOIN:...>` instead of `$<LIST:JOIN,...>` to compose the
  archiving commands
* to be on the safe side, perform the check on the archiver only if
  we are building the embedded stdlib
2026-03-12 13:02:20 -07:00
Doug Gregor fbeb12273d macCatalyst update for source file info emission 2026-03-11 10:59:07 -07:00
Doug Gregor af0855f8fe Build and install .swiftsourceinfo files for the standard library + friends
These are useful for debug backtraces when building against the binary
Swift modules. For Embedded Swift, it's even more important because
everything gets inlined. rdar://159398310
2026-03-11 10:57:46 -07:00
Kavon Farvardin 8f8b782531 Merge branch 'main' into se427-techdebt 2026-03-11 10:00:18 -07:00
Kavon Farvardin e5b2ead0d7 Sema: remove SE427NoInferenceOnExtension
The feature was added only to avoid a reverse-condfail
in the initial bring-up of noncopyable generics.

Nearly 2 years have passed since the last time I tried
to remove this old technical debt [1] and had to revert
it due to outdated build bots [2]. Hoping that won't be
a problem this time.

[1] 5b2f2cbfcf
[2] https://github.com/swiftlang/swift/pull/75267

resolves rdar://131560183
2026-03-11 09:57:47 -07:00
Eric Miotto b044464abf Embedded Swift stdlib: ensure archives are properly generated...
when building non Darwin architectures with Xcode 26.4 beta 1 and later
-- the archiver that ships in Xcode is guaranteed to work only on MachO
object files, and will generate empty archives for other executable
formats.

This is a temporary solution while we add the support to build the
Embedded Swift stdlib in the new Runtimes build system.

Addresses rdar://171007411
2026-03-02 08:30:46 -08:00
Kavon Farvardin dde4f8e092 Merge pull request #87325 from kavon/use-suppassocwithdefaults
Stdlib: switch to SuppressedAssociatedTypesWithDefaults
2026-02-20 02:11:07 -08:00
Slava Pestov 7982ceda0a Merge pull request #87305 from slavapestov/stdlib-salvage
stdlib: Build with -solver-enable-crash-on-valid-salvage
2026-02-19 17:49:03 -05:00
Rintaro Ishizaki c8206d1262 [stdlib] Use response files for availability macros
`-define-availability` arguments for stdlib modules can be very long,
which may exceed Windows command-line length limits and cause build
failures. Use response files to avoid this.
2026-02-18 21:57:54 -08:00
Kavon Farvardin 0ae044a555 Stdlib: switch to SuppressedAssociatedTypesWithDefaults
Ever since `_BorrowingSequence` and friends landed in the standard library,
it's introduced a primary associated type that is suppressed. Since the mangling
of generic signatures is different depending on whether you're using
`SuppressedAssociatedTypes` and the `-WithDefaults` version, we should introduce
it with the new mangling in-place. It's also source breaking to make this switch
happen later on, since defaults will get assumed where they were not before.

rdar://170650908
2026-02-18 21:14:39 -08:00
Slava Pestov 0fdcf10b1a stdlib: Build with -solver-enable-crash-on-valid-salvage 2026-02-18 11:08:09 -05:00
Rintaro Ishizaki 9822843aed [stdlib] Stop enabling NoncopyableGenerics2 "experimental" feature
`NoncopyableGenerics2` is a BASELINE_LANGUAGE_FEATURE since Jul., 2024.
2026-02-17 21:03:35 -08:00
susmonteiro 66171ac72e [cxx-interop] Use temporary _BorrowingSequence 2026-02-13 08:37:29 +00:00
Meghana Gupta a0664a938a Merge pull request #87019 from meg-gupta/assertconf
Add -assert-config DisableReplacement to the private oslog library
2026-02-06 09:13:21 -08:00
Meghana Gupta 57ee2bd4f5 Add -assert-config DisableReplacement to the private oslog library
We have a private oslog library to test optimizations specific for oslog.
Add -assert-config DisableReplacement to this library similar to the real oslog library.
This prevents surprizing optimizer regressions.
2026-02-05 15:52:36 -08:00
Alastair Houghton 4f90a96640 [Backtracing][Windows] Fix things to install swift-backtrace
We needed to modify `build.ps1` to copy `swift-backtrace.exe` into
position.  Also tidy up the code in `AddSwiftStdlib.cmake`.

rdar://101623384
2026-02-03 18:23:29 +00:00
Alastair Houghton d13988bd5f [Backtracing][Windows] Initial Windows support.
This doesn't have a working symbolicator yet, but it does build and
it can obtain a basic backtrace.

It also doesn't include a working `swift-backtrace` program yet.

rdar://101623384
2026-02-03 18:23:29 +00:00
Daniel Rodríguez Troitiño b37511ef42 [CMake] Explicitly disable LTO if no LTO option is provided (take 2) (#86187)
This is second version of #85621 which was reverted in #85794 because
the result of `_compute_lto_flag` was used as a boolean in some
contexts.

The differences from the original is that `_compute_lto_flag` is split
into a second function `_is_lto_enabled` which provides an actual
boolean for when LTO is enabled, and the half dozen usages of
`_compute_lto_flag` have been audited for using `_compute_lto_flag`
without considering the return value a boolean, or using the new
`_is_lto_enabled` as a proper boolean. A small clean up of commented out
code is performed (probably just a forgetten clean up from #66077).

The changes have been verified by compiling with
`SWIFT_STDLIB_ENABLE_LTO=thin` and
`SWIFT_STDLIB_BUILD_TYPE=RelWithDebInfo`, and checking the resulting
flags for building the stdlib include both `-flto=thin` and
`-gline-tables-only`, while the Swift tools include `-fno-lto` instead.

The following is the original commit message, which explains why this
change is interesting:

---

When compiling Swift as an LLVM external project (not the non-unified
workflow from the build-script), if one tries to enable LTO for LLVM
projects it will end up affecting Swift and the Swift standard library,
even if the options `SWIFT_TOOLS_ENABLE_LTO` and
`SWIFT_STDLIB_ENABLE_LTO` are disabled or using their default values,
because [HandleLLVMOptions] modifies the `CMAKE_C/CXX_FLAGS` globally.

By setting `-fno-lto` explicitly when those options are disabled or
using their default values, the options from `CMAKE_C/CXX_FLAGS` are
overriden, and the `SWIFT_*_ENABLE_LTO` controls the usage or not of LTO
optimizations and the presence of bitcode in the object files.

[HandleLLVMOptions]:
https://github.com/swiftlang/llvm-project/blob/b58b2a34d5094928c4ee1b94a7d5412b14540c01/llvm/cmake/modules/HandleLLVMOptions.cmake#L1278-L1310
2026-01-12 10:08:42 -08:00
Alejandro Alonso 2e46df25a5 Make strict memory safety an error in the stdlib 2026-01-03 11:39:27 -08:00
Alastair Houghton c8b69781af Merge pull request #84705 from al45tair/eng/PR-160455139
[Build] Disable library evolution in the Static SDK for Linux.
2025-12-15 15:17:23 +00:00
Evan Wilde 1c3541e926 Build: Remove concurrency tracing option
Stripping out the logic behind enabling concurrency tracing
independently of the rest of the standard library tracing. It's not
clear that there is a use-case where we want one without the other.
2025-12-03 14:03:40 -08:00
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
Mads Odgaard c92e5b47f3 Merge pull request #84574 from madsodgaard/android-availability 2025-10-20 10:40:37 +09:00
Alastair Houghton 796d127058 [Build] Disable library evolution in the Static SDK for Linux.
We don't want library evolution turned on for the Static SDK.

We can't do this in the `StdlibOptions.cmake` file because that's
testing the *host*, not the *target* (the code in there is wrong).

rdar://160455139
2025-10-06 10:39:37 +01:00
Erik Eckstein 2f124cf564 Remove the -enable-ossa-modules option.
OSSA modules are enabled by default.
The compiler still accepts this option but it has no effect.
2025-09-26 08:01:08 +02:00
Egor Zhdan 28f9db7bfa [WinSDK] Modularize <guiddef.h>
This fixes modularization errors that arise when importing a C++ header that contains `#include <guiddef.h>`, which might hijack this header from the WinSDK module where it belongs.
2025-08-28 22:21:55 +01:00
Alastair Houghton 857539f3c5 [Build] Fix minimal stdlib build.
We need the new `deployment_version` function to handle the `FREESTANDING`
SDK also.

rdar://155841439
2025-08-01 14:37:34 +01:00
Alastair Houghton 27b1a7d8ee [Build] Fix deployment version handling for StdlibDeploymentTarget.
Where someone has told a target library to build for a _newer_ target
than the current deployment target, we need to respect that newer
target when setting StdlibDeploymentTarget for that target library.

This trips us up when testing against older systems.

rdar://155841439
2025-08-01 12:49:23 +01:00
Marc Prud'hommeaux 663ec9340d Support 16 KB page sizes on Android (#81596)
Android 15+ requires that native libraries be compiled with a linker
flag to support 16 KB page sizes. See:
https://developer.android.com/guide/practices/page-sizes#compile-r26-lower
2025-07-29 20:42:22 +05:30
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
Alastair Houghton 42ca1b1cc8 Rename SwiftStdlibCurrentOS to StdlibDeploymentTarget.
`StdlibDeploymentTarget` seems to be a better name.

rdar://152498657
2025-06-04 10:40:19 +01:00
Alastair Houghton d5ed335339 Merge pull request #81440 from al45tair/currentos-availability
[Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it.
2025-06-03 15:01:22 +01:00
Alastair Houghton cd7701cd82 [Build] Add catalyst support to SwiftStdlibCurrentOS.
Add catalyst support for SwiftStdlibCurrentOS.

Also, set a minimum deployment target when building Concurrency;
this stops the build failing when we're trying to build on older
systems where Concurrency didn't really exist yet.

rdar://150966361
2025-05-23 10:31:56 +01: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
Alastair Houghton 28f96e64ab [Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it.
If you use SwiftStdlibCurrentOS availability, you will be able to
use new types and functions from within the implementation. This
works by, when appropriate, building with the CurrentOS availability
set to the current deployment target.

rdar://150944675
2025-05-12 12:07:24 +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
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 a5c561fb13 Merge pull request #80831 from glessard/rdar149227278-nonescapable-mutating-accessor
[LifetimeDependenceMutableAccessors] defensive feature flag
2025-04-17 09:27:23 -07:00
Guillaume Lessard 3670664ce6 [stdlib] use “LifetimeDependenceMutableAccessors” 2025-04-15 10:41:27 -07:00
QuietMisdreavus 41120da702 [SymbolGraphGen] add flags to filter platforms out of availability metadata (#80778)
* add option to filter availability metadata in symbol graphs

* filter out platform-specific availability in the stdlib docs

rdar://144379124
2025-04-14 15:20:22 -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