Skip to content

Commit f07ba0b

Browse files
authored
Merge pull request #343 from tayloraswift/searchbot-coverage
support Swift 6.0 on Linux
2 parents c71579c + b270fea commit f07ba0b

26 files changed

+156
-141
lines changed

.github/workflows/docs.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@ jobs:
1616
env:
1717
UNIDOC_ENABLE_INDEXSTORE: "0"
1818
steps:
19-
# Important! We install an Ubuntu 22.04 Swift toolchain, and not the 24.04 one
20-
# because the 24.04 toolchain for some reason is built with assertions enabled,
21-
# which causes the Swift compiler to crash when building the package.
2219
- name: Install Swift
2320
uses: tayloraswift/swift-install-action@master
2421
with:
25-
swift-prefix: "swift-5.10.1-release/ubuntu2204/swift-5.10.1-RELEASE"
26-
swift-id: "swift-5.10.1-RELEASE-ubuntu22.04"
22+
swift-prefix: "swift-6.0-release/ubuntu2404/swift-6.0-RELEASE"
23+
swift-id: "swift-6.0-RELEASE-ubuntu24.04"
2724

2825
# This installs an older version of Unidoc, not the one we are testing.
26+
# We use `--static-swift-stdlib` so it doesn’t matter if the Unidoc binary was
27+
# built with a different version of Swift.
2928
- name: Install Unidoc
3029
uses: tayloraswift/swift-unidoc-action@master
31-
with:
32-
unidoc-version: "master"
3330

3431
- name: Checkout repository
3532
uses: actions/checkout@v3
@@ -46,13 +43,16 @@ jobs:
4643
name: macOS
4744
env:
4845
UNIDOC_ENABLE_INDEXSTORE: "0"
49-
DEVELOPER_DIR: "/Applications/Xcode_15.3.app/Contents/Developer"
5046

5147
steps:
48+
- name: Install Swift 6.0
49+
uses: tayloraswift/swift-install-action@master
50+
with:
51+
swift-prefix: "swift-6.0-release/xcode/swift-6.0-RELEASE"
52+
swift-id: "swift-6.0-RELEASE"
53+
5254
- name: Install Unidoc
5355
uses: tayloraswift/swift-unidoc-action@master
54-
with:
55-
unidoc-version: "master"
5656

5757
- name: Checkout repository
5858
uses: actions/checkout@v3

.github/workflows/package.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ jobs:
1111
macos:
1212
runs-on: macos-14
1313
name: macOS
14-
15-
env:
16-
DEVELOPER_DIR: "/Applications/Xcode_15.3.app/Contents/Developer"
17-
1814
steps:
15+
- name: Install Swift 6.0
16+
uses: tayloraswift/swift-install-action@master
17+
with:
18+
swift-prefix: "swift-6.0-release/xcode/swift-6.0-RELEASE"
19+
swift-id: "swift-6.0-RELEASE"
20+
1921
- name: Checkout repository
2022
uses: actions/checkout@v3
2123

@@ -47,8 +49,8 @@ jobs:
4749
- name: Install Swift
4850
uses: tayloraswift/swift-install-action@master
4951
with:
50-
swift-prefix: "swift-5.10.1-release/ubuntu2404/swift-5.10.1-RELEASE"
51-
swift-id: "swift-5.10.1-RELEASE-ubuntu24.04"
52+
swift-prefix: "swift-6.0-release/ubuntu2404/swift-6.0-RELEASE"
53+
swift-id: "swift-6.0-RELEASE-ubuntu24.04"
5254

5355
# This clobbers everything in the current directory, which is why we installed
5456
# the Swift toolchain in the home directory.

