Commit Graph

491 Commits

Author SHA1 Message Date
Evan Wilde
3b99b43d91 Merge pull request #85931 from etcwilde/ewilde/stringprocessing-flags
CMake: StringProcessing: More apple flags
2025-12-11 09:22:21 -08:00
Tim Kientzle
efdd00892c Merge pull request #85797 from tbkka/tbkka-float-parsing
Reimplement Floating-Point Parsing in pure Swift
2025-12-10 18:42:41 +00:00
Evan Wilde
b2797334eb CMake: StringProcessing: Embed Plist Sections
Generate and embed plists for StringProcessing libraries.

rdar://165944416
2025-12-09 13:39:36 -08:00
Evan Wilde
1f9bdcadc2 CMake: StringProcessing: Catalyst support
Enable catalyst support in Apple StringProcessing builds
2025-12-09 13:34:29 -08:00
Tim Kientzle
93eb82c9a3 [Embedded] Reimplement Float16/32/64 parsing in Swift
This reimplements the underlying support for `Float16(_:StringSlice)`,
`Float32(_:StringSlice)`, and `Float64(_:StringSlice)` in pure Swift,
using the same core algorithm currently used by Apple's libc.  Those
`StringSlice` initializers are in turn used by `Float16(_:String)`,
`Float32(_:String)`, and `Float64(_:String)`.

**Supports Embedded**: This fully supports Embedded Swift and
insulates us from variations in libc implementations.

**Corrects bugs in Float16 parsing**: The previous version of
`Float16` parsing called libc `strtof()` to parse to a 32-bit float,
then rounded to `Float16`. (This was necessary because float16
parsing functions are not widely supported in C implementations.)
This double-rounding systematically corrupted NaN payloads and
resulted in 1 ULP errors for certain decimal and hexadecimal inputs.
The new version parses `Float16` directly, avoiding these errors.

**Modest perforamnce improvement**:  The old version had to copy
the Swift string to construct a C string.  For inputs longer than
15 characters, this typically required a heap allocation, which added
up to 20% to the runtime.  The new version parses directly from a Swift
string, avoiding this copy and heap allocation.
2025-12-06 09:04:12 +00:00
Eric Miotto
817a890a67 CMake Android: ensure _Builtin_float is built before _math
_math would be able to build against either the Swift or the clang
module for _Builtin_float; however the build will fail if the Swift
module is present but does not contain the architectures we need, with errors
like

```
<unknown>:0: error: could not find module
'_Builtin_float' for target 'armv7-unknown-linux-android'; found:
aarch64-unknown-linux-android, x86_64-unknown-linux-android, at:
/home/build-user/build/swift-project/Ninja-Release/swift-linux-x86_64/lib/swift/android/_Builtin_float.swiftmodule/armv7-unknown-linux-android
```

In other words, in this situation we are not falling back to the clang
module.

Addresses rdar://165768601
2025-12-05 12:58:06 -08:00
Evan Wilde
4ad6bea8c2 Merge pull request #85825 from etcwilde/ewilde/concurrency-tracing
Concurrency Runtime: Enable tracing with `SWIFT_STDLIB_TRACING`
2025-12-04 08:17:22 -08:00
Doug Gregor
dcebf64e32 Merge pull request #85808 from DougGregor/unicode-data-without-shims
Move Unicode Data declarations from SwiftShims to `@_extern(c)`
2025-12-04 01:50:41 -08:00
Evan Wilde
c1efd8f9d2 Concurrency: Use SWIFT_STDLIB_TRACING
Switching the concurrency runtime to use the common SWIFT_STDLIB_TRACING
to control whether the concurrency runtime enables tracing. The old
process required passing bot the `SWIFT_STDLIB_TRACING` and
`SWIFT_STDLIB_CONCURRENCY_TRACING` macro to the concurrency build or it
would fail to build.

It's not clear that there are any environments where it is desirable
for swiftCore to have tracing enabled and not have swift_Concurrency
tracing enabled or vice versa. Replacing the concurrency-specific macro
with a single common macro. If it is desirable, we can teach the build
system to avoid passing `SWIFT_STDLIB_TRACING` to a specific target if
an option is not set.

