Files
Doug Gregor 736efe4bfa [Embedded] Add interface-LTO build mode for the stdlib
When the embedded stdlib's target triple matches the new
SWIFT_EMBEDDED_INTERFACE_LTO_TRIPLE_REGEX (empty by default), build it
under `CodeGenerationModel=interface` with LLVM LTO. The resulting
`libswiftCore.a` contains real bitcode rather than the empty stubs
produced for the default Inlinable model, so clients reference its
strong external definitions instead of re-emitting `linkonce_odr`
copies of every stdlib function. C/C++ sources in the embedded
libraries are compiled with `-flto=` to match, so the linker sees a
coherent set of bitcode inputs.

Compiler:
  `SILFunction::hasValidLinkageForFragileRef` accepts
  `isNeverEmitIntoClient()` callees so a serialized caller in another
  module can reference an interface-mode body in libswiftCore.a by
  name. The linker resolves the call to the owning module's
  definition.

Stdlib:
  Promote `writeChars` (the embedded stdout helper used by
  `EmbeddedPrint`'s `print` overloads and `_Stdout.write`) to
  `@usableFromInline internal` so the SIL Linker can pull the body
  into generic specializations like `print<Int>` emitted into client
  code.

Test infrastructure:
  * `SWIFT_EMBEDDED_INTERFACE_LTO_TRIPLE_REGEX` is plumbed into lit via
    `lit.site.cfg.in`; `test/lit.cfg` derives the
    `embedded_stdlib_default_codegen` / `embedded_stdlib_interface_lto`
    feature globally so any test can `REQUIRES:`, `UNSUPPORTED:`, or
    `%if` against it.
  * Tests that verify default-mode contract (`dependencies-*`,
    `exclusivity_runtime`, `throw-trap-stdlib`,
    `concurrency-non-symbols`, `concurrency-deleted-method`) now
    `REQUIRES: embedded_stdlib_default_codegen`.
  * `SILOptimizer/devirt_deinits.swift` gates its embedded RUN line
    with `%if embedded_stdlib_default_codegen %{ ... %}` because that
    line doesn't link against `libswiftCore.a`.
  * Add an interface-mode RUN line to `extern_c_body_in_other_module`
    and a new `extern_c_thunk_no_interface_model` test covering
    interface-mode-specific behavior around `@_extern(c)` and
    `@_silgen_name` thunks.
2026-07-14 11:56:49 -07:00
..