.github/workflows/test.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ on:
1010
jobs:
1111
server:
1212
runs-on: ubuntu-24.04
13-
name: Amazon Linux 2023
14-
15-
strategy:
16-
matrix:
17-
image:
18-
- tayloraswift/5.10.0-amazonlinux2023:latest
19-
13+
name: Linux
2014
steps:
2115
- name: Checkout repository
2216
uses: actions/checkout@v3
@@ -39,17 +33,22 @@ jobs:
3933
--user root \
4034
-v $PWD:/swift/swift-unidoc \
4135
-w /swift/swift-unidoc \
42-
${{ matrix.image }} \
36+
swift:6.0-noble \
4337
/bin/bash .github/pipeline
4438
4539
macos:
4640
runs-on: macos-14
4741
name: macOS
4842
env:
4943
UNIDOC_ENABLE_INDEXSTORE: "1"
50-
DEVELOPER_DIR: "/Applications/Xcode_15.3.app/Contents/Developer"
5144

5245
steps:
46+
- name: Install Swift 6.0
47+
uses: tayloraswift/swift-install-action@master
48+
with:
49+
swift-prefix: "swift-6.0-release/xcode/swift-6.0-RELEASE"
50+
swift-id: "swift-6.0-RELEASE"
51+
5352
- name: Checkout repository
5453
uses: actions/checkout@v3
5554

Package.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"originHash" : "14136142efb275ae01dcfeaf5849d265cd6cab460ea3b046c55ea7ccd4d3ab76",
2+
"originHash" : "1285241c2a78115dc45f201aef02db9d1eeda9a0221d768c13bf21ebf6524a3a",
33
"pins" : [
44
{
55
"identity" : "indexstore-db",

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ Unidoc powers the [Swiftinit](https://swiftinit.org) open source package index!
2121

2222
## Requirements
2323

24-
Unidoc’s principal deployment target is Amazon Linux 2023, but the project also builds on macOS 14 with Xcode 15.3 or newer.
25-
26-
Unidoc requires Swift 5.10.
27-
28-
> Note:
29-
Due to a known [compiler bug](https://github.com/apple/swift/issues/71606), it is not currently possible to build Unidoc on macOS with a non-Xcode toolchain.
24+
Unidoc supports Linux and macOS. Unidoc requires Swift 6.0.
3025

3126

3227
## Features

Sources/SymbolGraphBuilderTests/Main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ enum Main:TestMain, TestBattery
268268
try workspace.build(package: try .remote(
269269
project: "swift-nio-ssl",
270270
from: "https://github.com/apple/swift-nio-ssl.git",
271-
at: "2.24.0",
271+
at: "2.27.2",
272272
in: workspace),
273273
with: toolchain)
274274
})
@@ -343,7 +343,7 @@ enum Main:TestMain, TestBattery
343343
try workspace.build(package: try .remote(
344344
project: "swift-snapshot-testing",
345345
from: "https://github.com/pointfreeco/swift-snapshot-testing.git",
346-
at: "1.17.0",
346+
at: "1.17.5",
347347
in: workspace),
348348
with: toolchain)
349349
})
@@ -369,7 +369,7 @@ enum Main:TestMain, TestBattery
369369
try workspace.build(package: try .remote(
370370
package: "indexstore-db",
371371
from: "https://github.com/apple/indexstore-db.git",
372-
at: "swift-5.10-RELEASE",
372+
at: "swift-6.0-RELEASE",
373373
in: workspace,
374374
flags: .init(cxx: ["-I/usr/lib/swift", "-I/usr/lib/swift/Block"])),
375375
with: toolchain)

Sources/SymbolGraphCompiler/Extensions/SSGC.ExtensionSignatureError.swift

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,34 @@ import Symbols
44

