Skip to content

Commit 9eb0fbf

Browse files
authored
Provide ability for caller to seed/re-use symbol table across compile jobs (#294)
In addition to allowing a later compilation job to detect collisions with symbols defined in earlier jobs, this also gives the caller access to an index of all symbols, which can be used to implement an efficient resolver over all results of compilation.
1 parent 016b009 commit 9eb0fbf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

compiler.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ type Compiler struct {
8989
// will be removed as soon as it's no longer needed. This can help reduce
9090
// total memory usage for operations involving a large number of files.
9191
RetainASTs bool
92+
93+
// If non-nil, the set of symbols already known. Any symbols in the current
94+
// compilation will be added to it. If the compilation tries to redefine any
95+
// of these symbols, it will be reported as a collision.
96+
//
97+
// This allows a large compilation to be split up into multiple, smaller
98+
// operations and still be able to identify naming collisions and extension
99+
// number collisions across all operations.
100+
Symbols *linker.Symbols
92101
}
93102

94103
// SourceInfoMode indicates how source code info is generated by a Compiler.
@@ -140,12 +149,16 @@ func (c *Compiler) Compile(ctx context.Context, files ...string) (linker.Files,
140149

141150
h := reporter.NewHandler(c.Reporter)
142151

152+
sym := c.Symbols
153+
if sym == nil {
154+
sym = &linker.Symbols{}
155+
}
143156
e := executor{
144157
c: c,
145158
h: h,
146159
s: semaphore.NewWeighted(int64(par)),
147160
cancel: cancel,
148-
sym: &linker.Symbols{},
161+
sym: sym,
149162
results: map[string]*result{},
150163
}
151164

0 commit comments

Comments
 (0)