rdar://165777240
2025-12-03 14:02:40 -08:00
Evan Wilde
968f086d82 Merge pull request #85810 from etcwilde/ewilde/fix-synchronization-sources
CMake: Synchronization Source Lists
2025-12-03 09:37:31 -08:00
Evan Wilde
5ba064c5f9 Merge pull request #85804 from etcwilde/ewilde/Apple-stringprocessing-caches
CMake: StringProcessingCaches
2025-12-02 18:30:27 -08:00
Evan Wilde
394e907802 CMake: Synchronization
Fixing sources used to build synchronization library. This aligns the
synchronization source list with what is posted in the old build system.

```
set(SWIFT_SYNCHRONIZATION_DARWIN_SOURCES
  Mutex/DarwinImpl.swift
  Mutex/Mutex.swift
)
set(SWIFT_SYNCHRONIZATION_LINUX_SOURCES
  Mutex/LinuxImpl.swift
  Mutex/Mutex.swift
  Mutex/SpinLoopHint.swift
)
set(SWIFT_SYNCHRONIZATION_FREEBSD_SOURCES
  Mutex/FreeBSDImpl.swift
  Mutex/Mutex.swift
)
set(SWIFT_SYNCHRONIZATION_WASM_SOURCES
  Mutex/Mutex.swift
  Mutex/WasmImpl.swift
)
set(SWIFT_SYNCHRONIZATION_WINDOWS_SOURCES
  Mutex/Mutex.swift
  Mutex/WindowsImpl.swift
)
set(SWIFT_SYNCHRONIZATION_OPENBSD_SOURCES
  Mutex/Mutex.swift
  Mutex/OpenBSDImpl.swift
)
```

This is specifically to fix this error when building for Linux:

```
/build/swift/Runtimes/Supplemental/Synchronization/Mutex/LinuxImpl.swift:99:19: error: cannot find '_tries' in scope
 97 |       // This value is controlled on a per architecture bases defined in
 98 |       // 'SpinLoopHint.swift'.
 99 |       var tries = _tries
    |                   `- error: cannot find '_tries' in scope