55
extension SSGC
66
{
7-
struct ExtensionSignatureError:Error
7+
enum ExtensionSignatureError:Error
88
{
9-
let expected:ExtensionSignature
10-
let declared:[GenericConstraint<Symbol.Decl>]?
11-
12-
init(expected:ExtensionSignature,
13-
declared:[GenericConstraint<Symbol.Decl>]? = nil)
14-
{
15-
self.expected = expected
16-
self.declared = declared
17-
}
9+
case conformance(expected:ExtensionSignature, declared:[GenericConstraint<Symbol.Decl>])
10+
case member (expected:ExtensionSignature, declared:[GenericConstraint<Symbol.Decl>])
1811
}
1912
}
2013
extension SSGC.ExtensionSignatureError:CustomStringConvertible
2114
{
2215
var description:String
2316
{
24-
if let _:[GenericConstraint<Symbol.Decl>] = self.declared
17+
switch self
2518
{
19+
case .conformance(expected: let expected, declared: let declared):
2620
"""
27-
Cannot declare an extension (of \(self.expected.extendee)) containing \
28-
a symbol with different extension constraints than its extension block.
29-
"""
30-
}
31-
else
32-
{
33-
"""
34-
Cannot declare an extension (of \(self.expected.extendee)) containing \
21+
Cannot declare an extension (of \(expected.extendee)) containing \
3522
a relationship with different extension constraints than its extension \
3623
block.
24+
25+
Extension block: \(expected.conditions.humanReadable)
26+
Relationship: \(declared.humanReadable)
27+
"""
28+
case .member(expected: let expected, declared: let declared):
29+
"""
30+
Cannot declare an extension (of \(expected.extendee)) containing \
31+
a symbol with different extension constraints than its extension block!
32+
33+
Extension block: \(expected.conditions.humanReadable)
34+
Extension member: \(declared.humanReadable)
3735
"""
3836
}
3937
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Signatures
2+
3+
extension GenericOperator
4+
{
5+
var token:String
6+
{
7+
switch self
8+
{
9+
case .conformer: ":"
10+
case .subclass: ":"
11+
case .equal: "=="
12+
}
13+
}
14+
}

Sources/SymbolGraphCompiler/SSGC.SymbolDump.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ extension SSGC.SymbolDump
104104
}
105105
// Trim file path prefixes.
106106
guard
107-
let base:Symbol.FileBase = base
107+
let base:Symbol.FileBase = copy base
108108
else
109109
{
110110
$0.location = nil

Sources/SymbolGraphCompiler/SSGC.TypeChecker.swift

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ extension SSGC.TypeChecker
311311
{
312312
// The member’s extension constraints don’t match the extension
313313
// object’s signature!
314-
throw SSGC.ExtensionSignatureError.init(expected: group.signature,
314+
throw SSGC.ExtensionSignatureError.member(
315+
expected: group.signature,
315316
declared: member.conditions.sorted())
316317
}
317318

@@ -379,10 +380,14 @@ extension SSGC.TypeChecker
379380

380381
conformer = type
381382

382-
guard named.conditions == conditions
383+
// This assertion disabled due to Apple Swift bug:
384+
// https://github.com/swiftlang/swift/issues/76559
385+
guard named.conditions == conditions || { true }()
383386
else
384387
{
385-
throw SSGC.ExtensionSignatureError.init(expected: named.signature)
388+
throw SSGC.ExtensionSignatureError.conformance(
389+
expected: named.signature,
390+
declared: conformance.conditions)
386391
}
387392
}
388393

@@ -429,19 +434,19 @@ extension SSGC.TypeChecker
429434
(\(target)) of '\(type.value.path)' because multiple conflicting \
430435
conformances unify to a heterogeneous set of constraints
431436
432-
Declared constraints: \(lists)
433-
Simplified constraints: \(reduced)
437+
Declared constraints: \(lists.map(\.humanReadable))
438+
Simplified constraints: \(reduced.humanReadable)
434439
""")
435440
}
436441
catch SSGC.ConstraintReductionError.redundant(let reduced, from: let lists)
437442
{
438443
throw AssertionError.init(message: """
439444
Failed to simplify constraints for conditional conformance \
440-
(\(target)) of '\(type.value.path)' because at least one of the \
441-
constraint lists had redundancies within itself
445+
(\(target)) of '\(type.value.path)' due to multiple conflicting conditional
446+
conformances parsed from Swift compiler output
442447
443-
Declared constraints: \(lists)
444-
Simplified constraints: \(reduced)
448+
Declared constraints: \(lists.map(\.humanReadable))
449+
Simplified constraints: \(reduced.humanReadable)
445450
""")
446451
}
447452
}
@@ -470,10 +475,30 @@ extension SSGC.TypeChecker
470475
return
471476
}
472477

473-
let canonical:Set<GenericConstraint<Symbol.Decl>> = try self.computeConformance(
474-
where: overlapping,
475-
to: target,
476-
of: type)
478+
let canonical:Set<GenericConstraint<Symbol.Decl>>
479+
do
480+
{
481+
canonical = try self.computeConformance(where: overlapping,
482+
to: target,
483+
of: type)
484+
}
485+
catch let error
486+
{
487+
switch target
488+
{
489+
case "ss9EscapableP": print(error)
490+
case "ss8CopyableP": print(error)
491+
case "s11CoreMetrics06_SwiftB16SendableProtocolP": print(error)
492+
default: throw error
493+
}
494+
495+
print("""
496+
Note: recovering from error due to known Apple Swift bug
497+
https://github.com/swiftlang/swift/issues/76499
498+
499+
""")
500+
return
501+
}
477502

478503
// Generate an implicit, internal extension for this conformance,
479504
// if one does not already exist.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Signatures
2+
import Symbols
3+
4+
extension Sequence<GenericConstraint<Symbol.Decl>>
5+
{
6+
var humanReadable:String
7+
{
8+
var string:String = ""
9+
for clause:GenericConstraint<Symbol.Decl> in self
10+
{
11+
if !string.isEmpty
12+
{
13+
string += ", "
14+
}
15+
16+
switch clause
17+
{
18+
case .where(let parameter, is: let what, to: let type):
19+
string += "\(parameter) \(what.token) \(type.spelling)"
20+
}
21+
}
22+
return string
23+
}
24+
}

Sources/Symbols/Identifiers/Symbol.Decl.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ extension Symbol.Decl
4343
/// mangled suffix, returning nil if the suffix contains characters
4444
/// that are not allowed to appear in a symbol identifier.
4545
///
46-
/// Valid characters are `_`, `[A-Z]`, `[a-z]`, `[0-9]`, '(', ')', ':', '.', '-', and `@`.
46+
/// Valid characters are `_`, `[A-Z]`, `[a-z]`, `[0-9]`, '(', ')', '*', ':', '.', '-', `@`,
47+
/// `#`, and `$`.
4748
@inlinable public
4849
init?(_ language:Language, _ suffix:some StringProtocol)
4950
{
@@ -55,13 +56,15 @@ extension Symbol.Decl
5556
{
5657
switch Unicode.Scalar.init(ascii)
5758
{
59+
case "#": continue
5860
case "$": continue
5961
case "-": continue
6062
case ":": continue
6163
case ".": continue
6264
case "_": continue
6365
case "(": continue
6466
case ")": continue
67+
case "*": continue
6568
case "0" ... "9": continue
6669
case "@": continue
6770
case "A" ... "Z": continue

Sources/UnidocQueries/Packages/Unidoc.AliasResolutionQuery.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import BSON
2+
import MongoDB
23
import MongoQL
34
import UnidocDB
45
import UnidocRecords
@@ -19,12 +20,9 @@ extension Unidoc
1920
}
2021
}
2122
}
22-
extension Unidoc.AliasResolutionQuery:Mongo.PipelineQuery
23-
{
24-
typealias Iteration = Mongo.Single<Targets.Element>
25-
}
2623
extension Unidoc.AliasResolutionQuery:Unidoc.AliasingQuery
2724
{
25+
typealias Iteration = Mongo.Single<Targets.Element>
2826
typealias CollectionOrigin = Aliases
2927
typealias CollectionTarget = Targets
3028

0 commit comments

Comments
 (0)