Commit Graph

21434 Commits

Author SHA1 Message Date
Alastair Houghton
f4bf27852f [Backtracing] Make the backtracer work for fully-static Linux.
The backtracer and its build system need a couple of changes to make
them work with the new fully-static Linux support.

rdar://123507656
2024-05-07 16:51:34 +01:00
Alastair Houghton
a2c33ad22c [Runtime] Fix generation of .lnk files for static linking.
Use the new `SWIFT_SDK_<sdk>_STATIC_LINKING_SUPPORTED` and
`_STATIC_ONLY` flags instead of hardcoding support for Linux
and WASI.

Also, use the `_LIB_SUBDIR` variable rather than lowercasing
the SDK.

rdar://123504757
2024-05-07 16:45:16 +01:00
Yuta Saito
7e3c7089aa [Build] Repair the build for non-static-only static stdlib builds
When SWIFT_BUILD_STATIC_STDLIB=ON, SWIFT_BUILD_DYNAMIC_STDLIB=OFF, and
the sdk being built is not a static-only (e.g. WASI), the build fails
due to duplicate custom command rules against the same output path.
In the case of WASI, the static archive should be copied into lib/swift
by the first lipo target, and then the second lipo target should copy it
into lib/swift_static.

```
CMake Error at cmake/modules/SwiftAddCustomCommandTarget.cmake:144 (add_custom_command):
  Attempt to add a custom rule to output

    /home/build-user/build/buildbot_linux/wasmstdlib-linux-x86_64/lib/swift_static/wasi/libswiftCore.a.rule

  which already has a custom rule.
Call Stack (most recent call first):
  stdlib/cmake/modules/AddSwiftStdlib.cmake:673 (add_custom_command_target)
  stdlib/cmake/modules/AddSwiftStdlib.cmake:2657 (_add_swift_lipo_target)
  stdlib/public/core/CMakeLists.txt:401 (add_swift_target_library)
```
2024-05-07 07:31:12 +00:00
Dario Rexin
db7580f842 Merge pull request #73426 from drexin/wip-127379960
[Runtime] Mask out spare bits after copying for Error in CVW
2024-05-06 13:59:37 -07:00
Alastair Houghton
9e2c13bd10 Merge pull request #71839 from al45tair/eng/PR-123503470
[Build] Add the new fully-static Linux SDK.
2024-05-06 17:34:22 +01:00
nate-chandler
bcd08c0c9a Merge pull request #73235 from nate-chandler/bitwise-copyable/enable
[BitwiseCopyable] Promote to feature.
2024-05-04 10:16:40 -07:00
Stephen Canon
da9922d8bb Avoid using generic static members on Duration across module boundaries (#73419)
* Avoid using generic static members on Duration across module boundaries

Because the clocks are implemented in Concurrency, but Duration is in the Swift module, these don't get specialized. Add a fully-concrete internal init in Concurrency to avoid the problem.

* Call self.init(_high:low:) explicitly.

* Add availability annotation.
2024-05-04 10:40:10 -04:00
Stephen Canon
102df47a4c Make static [milli/micro/nano]seconds members on Duration inlinable (#73429)
This means that they can't use _Int128 for their implementation, but efficient implementation of these using only 64b arithmetic is pretty straightforward, so that's OK. This allows them to be specialized and mostly optimized away in release builds.
2024-05-04 10:39:17 -04:00
Alastair Houghton
6afdcd311f Merge pull request #72061 from al45tair/eng/PR-123504095
[Linux][Runtime][IRGen] Mark metadata sections as retained and support section GC.
2024-05-04 09:23:06 +01:00
Doug Gregor
406346b4ba Merge pull request #73425 from DougGregor/task-group-next-public 2024-05-04 00:09:28 -07:00
Nate Chandler
06921cfe84 [SIL] Hollow out Builtin.copy, deprecate _copy.
The copy operator has been implemented and doesn't use it.  Remove
`Builtin.copy` and `_copy` as much as currently possible.

Source compatibility requires that `_copy` remain in the stdlib.  It is
deprecated here and just uses the copy operator.

Handling old swiftinterfaces requires that `Builtin.copy` be defined.
Redefine it here as a passthrough--SILGen machinery will produce the
necessary copy_addr.

rdar://127502242
2024-05-03 15:56:25 -07:00
Dario Rexin
101f8a4760 [Runtime] Mask out spare bits after copying for Error in CVW
rdar://127379960

When the spare bits of an Error objects are used to store tag bits, this caused the enum tag to be lost, which caused the wrong enum cases to be matched.
2024-05-03 12:26:43 -07:00
Doug Gregor
b8d6c7f9d2 Disfavor the older next() APIs on TaskGroup 2024-05-03 12:21:35 -07:00
Doug Gregor
f85eed4858 Bring back TaskGroup.next() and ThrowingTaskGroup.next() as public API
With the introduction of `next(isolation:)` into the task group types,
we removed the public APIs for the no-argument `next()` versions,
leaving them only as `@usableFromInline internal` entrypoints for the
ABI. Because the `next(isolation:)` versions have a default argument,
this was sufficient for providing source compatibility for calls, but
not for protocol conformances.

Bring these APIs back publicly. Fixes rdar://127499568.
2024-05-03 12:09:55 -07:00
Alastair Houghton
3627507eb1 [Build] Further static Linux SDK support changes.
Fix some indentation issues.

Change `build-script-impl` to make `build-linux-static` a positive argument.

Fix documentation for `--linux-archs` and `--linux-static-archs` (the options
are comma separated for `build-script`, but semicolon separated for
`build-script-impl`).

Set the default for `linux-static-archs` to `x86_64, aarch64` so that we
install the expected content in the toolchain.

Add missing default for `test_linux_static`.

Make sure to pass down `--skip-build-linux` and `--build-linux-static`.

Factor out config file generation and call it from the install step in `llvm.py`
as well as from the build step.

rdar://123503470
2024-05-03 09:12:49 +01:00
Egor Zhdan
a5fdf158dc Merge pull request #72268 from apple/egorzhdan/std-string-reserve
[cxx-interop] Faster `std::string` initialization from String
2024-05-02 22:48:42 +01:00
Karoy Lorentey
3061531cb6 [stdlib] ManagedBuffer: Fix misapplied linkage names for legacy entry points
I accidentally copy and pasted the mangled symbol names in the wrong order, so existing callers got directed to the wrong entry points, and things got terribly, terribly wrong.

(We badly need a sensible replacement for these `@_silgen_name` hacks.)

Huge thanks to @edymtt for spotting this!

rdar://127016847
2024-05-02 14:24:55 -07:00
Alastair Houghton
fdc8ffd36f [Build] Updated following initial comments from Eric.
Change the `--linux[-static]-arch` option to `--linux[-static]-archs`, on the
basis that it supports multiple values.

Other tidying.

rdar://123503470
2024-05-02 14:56:18 +01:00
Alastair Houghton
ae1c0455f3 [Build] Add the new fully-static Linux SDK.
Declare a new `LINUX_STATIC` SDK and configure it.

Add options to set the build architectures for the `LINUX` and
`LINUX_STATIC` SDKs, similar to what we have for Darwin, because
we'll be cross-compiling.

Also add an option to point the build system at the sources for
the musl C library, which we're using for `LINUX_STATIC`.

rdar://123503470
2024-05-02 14:56:18 +01:00
Egor Zhdan
4513ca2447 [cxx-interop] Faster std::string initialization from String
Instead of appending characters one-by-one, which resizes the resulting string multiple times, let's reserve the required number of bytes beforehand.

rdar://127423949
2024-05-02 14:07:07 +01:00
Konrad `ktoso` Malawski
dc5e354d69 [Concurrency] Reimplement @TaskLocal as a macro (#73078) 2024-05-01 20:57:20 -07:00
Becca Royal-Gordon
981233ad37 Merge pull request #73128 from beccadax/objcimpl-resilient
Handle resilient stored properties in objcImpl
2024-04-30 20:50:33 -07:00
Holly Borla
43681259e9 Merge pull request #73310 from hborla/async-stream-sendable-error
[Concurrency] Stage in new `Async{Throwing}Stream.init(unfolding:)` errors as warnings.
2024-04-30 19:23:19 -07:00
Kuba (Brecka) Mracek
4e474d81da Merge pull request #73347 from kubamracek/keypath-fix-equality
[KeyPath] Fix regression in == on keypaths
2024-04-30 19:05:58 -07:00
Philippe Hausler
54b3a9b64a [Observation] Optimize cancellation path to avoid excessive copies (#73288) 2024-04-30 14:40:02 -07:00
Kuba Mracek
1d48f28d84 [KeyPath] Fix regression in == on keypaths 2024-04-30 12:50:03 -07:00
Becca Royal-Gordon
4578be2810 Set a minimum deployment target for objcImpl
We’re not committing to @objc @implementation back-deploying to pre-stable Apple platforms.
2024-04-30 12:03:46 -07:00
Becca Royal-Gordon
915a49a1c0 [NFC] Refactor swift_updatePureObjCClassMetadata()
Merge the three-stage operation originally designed for field vectors into a single unified loop that acts directly on the ivar offsets instead of using a faux field offset vector.
2024-04-30 12:03:46 -07:00
Becca Royal-Gordon
d1f14e5814 Eliminate objcImpl field offset vectors
We really don’t need ‘em; we can just adjust the direct field offsets.

The runtime entry point currently uses a weird little hack that we will refactor away shortly.
2024-04-30 12:03:46 -07:00
Becca Royal-Gordon
427386feea Support resilient stored properties in objcImpl
When an @objc @implementation class requires the use of `ClassMetadataStrategy::Update` because some of its stored properties do not have fixed sizes, we adjust the direct field offsets during class realization by emitting a custom metadata update function which calls a new entry point in the Swift runtime. That entry point adjusts field offsets like `swift_updateClassMetadata2()`, but it only assumes that the class has Objective-C metadata, not Swift metadata.

This commit introduces an alternative mechanism which does the same thing without using any Swift-only metadata. It’s a rough implementation with important limitations:

• We’re currently using the field offset vector, which means that field offsets are being emitted into @objc @implementation classes; these will be removed.
• The new Swift runtime entry point duplicates a lot of `swift_updateClassMetadata2()`’s implementation; it will be refactored into something much smaller and more compact.
• Availability bounds for this feature have not yet been implemented.

Future commits in this PR will correct these issues.
2024-04-30 12:03:44 -07:00
Holly Borla
2c2090201e [Concurrency] Preserve the mangling of AsyncStream.init(unfolding:onCancel:). 2024-04-30 09:25:23 -07:00
Tim Kientzle
e546684e9a Extract the BitMask support to a separate file 2024-04-29 16:50:58 -07:00
Alex Lorenz
7815f843a3 [android] do not build the builtin float overlay for android (NDK's clang module map doesn't have it) 2024-04-29 15:57:27 -07:00
Alex Lorenz
7a5a0aad22 [android] misc stdlib build fixes 2024-04-29 15:54:05 -07:00
Alastair Houghton
7df249b67c [Runtime] Tidy up a couple of minor nits.
This doesn't change any code, just makes things look slightly
neater.

rdar://123504095
2024-04-29 10:48:23 +01:00
Alastair Houghton
554c402f11 [Runtime] Add the retain attribute to make the backtracer work.
Without `retain` here, we might remove the reference that pulls in
the backtracing support code.

rdar://123504095
2024-04-29 10:48:23 +01:00
Alastair Houghton
b7557247a7 [Runtime] Tidy up section declarations slightly.
This also calls out the reflection sections, even though we don't
actually need to do anything special for them (as it turns out).

rdar://123504095
2024-04-29 10:48:22 +01:00
Allan Shortlidge
250758335c Merge pull request #73306 from tshortli/the-condfails-never-end
stdlib: Fix more typed throws and non-copyable generics condfails
2024-04-27 16:07:28 -07:00
Karoy Lorentey
8f223e98bc Merge pull request #73296 from lorentey/rdar127015095
[stdlib] Optional.map, .flatMap: Remove @_disfavoredOverload
2024-04-26 19:16:50 -07:00
Holly Borla
38cc9511ee [Concurrency] Stage in new Async{Throwing}Stream.init(unfolding:) errors
as warnings.

Marking the closure parameter to these inits as `@Sendable` changed the
inferred isolation of closure arguments in actor-isolated contexts, which
caused new effects checker errors when accessing isolated properties and
methods without `await`. Mark these `init`s as `@preconcurrency`, and fix
the effects checker to downgrade those errors to warnings when the context
of the call is `@preconcurrency`.
2024-04-26 18:09:37 -07:00
Allan Shortlidge
7fc2179c31 stdlib: Fix more typed throws and non-copyable generics condfails.
There were two categories of problem for older compilers that consume the
stdlib `.swiftinterface`:

- The `case .some(borrowing x)` syntax isn't accepted; use `_borrowing`
- Various functions that addopted `~Copyable` generic constraints conflict with
  the `@usableFromInline` ABI stubs that were left in to preserve compatibility
  when the functions are printed with `~Copyable` constraints stripped. The stubs
  need to have different names to get out of the way.

Resolves rdar://127132742
2024-04-26 16:37:09 -07:00
Karoy Lorentey
775aab0c8e [stdlib] Optional.map, .flatMap: Remove @_disfavoredOverload
We don’t need this to worka round the known source compat issue, and it is triggering “expression too complex” errors, causing harm.

rdar://127015095
2024-04-26 11:58:09 -07:00
Mike Ash
4d62c521bd [Runtime] Avoid dlsym of objc_isUniquelyReferenced.
We attempted to use the declaration if it exists, and fall back to dlsym. This didn't actually work and we always call dlsym. Include the right header (when available) and add a weak check to the direct call.

rdar://127116080
2024-04-26 11:44:28 -04:00
Joe Groff
2f954ef5d7 Merge pull request #73259 from jckarter/external-key-path-generic-environment-binding
IRGen: Fix key path generic environment marshalling for external property descriptors.
2024-04-25 16:24:42 -07:00
Nate Chandler
b12def9c6a [BitwiseCopyable] Deprecate unbound overloads.
The unconstrained overloads of loadUnaligned and storeBytes were
deprecated in SE-0426.
2024-04-25 11:44:15 -07:00
Nate Chandler
f9ad81e106 [BitwiseCopyable] Remove #ifs. 2024-04-25 11:44:15 -07:00
Nate Chandler
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
Alex Martini
587c79b6f1 Fix plurals
Incorporates feedback from Slava Pestov <spestov@apple.com>
2024-04-25 11:05:35 -07:00
Joe Groff
02e1f2ea15 IRGen: Fix key path generic environment marshalling for external property descriptors.
The layout of a computed key path component carries an argument buffer for captures, which has
the following layout:

```
---
captured values (subscript indices)
---
generic arguments
---
```

When we reference an externally-defined public property or subscript from a key path, and the
external declaration has a property descriptor, then the generic arguments for the external
declaration get appended to the end of this buffer, giving:

```
---
captured values (subscript indices)
---
generic arguments
---
external property's generic arguments
---
```

The convention for key path accessors to bind their generic environment is thus to unpack them
from the end of the argument buffer, so that the external keypath's accessors can find the
arguments to bind the external generic environment while still allowing the enclosing key path
to save the original captured generic environment (which may be necessary to capture the
appropriate conditional and/or retroactive `Equatable` and `Hashable` conformances for
subscript indices).

However, our code generation for binding the generic arguments out of the argument buffer
contained a flawed optimization: for a property, we know there are never any captured values,
so I had assumed that the generic parameters could always be bound from the beginning of the
argument buffer, assuming that the generic parameters make up the totality of the buffer. This
falls over for external property descriptor references when the key path itself captures a
generic environment, since the external property's expected generic environment appears after
the key path's original generic environment. We can fix this by removing the conditional
entirely, and always adjusting the offset we load the generic environment from to look at the
end of the buffer. Fixes rdar://125886333.
2024-04-25 10:36:13 -07:00
Dave Lee
d7426e2e75 [RemoteInspection] Fix format of dumped spare bit mask (#73231)
Even with `std::hex`, the `uint8_t` values are being printed as characters, not hex 
values. This change casts the value to `int`, which results in the hex representation 
being properly printed.
2024-04-25 09:51:22 -07:00