100 |
101 |       repeat {

/build/swift/Runtimes/Supplemental/Synchronization/Mutex/LinuxImpl.swift:126:9: error: cannot find '_spinLoopHint' in scope
124 |         // effect of slowing down this loop if only by a little to preserve
125 |         // energy.
126 |         _spinLoopHint()
    |         `- error: cannot find '_spinLoopHint' in scope
127 |       } while tries != 0
128 |     }
ninja: build stopped: subcommand failed.
```
2025-12-02 18:15:34 -08:00
Doug Gregor
3c933a1f73 Move Unicode Data declarations from SwiftShims to @_extern(c)
This eliminates UnicodeData.h from the public SwiftShims. A small
part of it remains as a private header, but everything else moves
into `@_extern(c)`.
2025-12-02 15:11:53 -08:00
Evan Wilde
3bdba03f99 CMake: StringProcessingCaches
Add Apple caches for the StringProcessing libraries.
2025-12-02 10:51:23 -08:00
Eric Miotto
aaad315e50 Runtimes: build Runtime and StringProcessing with whole module...
...optimization in Apple vendor configurations.

This is needed to avoid increasing the
size of the associated dylibs.

Take this chance to remove the `-enable-ossa-modules` flag when building
Runtimes, since that's a noop now.

Addresses rdar://165699017
2025-12-02 10:24:18 -08:00
Evan Wilde
d2681c5224 Merge pull request #85778 from etcwilde/ewilde/export-glibc-clang-overlay
CMake: Add GlibC Clang Overlay to export set
2025-12-02 08:26:49 -08:00
Evan Wilde
e7a8bf7288 CMake: Add GlibC Clang Overlay to export set
Adding the Glibc Clang Overlay interface target to the installed export
set. The interface library exists to plumb the appropriate flags through
the build graph and ensure that the modulemap and header file are
generated when depended on.

Interface libraries need to be in the export set when depended on by a
public library to ensure that the appropriate install interface flags
are exposed to targets importing the library from outside of the build
system, regardless of whether the interface library actually installs
any files.

This fixes the configuration-time error:

Export called with target "swiftGlibc" which requires
"SwiftGlibcClangOverlay" that is not in any export set.
2025-12-01 15:27:48 -08:00
Evan Wilde
3aa8b76a00 Merge pull request #85616 from etcwilde/ewilde/stdlib-tracing
CMake: Runtimes: Enable tracing on Apple OSs
2025-11-20 17:19:26 -08:00
Evan Wilde
20cfe0a4e0 CMake: Verify os_signpost_*/os_log with tracing
Adding check to CMake to verify that we have the os_signpost and os_log
API available in order to accept enabling the runtime tracing.
2025-11-20 08:34:39 -08:00
Evan Wilde
01eb3990be CMake: Runtime: Enable tracing on Apple platforms
Adding tracing to concurrency, and enable tracing on the standard
library on Apple OSs.

rdar://164925172
2025-11-20 08:34:23 -08:00
Saleem Abdulrasool
f4a60df6ea build: explicitly error out if -print-target-info fails
Rather than trying to silently continue, catch an execution error and
report it to the user. There is no possible recovery at this point.
2025-11-18 10:01:39 -08:00
Eric Miotto
d704461048 Merge pull request #85367 from edymtt/edymtt/link-client-retain-release-from-swift-core-in-runtimes-build-system
Runtimes: allow to link swiftSwiftDirectRuntime
2025-11-14 11:55:54 -08:00
Eric Miotto
578b7f44fe Allow to link SwiftSwiftDirectRuntime in Supplemental build system
Addresses rdar://164174616
2025-11-14 07:02:02 -08:00
Eric Miotto
b1f7f81c4e Add support for linking SwiftSwiftDirectRuntime in Overlay build system
Addresses rdar://164174616
2025-11-14 07:01:57 -08:00
Eric Miotto
57908cd4e7 Runtimes: allow to link SwiftDirectRetainRelease in swiftCore
At the moment we are not building that natively in the new build system,
so find the copy built by the legacy one using a find module.

Keep this disabled for the time being.

Addresses rdar://164174616
2025-11-14 07:01:27 -08:00
Evan Wilde
22d2511477 CMake: StringProcessing: Set C visibility hidden
Don't expose the C symbols from StringProcessing.
2025-11-12 17:03:14 -08:00
Eric Miotto
a93595e589 Merge pull request #85371 from edymtt/edymtt/rename-core-to-be-higher-in-directory-listings
Runtimes: rename Core/core to Core/Core (uppercase C) so it appears...
2025-11-10 06:36:29 -08:00
Eric Miotto
9e85aa7fd2 Runtimes: rename Core/core to Core/Core (uppercase C) so it appears...
higher in case sensitive directory listings (like GitHub).

This will ease checking for stdlib code on small screens without needing
to scroll.

Addresses rdar://164195263
2025-11-06 14:26:21 -08:00
Eric Miotto
535f83a527 Pass SDK paths explicitly when building Runtimes in macOS smoketest
As per 7b19531291
CMake 4.0 does not pass `-sdk` to compiler invocations if the user does
not provide `CMAKE_OSX_SYSROOT` -- this in turn causes failures in
linking.

Addresses rdar://163672815
2025-10-29 15:47:49 -07:00
Eric Miotto
9c9f6b7a06 Merge pull request #85127 from edymtt/edymtt/cxx-find-module
Supplemental: add find module for Cxx interop modules
2025-10-27 13:21:09 -07:00
Eric Miotto
0466e4925a Supplemental: add find module for Cxx interop modules.
This is meant to support Apple vendor configurations.

Addresses rdar://163341811
2025-10-24 14:20:43 -07:00
Eric Miotto
30cd1ada78 Runtimes: pass target variant flags when compiling assembly code
This ensure we build code correctly for macCatalyst.

Addresses rdar://163363796
2025-10-24 14:04:56 -07:00
Eric Miotto
e9ea78eff6 Overlay: export Cxx interop targets to separate config files
Addresses rdar://163341811
2025-10-24 09:27:06 -07:00
Eric Miotto
a841ab0c5e Merge pull request #84720 from edymtt/edymtt/build-runtime-in-macos-smoketest
Build Runtime in macOS PR testing
2025-10-23 13:47:33 -07:00
Evan Wilde
a2dcc719aa Merge pull request #84737 from etcwilde/ewilde/runtimes-linux-glibc-overlay
CMake: Glibc Overlay
2025-10-21 14:21:25 -07:00
Eric Miotto
72bf8526ab Build Runtime in macOS PR testing
For this to work, add the dependency on Darwin and start building the
Cxx Interop libraries.

Addresses rdar://160774928
2025-10-20 15:34:52 -07:00
Eric Miotto
9eb24e0c1c Merge pull request #84718 from edymtt/edymtt/add-apple-vendor-caches-for-runtimes
Add Apple vendor caches for Runtime
2025-10-20 12:26:11 -07:00
Saleem Abdulrasool
6b0a88ba72 Android: correct module name for _math
This module was named improperly during the migration. Correct the name
to `_math`.
2025-10-16 11:15:13 -07:00
Tim Kientzle
41f680cb93 Merge pull request #84826 from tbkka/tbkka-revert-revert-floatingpointdescription
Re-land new Floating-poing `debugDescription`
2025-10-12 20:19:12 -07:00
Evan Wilde
44830d788c Overlays: Add Glibc Linux SDK overlay build
Adding a new glibc overlay for Linux builds. We will eventually need one
for Musl, and if someone really wants to, LLVM and cosmopolitan libcs
are also out there.
2025-10-11 16:06:44 -07:00
Tim Kientzle
b69d5fe40c Add Internal version of InlineArray with no availability limitations 2025-10-10 14:04:16 -07:00
Saleem Abdulrasool
69b4443304 Distributed: repair the build for Windows with early swift-driver
When we enable the early swift-driver, CMP0157 will be enabled, changing
the linker language for the library, changing the library prefix.
Correct this for that scenario.
2025-10-10 08:39:37 -07:00
Saleem Abdulrasool
6a1ff42a80 Merge pull request #84781 from compnerd/pretty-special
Runtime: disable prespecialisation on Windows
2025-10-09 10:21:30 -07:00
Evan Wilde
5088eb5927 Merge pull request #84741 from etcwilde/ewilde/runtimes-fix-cleanups
NFC: CMake: Runtime build housekeeping
2025-10-08 21:29:21 -07:00
Saleem Abdulrasool
bb18e02590 Runtime: disable prespecialisation on Windows
This causes crashes at runtime (see swiftlang/swift#84780).
2025-10-08 18:41:20 -07:00
Justice Adams
78f54c30fc [cmake] add cache files for Volatile (#84750)
Add cache files for the supplemental Volatile library
2025-10-08 16:12:42 -07:00
Evan Wilde
989b3bea01 NFC: Clean up runtime comments
Updating the todo list comments.

 - Windows builds are already using the runtime build system to build
   the runtimes so we can remove that from the todo list.

 - The Android SDK on Windows is currently cross-compiled with the new
   runtime build.

 - Catalyst builds have been going for a bit now, generating the
   necessary bits.

 - We moved things to a nested swiftmodule structure, which installs the
   entire directory, containing all of the emitted products.

The Glibc Linux builds should be coming soon.
We still have embedded to work on.
2025-10-07 15:16:17 -07:00
Evan Wilde
28a63171c3 SDK Overlays: Linux: disable explicit module builds
Explicit module builds crash the compiler when building the glibc
overlay library. The crash occurs in the Swift driver dependency
scanner. It appears to be related to vfs overlays, modulemaps,
injected header files, and explicit module builds.

This is odd though because the Android builds also have this
combination, but work.
2025-10-07 12:45:40 -07:00
Evan Wilde
0f3f3e5a59 NFC: Cleanup full module directory
Adding the additional driver outputs in the cleanup files. This cleans
up the warnings from `ninja clean`.

```
Cleaning... ninja: error: remove(clang/_Builtin_float.swiftmodule): Directory not empty
```
2025-10-07 11:18:46 -07:00
Evan Wilde
beac5fa1e1 NFC: Cleanup module directory name
This is a small refactor to rename the build module directory,
"${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule" to
"${module_directory}" to make it more concise.
2025-10-07 11:10:06 -07:00