Commit 1eeafc3967

Andrew Kelley <andrew@ziglang.org>
2021-07-28 00:10:49
stage2: move call to populateTestFunctions() outside performAllTheWork()
Before calling populateTestFunctions() we want to check totalErrorCount() but that will read from some tables that might get populated by the thread pool for C compilation tasks. So we wait until all those tasks are finished before proceeding.
1 parent a8e964e
Changed files (1)
src/Compilation.zig
@@ -1737,6 +1737,13 @@ pub fn update(self: *Compilation) !void {
 
     if (!use_stage1) {
         if (self.bin_file.options.module) |module| {
+            if (self.bin_file.options.is_test and self.totalErrorCount() == 0) {
+                // The `test_functions` decl has been intentionally postponed until now,
+                // at which point we must populate it with the list of test functions that
+                // have been discovered and not filtered out.
+                try module.populateTestFunctions();
+            }
+
             // Process the deletion set. We use a while loop here because the
             // deletion set may grow as we call `clearDecl` within this loop,
             // and more unreferenced Decls are revealed.
@@ -2384,14 +2391,6 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
             };
         },
     };
-
-    if (self.bin_file.options.is_test and self.totalErrorCount() == 0) {
-        // The `test_functions` decl has been intentionally postponed until now,
-        // at which point we must populate it with the list of test functions that
-        // have been discovered and not filtered out.
-        const mod = self.bin_file.options.module.?;
-        try mod.populateTestFunctions();
-    }
 }
 
 const AstGenSrc = union(enum) {