Skip to content

Commit cf23c8b

Browse files
authored
Merge pull request #324 from tayloraswift/noassert-extensions
Turn off extension block symbols
2 parents c389168 + 92b3b4a commit cf23c8b

File tree

9 files changed

+47
-116
lines changed

9 files changed

+47
-116
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
branches: [ master ]
1010

1111
jobs:
12-
linux:
13-
runs-on: ubuntu-22.04
12+
server:
13+
runs-on: ubuntu-24.04
1414
name: Amazon Linux 2023
1515

1616
strategy:

.github/workflows/package.yml

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,12 @@ jobs:
4343
linux:
4444
runs-on: ubuntu-24.04
4545
name: Ubuntu 24.04
46-
47-
env:
48-
SWIFT_PREFIX: "swift-5.10.1-release/ubuntu2404/swift-5.10.1-RELEASE"
49-
SWIFT_ID: "swift-5.10.1-RELEASE-ubuntu24.04"
50-
5146
steps:
52-
- name: Cache Swift toolchain
53-
uses: actions/cache@v2
54-
with:
55-
path: ${{ env.SWIFT_ID }}.tar.gz
56-
key: ${{ env.SWIFT_ID }}
57-
58-
- name: Cache status
59-
id: cache_status
60-
uses: andstor/file-existence-action@v1
47+
- name: Install Swift
48+
uses: tayloraswift/swift-install-action@master
6149
with:
62-
files: ${{ env.SWIFT_ID }}.tar.gz
63-
64-
- name: Download Swift
65-
if: steps.cache_status.outputs.files_exists == 'false'
66-
run: |
67-
curl https://download.swift.org/$SWIFT_PREFIX/$SWIFT_ID.tar.gz \
68-
--output $SWIFT_ID.tar.gz
69-
70-
- name: Set up Swift
71-
run: |
72-
mkdir -p $HOME/$SWIFT_ID
73-
tar -xzf $SWIFT_ID.tar.gz -C $HOME/$SWIFT_ID --strip 1
74-
echo "$HOME/$SWIFT_ID/usr/bin" >> $GITHUB_PATH
75-
cat $GITHUB_PATH
50+
swift-prefix: "swift-5.10.1-release/ubuntu2404/swift-5.10.1-RELEASE"
51+
swift-id: "swift-5.10.1-RELEASE-ubuntu24.04"
7652

7753
# This clobbers everything in the current directory, which is why we installed
7854
# the Swift toolchain in the home directory.
@@ -89,13 +65,13 @@ jobs:
8965
swift build -c release \
9066
--static-swift-stdlib \
9167
--product unidoc-publish \
92-
-Xcxx -I$HOME/$SWIFT_ID/usr/lib/swift \
93-
-Xcxx -I$HOME/$SWIFT_ID/usr/lib/swift/Block
68+
-Xcxx -I$SWIFT_INSTALLATION/lib/swift \
69+
-Xcxx -I$SWIFT_INSTALLATION/lib/swift/Block
9470
swift build -c release \
9571
--static-swift-stdlib \
9672
--product unidoc-tools \
97-
-Xcxx -I$HOME/$SWIFT_ID/usr/lib/swift \
98-
-Xcxx -I$HOME/$SWIFT_ID/usr/lib/swift/Block
73+
-Xcxx -I$SWIFT_INSTALLATION/lib/swift \
74+
-Xcxx -I$SWIFT_INSTALLATION/lib/swift/Block
9975
10076
- name: Upload products
10177
env:

