Skip to content

Commit 6c02aa9

Browse files
Merge pull request #4661 from swiftwasm/main
[pull] swiftwasm from main
2 parents 63bf579 + ed88700 commit 6c02aa9

File tree

65 files changed

+3755
-316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3755
-316
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,18 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
488488
the result type provides a generalization where the callee chooses the
489489
resulting type and value.
490490

491+
* The compiler now correctly emits errors for `@available` attributes on stored properties with the `lazy` modifier or with attached property wrappers. Previously, the attribute was accepted on this subset of stored properties but the resulting binary would crash at runtime when type metadata was unavailable.
492+
493+
```swift
494+
struct S {
495+
@available(macOS 99, *) // error: stored properties cannot be marked potentially unavailable with '@available'
496+
lazy var a: Int = 42
497+
498+
@available(macOS 99, *) // error: stored properties cannot be marked potentially unavailable with '@available'
499+
@Wrapper var b: Int
500+
}
501+
```
502+
491503
* The compiler now correctly emits warnings for more kinds of expressions where a protocol conformance is used and may be unavailable at runtime. Previously, member reference expressions and type erasing expressions that used potentially unavailable conformances were not diagnosed, leading to potential crashes at runtime.
492504

493505
```swift

SwiftCompilerSources/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ function(add_swift_compiler_modules_library name)
168168
"-emit-module-path" "${build_dir}/${module}.swiftmodule"
169169
"-parse-as-library" ${sources}
170170
"-wmo" ${swift_compile_options}
171+
# LLVM modules and headers.
172+
"-Xcc" "-I" "-Xcc" "${LLVM_MAIN_INCLUDE_DIR}"
173+
# Generated LLVM headers.
174+
"-Xcc" "-I" "-Xcc" "${LLVM_INCLUDE_DIR}"
171175
# Bridging modules and headers.
172176
"-Xcc" "-I" "-Xcc" "${SWIFT_SOURCE_DIR}/include"
173177
# Generated C headers.

SwiftCompilerSources/Package.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ private extension Target {
2020
"-Xfrontend", "-enable-experimental-cxx-interop",
2121
// Bridging modules and headers
2222
"-Xcc", "-I", "-Xcc", "../include",
23+
// LLVM modules and headers
24+
"-Xcc", "-I", "-Xcc", "../../llvm-project/llvm/include",
2325
"-cross-module-optimization"
2426
]),
2527
]

SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public struct DiagnosticEngine {
8080
highlight: CharSourceRange? = nil,
8181
fixIts: [DiagnosticFixIt] = []) {
8282

83-
let bridgedSourceLoc: BridgedSourceLoc = position.bridged
83+
let bridgedSourceLoc: swift.SourceLoc = position.bridged
8484
let bridgedHighlightRange: BridgedCharSourceRange = highlight.bridged
8585
var bridgedArgs: [BridgedDiagnosticArgument] = []
8686
var bridgedFixIts: [BridgedDiagnosticFixIt] = []

SwiftCompilerSources/Sources/Basic/SourceLoc.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public struct SourceLoc {
2121
self.locationInFile = locationInFile
2222
}
2323

24-
public init?(bridged: BridgedSourceLoc) {
25-
guard let locationInFile = bridged.pointer else {
24+
public init?(bridged: swift.SourceLoc) {
25+
guard bridged.isValid() else {
2626
return nil
2727
}
28-
self.init(locationInFile: locationInFile)
28+
self.locationInFile = bridged.getOpaquePointerValue().assumingMemoryBound(to: UInt8.self)
2929
}
3030

31-
public var bridged: BridgedSourceLoc {
32-
.init(pointer: locationInFile)
31+
public var bridged: swift.SourceLoc {
32+
.init(llvm.SMLoc.getFromPointer(locationInFile))
3333
}
3434
}
3535

@@ -40,8 +40,8 @@ extension SourceLoc {
4040
}
4141

4242
extension Optional where Wrapped == SourceLoc {
43-
public var bridged: BridgedSourceLoc {
44-
self?.bridged ?? .init(pointer: nil)
43+
public var bridged: swift.SourceLoc {
44+
self?.bridged ?? .init()
4545
}
4646
}
4747

@@ -68,6 +68,6 @@ public struct CharSourceRange {
6868

6969
extension Optional where Wrapped == CharSourceRange {
7070
public var bridged: BridgedCharSourceRange {
71-
self?.bridged ?? .init(start: .init(pointer: nil), byteLength: 0)
71+
self?.bridged ?? .init(start: .init(), byteLength: 0)
7272
}
7373
}

SwiftCompilerSources/Sources/Parse/Regex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public func _RegexLiteralParsingFn(
9292
_ versionOut: UnsafeMutablePointer<CUnsignedInt>,
9393
_ captureStructureOut: UnsafeMutableRawPointer,
9494
_ captureStructureSize: CUnsignedInt,
95-
_ bridgedDiagnosticBaseLoc: BridgedSourceLoc,
95+
_ bridgedDiagnosticBaseLoc: swift.SourceLoc,
9696
_ bridgedDiagnosticEngine: BridgedDiagnosticEngine
9797
) -> Bool {
9898
let str = String(cString: inputPtr)

docs/DevelopmentTips.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,25 @@ Copy the invocation that has ` -o <build-path>/swift-macosx-x86_64/stdlib/publi
2323
### Choosing the bootstrapping mode
2424
By default, the compiler builds with the `boostrapping-with-hostlibs` (macOS) or `bootstrapping` (Linux) bootstrapping mode. To speed up local development it's recommended to build with the `hosttools` mode: `utils/build-script --bootstrapping=hosttools`.
2525

