Commit Graph

21434 Commits

Author SHA1 Message Date
Alex Martini
3c54f6819b Fill in reference for Copyable 2024-04-24 16:58:00 -07:00
Nate Chandler
6e975da805 [BitwiseCopyable] Promote ConformanceSuppression.
The ability to suppress conformance to BitwiseCopyable was part of the
accepted SE-428.
2024-04-24 15:52:20 -07:00
Nate Chandler
ed5c7ef7ae [BitwiseCopyable] Promote to feature.
SE-0426 was accepted.
2024-04-24 15:52:20 -07:00
Michael Gottesman
8c7be03001 Merge pull request #73225 from gottesmm/pr-8b42b60f27fcdfdf5502a79e2a874ce1987d5838
[cmake] Make the hosttools lib SwiftMacros a dependency of the stdlib when we aren't cross compiling.
2024-04-24 16:26:06 -05: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
Mike Ash
e373cae729 Merge pull request #73205 from mikeash/libprespecialize-stack-allocated-demangler
[Runtime] Use StackAllocatedDemangler in getLibPrespecializedMetadata.
2024-04-24 09:01:54 -04:00
Pavel Yaskevich
9542216c6a Merge pull request #73188 from xedin/se-0428-renable-dist-protocol-macro-to-resolvable
[SE-0428] NFC: Rename `_DistributedProtocol` macro into `Resolvable`
2024-04-24 00:18:52 -07:00
Mike Ash
717b03b5a5 [Runtime] Use StackAllocatedDemangler in getLibPrespecializedMetadata.
Reduce the amount of time spent freeing demangler slabs by starting out with a stack allocation that doesn't need to be freed.

