Skip to content

Commit 2e158a4

Browse files
authored
ircode: handle content outside of a module (JuliaLang#58639)
Specifically, content in an `__init__` block is handled by secret duplicate precompile logic, and any content generated by it was previously not eligible to be included into cache files. Fix JuliaLang#58449
1 parent 7a86a28 commit 2e158a4

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

src/precompile.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ JL_DLLEXPORT void jl_write_compiler_output(void)
139139
}
140140
}
141141

142-
assert(jl_precompile_toplevel_module == NULL);
143142
void *native_code = NULL;
144143

145144
bool_t emit_native = jl_options.outputo || jl_options.outputbc || jl_options.outputunoptbc || jl_options.outputasm;

src/staticdata.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3419,9 +3419,6 @@ static void jl_save_system_image_to_stream(ios_t *f, jl_array_t *mod_array,
34193419

34203420
static void jl_write_header_for_incremental(ios_t *f, jl_array_t *worklist, jl_array_t *mod_array, jl_array_t **udeps, int64_t *srctextpos, int64_t *checksumpos)
34213421
{
3422-
assert(jl_precompile_toplevel_module == NULL);
3423-
jl_precompile_toplevel_module = (jl_module_t*)jl_array_ptr_ref(worklist, jl_array_len(worklist)-1);
3424-
34253422
*checksumpos = write_header(f, 0);
34263423
write_uint8(f, jl_cache_flags());
34273424
// write description of contents (name, uuid, buildid)
@@ -3479,9 +3476,7 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
34793476
// Generate _native_data`
34803477
if (_native_data != NULL) {
34813478
jl_prepare_serialization_data(mod_array, newly_inferred, &extext_methods, &new_ext_cis, NULL, &query_cache);
3482-
jl_precompile_toplevel_module = (jl_module_t*)jl_array_ptr_ref(worklist, jl_array_len(worklist)-1);
34833479
*_native_data = jl_precompile_worklist(worklist, extext_methods, new_ext_cis);
3484-
jl_precompile_toplevel_module = NULL;
34853480
extext_methods = NULL;
34863481
new_ext_cis = NULL;
34873482
}
@@ -3528,7 +3523,6 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
35283523
// Re-enable running julia code for postoutput hooks, atexit, etc.
35293524
jl_gc_enable_finalizers(ct, 1);
35303525
ct->reentrant_timing &= ~0b1000u;
3531-
jl_precompile_toplevel_module = NULL;
35323526

35333527
if (worklist) {
35343528
// Go back and update the checksum in the header

src/toplevel.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ htable_t jl_current_modules;
3434
jl_mutex_t jl_modules_mutex;
3535

3636
// During incremental compilation, the following gets set
37-
jl_module_t *jl_precompile_toplevel_module = NULL; // the toplevel module currently being defined
37+
jl_module_t *jl_precompile_toplevel_module = NULL; // the first toplevel module being defined
3838

3939
jl_module_t *jl_add_standard_imports(jl_module_t *m)
4040
{
@@ -172,7 +172,6 @@ static jl_value_t *jl_eval_module_expr(jl_module_t *parent_module, jl_expr_t *ex
172172
}
173173
}
174174

175-
jl_module_t *old_toplevel_module = jl_precompile_toplevel_module;
176175
size_t last_age = ct->world_age;
177176

178177
if (parent_module == jl_main_module && name == jl_symbol("Base") && jl_base_module == NULL) {
@@ -182,7 +181,7 @@ static jl_value_t *jl_eval_module_expr(jl_module_t *parent_module, jl_expr_t *ex
182181

183182
if (is_parent__toplevel__) {
184183
jl_register_root_module(newm);
185-
if (jl_options.incremental) {
184+
if (jl_options.incremental && jl_precompile_toplevel_module == NULL) {
186185
jl_precompile_toplevel_module = newm;
187186
}
188187
}
@@ -241,8 +240,6 @@ static jl_value_t *jl_eval_module_expr(jl_module_t *parent_module, jl_expr_t *ex
241240
}
242241
}
243242

244-
jl_precompile_toplevel_module = old_toplevel_module;
245-
246243
JL_GC_POP();
247244
return (jl_value_t*)newm;
248245
}

0 commit comments

Comments
 (0)