26-
It requires a recently new swift toolchain to be installed on your build machine. On macOS this comes with your Xcode installation.
26+
It requires a recently new swift toolchain to be installed on your build machine. You might need to download and install a nightly Swift toolchain to build the Swift project in `hosttools` mode.
2727

2828
Not that changing the bootstrapping mode needs a reconfiguration.
2929

30+
#### Using a locally built Swift toolchain
31+
32+
If you do not want to install a nightly Swift toolchain, or you need to debug Swift code within SwiftCompilerSources, you can build the Swift toolchain in `boostrapping-with-hostlibs` mode on your local machine once, and then use this toolchain to iterate on your changes with the `hosttools` mode:
33+
34+
* Build the toolchain locally in `boostrapping-with-hostlibs` mode: `./utils/build-toolchain com.yourname`.
35+
* Copy the `swift-LOCAL-YYYY-MM-DD.xctoolchain` file from `./swift-nightly-install/Library/Developer/Toolchains` to `/Library/Developer/Toolchains`.
36+
* Launch Xcode, in the menu bar select _Xcode_ > _Toolchains_ > _Local Swift Development Snapshot YYYY-MM-DD_.
37+
* Remove the Swift build directory: `./build`.
38+
* Run the Swift build script with the locally built Swift toolchain in `hosttools` mode: `TOOLCHAINS=com.yourname.YYYYMMDD ./utils/build-script --bootstrapping=hosttools`. Repeat this step as you iterate on your change.
39+
40+
To debug using LLDB, run LLDB from the locally built toolchain with a couple of environment variables set:
41+
```
42+
DYLD_LIBRARY_PATH=/Library/Developer/Toolchains/swift-LOCAL-YYYY-MM-DD.xctoolchain/usr/lib/swift/macosx DYLD_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Library/Frameworks /Library/Developer/Toolchains/swift-LOCAL-YYYY-MM-DD.xctoolchain/usr/bin/lldb
43+
```
44+
3045
### Working with two build directories
3146
For developing and debugging you are probably building a debug configuration of swift. But it's often beneficial to also build a release-assert configuration in parallel (`utils/build-script -R`).
3247

include/swift/AST/ASTBridging.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
#include <stdbool.h>
1919
#include <stddef.h>
2020

21-
#ifdef __cplusplus
22-
extern "C" {
23-
#endif
24-
2521
SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
2622

2723
//===----------------------------------------------------------------------===//
@@ -56,7 +52,7 @@ typedef struct {
5652
} BridgedDiagnosticArgument;
5753

5854
typedef struct {
59-
BridgedSourceLoc start;
55+
swift::SourceLoc start;
6056
SwiftInt byteLength;
6157
BridgedStringRef text;
6258
} BridgedDiagnosticFixIt;
@@ -70,7 +66,7 @@ typedef struct {
7066
} BridgedOptionalDiagnosticEngine;
7167

7268
// FIXME: Can we bridge InFlightDiagnostic?
73-
void DiagnosticEngine_diagnose(BridgedDiagnosticEngine, BridgedSourceLoc loc,
69+
void DiagnosticEngine_diagnose(BridgedDiagnosticEngine, swift::SourceLoc loc,
7470
BridgedDiagID diagID, BridgedArrayRef arguments,
7571
BridgedCharSourceRange highlight,
7672
BridgedArrayRef fixIts);
@@ -79,8 +75,4 @@ bool DiagnosticEngine_hadAnyError(BridgedDiagnosticEngine);
7975

8076
SWIFT_END_NULLABILITY_ANNOTATIONS
8177

82-
#ifdef __cplusplus
83-
} // extern "C"
84-
#endif
85-
8678
#endif // SWIFT_AST_ASTBRIDGING_H

include/swift/AST/Decl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6414,9 +6414,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
64146414
/// A function is concurrent if it has the @Sendable attribute.
64156415
bool isSendable() const;
64166416

6417-
/// Determine if function has 'nonisolated' attribute
6418-
bool isNonisolated() const;
6419-
64206417
/// Returns true if the function is a suitable 'async' context.
64216418
///
64226419
/// Functions that are an 'async' context can make calls to 'async' functions.

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4495,8 +4495,8 @@ ERROR(actor_inheritance,none,
44954495
(bool))
44964496

44974497
ERROR(actor_protocol_illegal_inheritance,none,
4498-
"non-actor type %0 cannot conform to the 'Actor' protocol",
4499-
(DeclName))
4498+
"non-actor type %0 cannot conform to the %1 protocol",
4499+
(DeclName, DeclName))
45004500
ERROR(distributed_actor_conformance_missing_system_type,none,
45014501
"distributed actor %0 does not declare ActorSystem it can be used with.",
45024502
(DeclName))

0 commit comments

Comments
 (0)