Skip to content

Commit 7af6775

Browse files
Merge pull request #4479 from swiftwasm/main
[pull] swiftwasm from main
2 parents c357105 + 58a2ed1 commit 7af6775

File tree

117 files changed

+1113
-1146
lines changed

Some content is hidden

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

117 files changed

+1113
-1146
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1.
16+
2.
17+
...
18+
19+
**Expected behavior**
20+
A clear and concise description of what you expected to happen.
21+
22+
**Screenshots**
23+
If applicable, add screenshots to help explain your problem.
24+
25+
**Environment (please complete the following information):**
26+
- OS: [e.g. macOS 11.0]
27+
- Xcode Version/Tag/Branch:
28+
29+
30+
**Additional context**
31+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: New Feature
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

SwiftCompilerSources/CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ if (NOT BOOTSTRAPPING_MODE)
182182
add_library(swiftCompilerModules ALIAS swiftCompilerStub)
183183

184184
else()
185-
# Note: "Swift" is not added intentinally here, because it would break
185+
# Note: "Swift" is not added intentionally here, because it would break
186186
# the bootstrapping build in case no swift toolchain is installed on the host.
187187
project(SwiftInTheCompiler LANGUAGES C CXX)
188188

@@ -251,3 +251,23 @@ else()
251251

252252
endif()
253253

254+
# Configure 'SwiftCompilerModules' SwiftPM package. The 'Package.swift' will
255+
# be created at '${build_dir}/SwiftCompilerSources/Package.swift' and can be
256+
# built with 'swift-build'.
257+
# Note that this SwiftPM package itself is just for development purposes, and
258+
# is not actually used for the compiler building.
259+
set(swiftcompiler_source_dir_name "_Sources")
260+
configure_file(Package.swift.in
261+
"${CMAKE_CURRENT_BINARY_DIR}/Package.swift" @ONLY)
262+
# SwiftPM requires all sources are inside the directory of 'Package.swift'.
263+
# Create symlinks to the actual source directories.
264+
execute_process(COMMAND
265+
"${CMAKE_COMMAND}" -E create_symlink
266+
"${CMAKE_CURRENT_SOURCE_DIR}/Sources"
267+
"${CMAKE_CURRENT_BINARY_DIR}/${swiftcompiler_source_dir_name}")
268+
if(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER)
269+
execute_process(COMMAND
270+
"${CMAKE_COMMAND}" -E create_symlink
271+
"${EXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR}/Sources/_RegexParser"
272+
"${CMAKE_CURRENT_BINARY_DIR}/_RegexParser_Sources")
273+
endif()

SwiftCompilerSources/Package.swift

Lines changed: 0 additions & 51 deletions
This file was deleted.

SwiftCompilerSources/Package.swift.in

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// swift-tools-version:5.3
2+
//===--- Package.swift.in - SwiftCompiler SwiftPM package -----------------===//
3+
//
4+
// This source file is part of the Swift.org open source project
5+
//
6+
// Copyright (c) 2021 - 2022 Apple Inc. and the Swift project authors
7+
// Licensed under Apache License v2.0 with Runtime Library Exception
8+
//
9+
// See https://swift.org/LICENSE.txt for license information
10+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
// NOTE: This 'Package.swift.in' file is for CMake configure_file().
15+
// Generated 'Package.swift' can be found in
16+
// '${swift_build_dir}/SwiftCompilerSources/Package.swift'.
17+
18+
import PackageDescription
19+
20+
private extension Target {
21+
static let defaultSwiftSettings: [SwiftSetting] = [
22+
.unsafeFlags([
23+
"-Xfrontend", "-validate-tbd-against-ir=none",
24+
"-Xfrontend", "-enable-cxx-interop",
25+
// Bridging modules and headers
26+
"-Xcc", "-I", "-Xcc", "@SWIFT_SOURCE_DIR@/include",
27+
// Generated C headers
28+
"-Xcc", "-I", "-Xcc", "@CMAKE_BINARY_DIR@/include",
29+
"-cross-module-optimization"
30+
]),
31+
]
32+
33+
static func compilerModuleTarget(
34+
name: String,
35+
dependencies: [Dependency],
36+
path: String? = nil,
37+
sources: [String]? = nil,
38+
swiftSettings: [SwiftSetting] = []) -> Target {
39+
.target(
40+
name: name,
41+
dependencies: dependencies,
42+
path: path ?? "@swiftcompiler_source_dir_name@/\(name)",
43+
exclude: ["CMakeLists.txt"],
44+
sources: sources,
45+
swiftSettings: defaultSwiftSettings + swiftSettings)
46+
}
47+
}
48+
49+
let package = Package(
50+
name: "SwiftCompilerSources",
51+
platforms: [
52+
.macOS("10.9"),
53+
],
54+
products: [
55+
.library(
56+
name: "swiftCompilerModules",
57+
type: .static,
58+
targets: ["Basic", "AST", "Parse", "SIL", "Optimizer", "_CompilerRegexParser"]),
59+
],
60+
dependencies: [
61+
],
62+
// Note that targets and their dependencies must align with
63+
// 'SwiftCompilerSources/Sources/CMakeLists.txt'
64+
targets: [
65+
.compilerModuleTarget(
66+
name: "_CompilerRegexParser",
67+
dependencies: [],
68+
path: "_RegexParser_Sources",
69+
swiftSettings: [
70+
// Workaround until `_CompilerRegexParser` is imported as implementation-only
71+
// by `_StringProcessing`.
72+
.unsafeFlags([
73+
"-Xfrontend",
74+
"-disable-implicit-string-processing-module-import"
75+
])]),
76+
.compilerModuleTarget(
77+
name: "Basic",
78+
dependencies: []),
79+
.compilerModuleTarget(
80+
name: "AST",
81+
dependencies: ["Basic"]),
82+
.compilerModuleTarget(
83+
name: "Parse",
84+
dependencies: ["Basic", "AST", "_CompilerRegexParser"]),
85+
.compilerModuleTarget(
86+
name: "SIL",
87+
dependencies: ["Basic"]),
88+
.compilerModuleTarget(
89+
name: "Optimizer",
90+
dependencies: ["Basic", "SIL", "Parse"]),
91+
]
92+
)

SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public struct DiagnosticEngine {
6767
public init(bridged: BridgedDiagnosticEngine) {
6868
self.bridged = bridged
6969
}
70+
public init?(bridged: BridgedOptionalDiagnosticEngine) {
71+
guard let object = bridged.object else {
72+
return nil
73+
}
74+
self.bridged = BridgedDiagnosticEngine(object: object)
75+
}
7076

7177
public func diagnose(_ position: SourceLoc?,
7278
_ id: DiagID,

SwiftCompilerSources/Sources/Basic/SourceLoc.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public struct SourceLoc {
3333
}
3434
}
3535

36+
extension SourceLoc {
37+
public func advanced(by n: Int) -> SourceLoc {
38+
SourceLoc(locationInFile: locationInFile.advanced(by: n))!
39+
}
40+
}
41+
3642
extension Optional where Wrapped == SourceLoc {
3743
public var bridged: BridgedSourceLoc {
3844
self?.bridged ?? .init(pointer: nil)

SwiftCompilerSources/Sources/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
# NOTE: Subdirectories must be added in dependency order.
1010

11-
add_subdirectory(Basic)
12-
add_subdirectory(AST)
1311
if(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER)
1412
add_subdirectory(_RegexParser)
1513
endif()
14+
add_subdirectory(Basic)
15+
add_subdirectory(AST)
16+
add_subdirectory(Parse)
1617
add_subdirectory(SIL)
1718
add_subdirectory(Optimizer)

SwiftCompilerSources/Sources/Optimizer/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
set(dependencies)
10-
list(APPEND dependencies Basic SIL)
11-
if(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER)
12-
list(APPEND dependencies _CompilerRegexParser)
13-
endif()
10+
list(APPEND dependencies Basic SIL Parse)
1411

1512
add_swift_compiler_module(Optimizer DEPENDS ${dependencies})
1613

SwiftCompilerSources/Sources/Optimizer/InstructionPasses/SimplifyStrongRetainRelease.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ private func isNotReferenceCounted(value: Value, context: PassContext) -> Bool {
7878
return isNotReferenceCounted(value: urc.operand, context: context)
7979
case let gvi as GlobalValueInst:
8080
// Since Swift 5.1, statically allocated objects have "immortal" reference
81-
// counts. Therefore we can safely eliminate unbalaced retains and
81+
// counts. Therefore we can safely eliminate unbalanced retains and
8282
// releases, because they are no-ops on immortal objects.
8383
// Note that the `simplifyGlobalValuePass` pass is deleting balanced
8484
// retains/releases, which doesn't require a Swift 5.1 minimum deployment
85-
// targert.
85+
// target.
8686
return gvi.function.isSwift51RuntimeAvailable
8787
case let rptr as RawPointerToRefInst:
8888
// Like `global_value` but for the empty collection singletons from the

0 commit comments

Comments
 (0)