rdar://126932780
2024-04-23 14:44:40 -04:00
Alex Martini
8468088e55 Add requirements & sketch TSPL cross reference 2024-04-23 09:12:15 -07:00
Kavon Farvardin
590c7cd925 Merge pull request #73133 from kavon/no-escapable-for-u
prevent uses of `Escapable` in general
2024-04-23 01:49:08 -07:00
Dario Rexin
b97fbac9a6 [Runtime] Fix CVW for genreic single payload enums with no extra inha… (#73186)
* [Runtime] Fix CVW for genreic single payload enums with no extra inhabitants

rdar://126728925

When the payload of a generic SPE did not have any extra inhabitants, we erroneously always treated it as the no payload case.
Additionally the offset and skip values were improperly computed.

* Fixed FileCheck string
2024-04-22 22:56:57 -07:00
Kavon Farvardin
f0a69a3ef1 prevent uses of Escapable in general
This protocol appears in the stdlib as scaffolding for the
`NonescapableTypes` feature, which is still experimental and not gone
through evolution as an approved addition to the stdlib.

Rather than delete it from the stdlib, because it needs to still remain
to support that feature work, gate references to it behind a feature
flag.

Additionally, prevent documentation from seeing this declaration.

rdar://126705184
2024-04-22 20:40:11 -07:00
Pavel Yaskevich
e6b445b8d1 [SE-0428] NFC: Rename _DistributedProtocol macro into Resolvable
The proposal was [accepted with modifications](https://forums.swift.org/t/accepted-with-modifications-se-0428-resolve-distributedactor-protocols/71366)

The decision was made to change the spelling of the attached macro
in the proposal from @DistributedProtocol to `@Resolvable`
(or `@Distributed.Resolvable` if disambiguation is needed).
2024-04-22 14:18:11 -07:00
Mike Ash
720ca4b4d9 Merge pull request #73138 from mikeash/symbolic-reference-lookup-better-error
[Runtime] Add the pointer location to the "failed to look up symbolic reference" error.
2024-04-22 14:15:56 -04:00
Daniel Rodríguez Troitiño
a7ff8159f1 [cmake] Check correctly for different flags. Don't check twice -Wall (#73144)
check_cxx_compiler_flag caches its results for the same variable, since
all the flags were using the same variable, only the first check was
done, and the rest of the flags were just using the result of the first
flag.

Make each of the check_cxx_compiler_flag use a different variable (by
interpolating the flag name) and reorder the list of compiler flags to
check. -Wall was added twice, and in the case of MSVC, the equivalent
was added last.

It doesn't really seem to affect a lot of things.
2024-04-22 08:40:57 -07:00
GG
739ff6f0c2 Fix typo in Result.swift 2024-04-21 21:17:22 +09:00
Mike Ash
84983353d3 [Runtime] Add the pointer location to the "failed to look up symbolic reference" error.
The pointer location can be computed from the symbolic reference location and offset, which we already provide, but it's not clear that you should add them together, nor is it clear why this failure would occur. Add the location of the NULL pointer itself to the error message, and also mention that it's probably caused by a missing weak symbol.
2024-04-19 10:48:44 -04:00
Dave Lee
e57f70bd4d [Debugging] Add DebugDescriptionMacro experimental feature (#73107)
This removes the leading underscore from the macro.
2024-04-18 17:25:44 -07:00
nate-chandler
b00b5aad4f Merge pull request #72646 from nate-chandler/bitwise-copyable/20240327/1
[BitwiseCopyable] Allow suppression via ~.
2024-04-18 07:05:10 -07:00
Karoy Lorentey
c6bc1965f6 [stdlib] Optional, Result: Try adding @_disfavoredOverload to work around a shadowing issue
The new ~Copyable generalizations have changed the function signature enough that alternative definitions of `map`/`flatMap` in existing code that used to be considered to shadow the originals no longer do so. This leads to use sites becoming ambiguous — a source break.

While we consider approaches to resolve this on the compiler side, let’s try slapping a `@_disfavoredOverload` on these and see if that helps.
2024-04-16 17:13:56 -07:00
Karoy Lorentey
153c001b15 [stdlib] Undo typed throws on withExtendedLifetime
https://github.com/apple/swift/pull/73045 has uncovered a compiler crash with existing code of this form:

       try withExtendedLifetime(statement) { // 💥silgen crash
            do {
                try dbPool.close()
                XCTFail("Expected Error")
            } catch DatabaseError.SQLITE_BUSY { }
        }

This patterns can happen with any of the newly typed throwing entry points, but the source compat suite only seems to have caught this with `withExtendedLifetime`; let’s see if we can get away with only rolling back this one.
2024-04-16 17:10:24 -07:00
Karoy Lorentey
fab25dc984 [stdlib] Optional, Result: Update borrowing switch syntax (_borrowing → borrowing) 2024-04-16 01:15:33 -07:00
Karoy Lorentey
5679bf6697 [stdlib] Generalize temporary allocations for noncopyable result types
We can’t do typed throws here yet. (They involve implicit stack allocations that interfere with the explicit stack allocation builtins.)
2024-04-16 01:15:33 -07:00
Karoy Lorentey
cafc99369b [stdlib] Round out ~Copyable generalizations in stdlib primitives
- `Optional.map`, `.flatMap`: Allow noncopyable results. Implement typed throws.

- `Result.map`, `.flatMap`: Allow noncopyable types for the new success.
- `Result.flatMapError`: Generalize for noncopyable Success.

- `Unsafe[Mutable][Buffer]Pointer.withMemoryRebound`: Alllow typed throws.
- `Unsafe[Mutable]BufferPointer: Generalize CustomDebugStringConvertible conformance for noncopyable `Element`s.

- `OpaquePointer.init(_: UnsafeMutablePointer)`, `.init(_: UnsafeMutablePointer?)`: Allow noncopyable pointee types.

- `ManagedBuffer.withUnsafeMutablePointerToHeader`, `.withUnsafeMutablePointerToElements`, `.withUnsafeMutablePointers`: Generalize for typed throws and noncopyable return types. Avoid `@_preInverseGenerics`.
- `ManagedBufferPointer`: Ditto.

- `withExtendedLifetime`: Use typed throws. Stop using `@_preInverseGenerics`.

rdar://117753275
2024-04-16 01:15:33 -07:00
Nate Chandler
eb1f0ac68a [BitwiseCopyable] Suppress via ~.
In addition to the existing language mechanism of
`@available(*, unavailable)`.
2024-04-15 16:46:24 -07:00
Nate Chandler
deeea710ae [NFC] stdlib: Separate type decl from members. 2024-04-15 16:46:00 -07:00
Artem Chikin
01d891ad99 Merge pull request #72834 from artemcm/UpstreamVisionOS
Introduce visionOS Platform
2024-04-15 09:33:49 -07:00
Harlan Haskins
1b36983b8b Add armv4t for GBA programming (#73005) 2024-04-13 18:11:16 -06:00
Alex Martini
325e033547 Add initial reference for Copyable
Drawing from SE-0427.
2024-04-12 16:55:52 -07:00
Saleem Abdulrasool
5919346b32 Platform: add UserEnv module to WinSDK
This allows access to the `GetUserProfileDirectoryW` API which is
required for the swift-foundation implementation on Windows.
2024-04-12 10:25:32 -07:00
Tim Kientzle
9f2acb294f Merge pull request #72943 from tbkka/tbkka-rdar102906195
Fill in extended existential support for type(of:) and mirror
2024-04-11 12:31:42 -07:00
Mike Ash
d964efedba Merge pull request #72958 from mikeash/prespecialized-metadata-disable-per-process
[Runtime] Allow disabling/enabling prespecializations library per-process.
2024-04-11 11:35:18 -04:00
Yuta Saito
10410f1030 Merge pull request #72973 from kateinoigakukun/yt/repair-embedded-wasm-class
[embedded][wasm] Fix missing putchar symbol in test
2024-04-12 00:06:35 +09:00
Yuta Saito
7a205dca32 [embedded] Use @_extern(c) instead of @_silgen_name for putchar 2024-04-11 02:55:23 +00:00
Kuba Mracek
8dfee7de2b [embedded] Conditionalize assert printing to debug assert config 2024-04-10 19:22:00 -07:00
Mike Ash
b8f29cfda0 [Runtime] Allow disabling/enabling prespecializations library per-process.
Read a list of disabled process names from the prespecializations library, and turn the feature off if the current process matches. Also allow passing process names in environment variables. Processes can be disabled by name using SWIFT_DEBUG_LIB_PRESPECIALIZED_DISABLED_PROCESSES, and a disable can be overridden with SWIFT_DEBUG_LIB_PRESPECIALIZED_ENABLED_PROCESSES.

rdar://126216786
2024-04-10 14:29:19 -04:00
Allan Shortlidge
a7914bba3a Concurrency: Fix a condfail in default AsyncIteratorProtocol.next().
Older compilers that do not enable `OptionalIsolatedParameters` by default must
be able to build the `_Concurrency` module.

Resolves rdar://126215750
2024-04-10 10:43:58 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Kuba (Brecka) Mracek
6e4ccca2db Merge pull request #72817 from kubamracek/embedded-print-on-assert
[embedded] In -assert-config Debug, print errors in assertions, preconditions, fatalErrors
2024-04-10 07:52:02 -07:00
Kuba (Brecka) Mracek
f9ed12d781 Merge pull request #72716 from kubamracek/embedded-build-macos-as-14
[embedded] Build the macOS Embedded Stdlib with a recent deployment target
2024-04-09 19:11:08 -07:00
Tim Kientzle
810792843b Fill in extended existential support for type(of:) and mirror
type(of:) now returns the dynamic type of the contents of
an extended existential (just like it does for a regular existential)

Mirror can now reflect fields of a value stored inside an extended
existential (just like it can with a regular existential).  This
requires type(of:) support, since Mirror internals use that to
determine how to reflect a value.

Resolves rdar://102906195
2024-04-09 17:37:57 -07:00
Kuba Mracek
67f3d34d02 [embedded] Fix fatalError() to produce a trap in Release configurations 2024-04-09 11:36:39 -07:00
Kuba Mracek
309dbe1c1a [embedded] Make fatalError() in embedded Swift only print in non-production builds (-Onone or -assert-config Debug) 2024-04-09 11:36:38 -07:00
Kuba Mracek
757e4e56b0 [embedded] In -assert-config Debug, print errors in assertions, preconditions, fatalErrors 2024-04-09 11:36:21 -07:00
Yuta Saito
ef07102b88 Merge pull request #72891 from kateinoigakukun/yt/fix-wasm-float16 2024-04-10 01:01:58 +09:00
eeckstein
648705e524 Merge pull request #72850 from eeckstein/sensitive
Add the experimental attribute `@sensitive` for struct declarations
2024-04-09 15:46:22 +02:00
Mike Ash
deab2fa5ef Merge pull request #72519 from mikeash/fix-validate-prespecialized-metadata
[Runtime] Fix _swift_validatePrespecializedMetadata when type lookup fails.
2024-04-09 09:14:39 -04:00
Erik Eckstein
ce33d47a4c stdlib: add the swift_clearSensitive runtime function 2024-04-09 12:01:10 +02:00
Saleem Abdulrasool
269565c9dd runtime: add an explicit cast for older C++ runtimes
The older C++ runtime seems to be unhappy with the implicit conversion
of the parameters:

~~~
FAILED: stdlib/public/runtime/CMakeFiles/swiftRuntime-linux-x86_64.dir/Errors.cpp.o
/home/build-user/build/buildbot_incremental_lsan/llvm-linux-x86_64/./bin/clang++ -DCMARK_STATIC_DEFINE -DGTEST_HAS_RTTI=0 -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -DSWIFT_BUILD_SWIFT_SYNTAX -DSWIFT_INLINE_NAMESPACE=__runtime -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_LIBCPP_ENABLE_HARDENED_MODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/build-user/build/buildbot_incremental_lsan/swift-linux-x86_64/stdlib/public/runtime -I/home/build-user/swift/stdlib/public/runtime -I/home/build-user/swift/stdlib/include -I/home/build-user/swift/stdlib/public/SwiftShims -I/home/build-user/build/buildbot_incremental_lsan/swift-linux-x86_64/include -I/home/build-user/swift/include -I/home/build-user/build/buildbot_incremental_lsan/llvm-linux-x86_64/include -I/home/build-user/llvm-project/clang/include -I/home/build-user/build/buildbot_incremental_lsan/llvm-linux-x86_64/tools/clang/include -I/home/build-user/cmark/src/include -I/home/build-user/build/buildbot_incremental_lsan/cmark-linux-x86_64/src -I/home/build-user/swift-corelibs-libdispatch/src/BlocksRuntime -I/home/build-user/swift-corelibs-libdispatch -gline-tables-only -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer -fsanitize=leak -fdiagnostics-color -ffunction-sections -fdata-sections -O2 -DNDEBUG -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -funwind-tables -fno-rtti -Werror=gnu -Werror=c++98-compat-extra-semi -UNDEBUG -Werror=switch -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -Wno-nested-anon-types -fno-sanitize=all -Wall -Wformat-nonliteral -Werror=format-nonliteral -Wglobal-constructors -Werror=global-constructors -Wexit-time-destructors -Werror=exit-time-destructors -DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=1 -DswiftCore_EXPORTS -I/home/build-user/swift/stdlib/include/llvm/Support -I/home/build-user/swift/include -DSWIFT_TARGET_LIBRARY_NAME=swiftRuntime -DSWIFT_RUNTIME -DSWIFT_LIB_SUBDIR="linux" -DSWIFT_ARCH="x86_64" -target x86_64-unknown-linux-gnu -fno-omit-frame-pointer -O0 -g -mcx16 -DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -march=core2 -DSWIFT_OBJC_INTEROP=0 -DSWIFT_LIBRARY_EVOLUTION=1 -DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT -DSWIFT_ENABLE_REFLECTION -DSWIFT_STDLIB_HAS_DLADDR -DSWIFT_STDLIB_HAS_DLSYM=1 -DSWIFT_STDLIB_HAS_FILESYSTEM -DSWIFT_STDLIB_HAS_DARWIN_LIBMALLOC=1 -DSWIFT_STDLIB_HAS_STDIN -DSWIFT_STDLIB_HAS_ENVIRON -DSWIFT_STDLIB_HAS_LOCALE -DSWIFT_THREADING_LINUX -DSWIFT_RUNTIME_OS_VERSIONING -DSWIFT_STDLIB_SHORT_MANGLING_LOOKUPS -DSWIFT_STDLIB_ENABLE_VECTOR_TYPES -DSWIFT_STDLIB_HAS_TYPE_PRINTING -DSWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING -DSWIFT_STDLIB_ENABLE_UNICODE_DATA -DSWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE -std=c++17 -MD -MT stdlib/public/runtime/CMakeFiles/swiftRuntime-linux-x86_64.dir/Errors.cpp.o -MF stdlib/public/runtime/CMakeFiles/swiftRuntime-linux-x86_64.dir/Errors.cpp.o.d -o stdlib/public/runtime/CMakeFiles/swiftRuntime-linux-x86_64.dir/Errors.cpp.o -c /home/build-user/swift/stdlib/public/runtime/Errors.cpp
/home/build-user/swift/stdlib/public/runtime/Errors.cpp:315:13: error: no matching function for call to 'atomic_compare_exchange_strong_explicit'
315 | } while (!std::atomic_compare_exchange_strong_explicit(&kFatalErrorMessage,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../include/c++/7/atomic:1121:5: note: candidate template ignored: deduced conflicting types for parameter '_ITp' ('const char ' vs. 'char ')
1121 | atomic_compare_exchange_strong_explicit(atomic<_ITp> __a,
| ^
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../include/c++/7/atomic:1129:5: note: candidate template ignored: deduced conflicting types for parameter '_ITp' ('const char ' vs. 'char ')
1129 | atomic_compare_exchange_strong_explicit(volatile atomic<_ITp> __a,
| ^
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../include/c++/7/bits/shared_ptr_atomic.h:220:5: note: candidate template ignored: could not match 'shared_ptr' against 'atomic'
220 | atomic_compare_exchange_strong_explicit(shared_ptr<_Tp> __p,
| ^
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../include/c++/7/bits/shared_ptr_atomic.h:272:5: note: candidate template ignored: could not match '__shared_ptr' against 'atomic'
272 | atomic_compare_exchange_strong_explicit(__shared_ptr<_Tp, _Lp> __p,
| ^
1 error generated.
~~~

Use an explicit cast to resolve the ambiguity.
2024-04-08 10:28:31 -07:00
Konrad `ktoso` Malawski
fb4ffb43db [Concurrency] Add missing runSynchronously to ExecutorJob (#72899) 2024-04-08 13:41:08 +09:00