Sources/SymbolGraphBuilder/Builds/SSGC.PackageBuild.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ extension SSGC.PackageBuild
302302
{
303303
try toolchain.build(package: self.root,
304304
using: self.scratch,
305-
flags: self.flags.dumping(symbols: .default, to: artifacts))
305+
flags: self.flags.dumping(symbols: .init(), to: artifacts))
306306
}
307307
catch SystemProcessError.exit(let code, let invocation)
308308
{
@@ -331,14 +331,13 @@ extension SSGC.PackageBuild
331331
// Dump the standard library’s symbols, unless they’re already cached.
332332
let artifactsCached:FilePath.Directory = try toolchain.dump(
333333
standardLibrary: .init(platform: platform),
334-
options: .default,
335334
cache: cache)
336335
for (module, include):(Symbol.Module, [FilePath.Directory]) in try self.modulesToDump(
337336
among: modules)
338337
{
339338
try toolchain.dump(module: module,
340339
to: artifacts,
341-
options: .default,
340+
options: .init(),
342341
include: include)
343342
}
344343

Sources/SymbolGraphBuilder/Standard library/SSGC.StandardLibraryBuild.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ extension SSGC.StandardLibraryBuild:SSGC.DocumentationBuild
2727
let standardLibrary:SSGC.StandardLibrary = .init(platform: try toolchain.platform())
2828

2929
let artifacts:FilePath.Directory = try toolchain.dump(standardLibrary: standardLibrary,
30-
options: .default,
3130
cache: cache)
3231

3332
let metadata:SymbolGraphMetadata = .swift(toolchain.splash.swift,

Sources/SymbolGraphBuilder/Toolchains/SSGC.Toolchain.SymbolDumpOptions.swift

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ extension SSGC.Toolchain
99
var includeInterfaceSymbols:Bool
1010
var skipInheritedDocs:Bool
1111

12-
init(minimumACL:Symbol.ACL,
13-
emitExtensionBlockSymbols:Bool,
14-
includeInterfaceSymbols:Bool,
15-
skipInheritedDocs:Bool)
12+
init(minimumACL:Symbol.ACL = .internal,
13+
emitExtensionBlockSymbols:Bool = true,
14+
includeInterfaceSymbols:Bool = true,
15+
skipInheritedDocs:Bool = true)
1616
{
1717
self.minimumACL = minimumACL
1818
self.emitExtensionBlockSymbols = emitExtensionBlockSymbols
@@ -21,14 +21,3 @@ extension SSGC.Toolchain
2121
}
2222
}
2323
}
24-
extension SSGC.Toolchain.SymbolDumpOptions
25-
{
26-
static
27-
var `default`:Self
28-
{
29-
.init(minimumACL: .internal,
30-
emitExtensionBlockSymbols: true,
31-
includeInterfaceSymbols: true,
32-
skipInheritedDocs: true)
33-
}
34-
}

