Skip to content

Commit

Permalink
avoid generating native code if only output ji file (#48431)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash authored Jan 28, 2023
1 parent 82cec36 commit 2eeefbe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/precompile.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ JL_DLLEXPORT void jl_write_compiler_output(void)
ios_t *s = NULL;
ios_t *z = NULL;
int64_t srctextpos = 0 ;
jl_create_system_image(&native_code, jl_options.incremental ? worklist : NULL, emit_split,
&s, &z, &udeps, &srctextpos);
jl_create_system_image(emit_native ? &native_code : NULL,
jl_options.incremental ? worklist : NULL,
emit_split, &s, &z, &udeps, &srctextpos);

if (!emit_split)
z = s;
Expand Down
10 changes: 6 additions & 4 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
if (worklist) {
mod_array = jl_get_loaded_modules(); // __toplevel__ modules loaded in this session (from Base.loaded_modules_array)
// Generate _native_data`
if (jl_options.outputo || jl_options.outputbc || jl_options.outputunoptbc || jl_options.outputasm) {
if (_native_data != NULL) {
jl_prepare_serialization_data(mod_array, newly_inferred, jl_worklist_key(worklist),
&extext_methods, &new_specializations, NULL, NULL, NULL);
jl_precompile_toplevel_module = (jl_module_t*)jl_array_ptr_ref(worklist, jl_array_len(worklist)-1);
Expand All @@ -2574,7 +2574,7 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
checksumpos_ff = checksumpos;
}
}
else {
else if (_native_data != NULL) {
*_native_data = jl_precompile(jl_options.compile_enabled == JL_OPTIONS_COMPILE_ALL);
}

Expand All @@ -2595,9 +2595,11 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
}
datastartpos = ios_pos(ff);
}
native_functions = *_native_data;
if (_native_data != NULL)
native_functions = *_native_data;
jl_save_system_image_to_stream(ff, worklist, extext_methods, new_specializations, method_roots_list, ext_targets, edges);
native_functions = NULL;
if (_native_data != NULL)
native_functions = NULL;
// make sure we don't run any Julia code concurrently before this point
// Re-enable running julia code for postoutput hooks, atexit, etc.
jl_gc_enable_finalizers(ct, 1);
Expand Down

0 comments on commit 2eeefbe

Please sign in to comment.