diff --git a/src/precompile.c b/src/precompile.c index ff5edb9a745f3..75970a20237c2 100644 --- a/src/precompile.c +++ b/src/precompile.c @@ -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; diff --git a/src/staticdata.c b/src/staticdata.c index 91c0b04bac5d0..804193ff90229 100644 --- a/src/staticdata.c +++ b/src/staticdata.c @@ -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); @@ -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); } @@ -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);