Sources/SymbolGraphBuilder/Toolchains/SSGC.Toolchain.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,10 @@ extension SSGC.Toolchain
208208
}
209209
extension SSGC.Toolchain
210210
{
211+
/// Dumps the symbols for the standard library. Due to upstream bugs in the Swift compiler,
212+
/// this methods disables extension block symbols by default.
211213
func dump(standardLibrary:SSGC.StandardLibrary,
212-
options:SymbolDumpOptions = .default,
214+
options:SymbolDumpOptions = .init(emitExtensionBlockSymbols: false),
213215
cache:FilePath.Directory) throws -> FilePath.Directory
214216
{
215217
let cached:FilePath.Directory = cache / "swift@\(self.splash.swift.version)"
@@ -234,7 +236,7 @@ extension SSGC.Toolchain
234236
/// output directory.
235237
func dump(module id:Symbol.Module,
236238
to output:FilePath.Directory,
237-
options:SymbolDumpOptions = .default,
239+
options:SymbolDumpOptions,
238240
include:[FilePath.Directory] = []) throws
239241
{
240242
print("Dumping symbols for module '\(id)'")

Sources/SymbolGraphCompiler/Extensions/SSGC.Extensions.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ extension SSGC
2424
}
2525
}
2626
extension SSGC.Extensions
27+
{
28+
var all:Dictionary<SSGC.ExtensionSignature, SSGC.ExtensionObject>.Values
29+
{
30+
self.groups.values
31+
}
32+
}
33+
extension SSGC.Extensions
2734
{
2835
mutating
2936
func include(_ vertex:SymbolGraphPart.Vertex,
@@ -114,7 +121,7 @@ extension SSGC.Extensions
114121
/// Gather extension members attributable to the specified culture, simplifying the
115122
/// extension signatures by inspecting the extended declaration. This may coalesce
116123
/// multiple extension objects into a single extension layer.
117-
let coalesced:[SSGC.Extension.ID: SSGC.ExtensionLayer] = try self.groups.values.reduce(
124+
let coalesced:[SSGC.Extension.ID: SSGC.ExtensionLayer] = try self.all.reduce(
118125
into: [:])
119126
{
120127
let blocks:[(id:Symbol.Block, block:SSGC.Extension.Block)] = $1.blocks.reduce(

Sources/SymbolGraphCompiler/SSGC.TypeChecker.swift

Lines changed: 18 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ extension SSGC
1010
public
1111
struct TypeChecker
1212
{
13-
private
14-
let ignoreExportedInterfaces:Bool
1513
private
1614
var declarations:Declarations
1715
private
@@ -23,9 +21,8 @@ extension SSGC
2321
var resolvableModules:[Symbol.Module]
2422

2523
public
26-
init(ignoreExportedInterfaces:Bool = true, threshold:Symbol.ACL = .public)
24+
init(threshold:Symbol.ACL = .public)
2725
{
28-
self.ignoreExportedInterfaces = ignoreExportedInterfaces
2926
self.declarations = .init(threshold: threshold)
3027
self.extensions = .init()
3128

@@ -258,41 +255,20 @@ extension SSGC.TypeChecker
258255
return
259256
}
260257

261-
guard self.ignoreExportedInterfaces || member.culture == culture
262-
else
263-
{
264-
throw AssertionError.init(message: """
265-
Found cross-module member relationship \
266-
(from \(member.culture) in \(culture)), which should not be possible in \
267-
symbol dumps generated with '-emit-extension-symbols'
268-
""")
269-
}
270-
271258
switch relationship.target
272259
{
273260
case .vector(let symbol):
274261
// Nothing can be a member of a vector symbol.
275262
throw SSGC.UnexpectedSymbolError.vector(symbol)
276263

277264
case .scalar(let scope):
278-
// We should never see an external type reference here either.
279265
guard
280266
let scope:SSGC.DeclObject = self.declarations[visible: scope]
281267
else
282268
{
283269
return
284270
}
285271

286-
guard self.ignoreExportedInterfaces || scope.culture == culture
287-
else
288-
{
289-
throw AssertionError.init(message: """
290-
Found cross-module member relationship \
291-
(to \(scope.culture) in \(culture)), which should not be possible in \
292-
symbol dumps generated with '-emit-extension-symbols'
293-
""")
294-
}
295-
296272
// Enum cases are considered intrinsic members of their parent enum.
297273
if case .case = member.value.phylum
298274
{
@@ -358,16 +334,6 @@ extension SSGC.TypeChecker
358334
return
359335
}
360336

361-
guard self.ignoreExportedInterfaces || type.culture == culture
362-
else
363-
{
364-
throw AssertionError.init(message: """
365-
Found cross-module conformance relationship \
366-
(from \(type.culture) in \(culture)), which should not be possible in \
367-
symbol dumps generated with '-emit-extension-symbols'
368-
""")
369-
}
370-
371337
if let origin:Symbol.Decl = conformance.origin
372338
{
373339
type.assign(origin: origin)
@@ -422,14 +388,6 @@ extension SSGC.TypeChecker
422388
return
423389
}
424390

425-
guard self.ignoreExportedInterfaces || subform.culture == culture
426-
else
427-
{
428-
throw AssertionError.init(message: """
429-
Found retroactive superform relationship (from \(subform.culture) in \(culture))
430-
""")
431-
}
432-
433391
try subform.add(superform: relationship)
434392

435393
/// Having a universal witness is not intrinsic, but it is useful to know
@@ -459,8 +417,6 @@ extension SSGC.TypeChecker
459417
throw SSGC.UnexpectedSymbolError.vector(symbol)
460418

461419
case .scalar(let symbol):
462-
// If the colonial graph was generated with '-emit-extension-symbols',
463-
// we should never see an external type reference here.
464420
if let decl:SSGC.DeclObject = self.declarations[visible: symbol]
465421
{
466422
heir = decl
@@ -470,16 +426,6 @@ extension SSGC.TypeChecker
470426
return
471427
}
472428

473-
guard self.ignoreExportedInterfaces || heir.culture == culture
474-
else
475-
{
476-
throw AssertionError.init(message: """
477-
Found direct cross-module feature inheritance relationship in culture \
478-
'\(culture)' adding feature '\(feature.value.path)' to type \
479-
'\(heir.value.path)' from '\(heir.culture)', which should not be \
480-
possible in symbol dumps generated with '-emit-extension-symbols'
481-
""")
482-
}
483429
guard heir.id == relationship.source.heir
484430
else
485431
{
@@ -579,16 +525,29 @@ extension SSGC.TypeChecker
579525
""")
580526
}
581527
}
582-
583-
self.resolvableLinks[heir.namespace, heir.value.path, feature.value.path.last].append(
584-
.feature(feature.value, self: heir.id))
585528
}
586529
}
587530
extension SSGC.TypeChecker
588531
{
589-
public __consuming
532+
public consuming
590533
func load(in culture:Symbol.Module) throws -> SSGC.ModuleIndex
591534
{
535+
for `extension`:SSGC.ExtensionObject in self.extensions.all
536+
{
537+
// We add the feature paths here and not in `insert(_:by:)` because those
538+
// edges are frequently duplicated, and it is hard to remove duplicate paths
539+
// after they have been added.
540+
let extendee:SSGC.DeclObject = try self.declarations[`extension`.extendee]
541+
for feature:Symbol.Decl in `extension`.features.keys
542+
{
543+
let feature:SSGC.Decl = try self.declarations[feature].value
544+
let last:String = feature.path.last
545+
546+
self.resolvableLinks[extendee.namespace, extendee.value.path, last].append(
547+
.feature(feature, self: extendee.id))
548+
}
549+
}
550+
592551
let extensions:[SSGC.Extension] = try self.extensions.load(culture: culture,
593552
with: self.declarations)
594553

Sources/SymbolGraphs/SymbolGraphABI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import SemanticVersions
33
@frozen public
44
enum SymbolGraphABI
55
{
6-
@inlinable public static var version:PatchVersion { .v(0, 10, 2) }
6+
@inlinable public static var version:PatchVersion { .v(0, 10, 3) }
77
}

0 commit comments

Comments
 (0)