Skip to content

Commit 62b70e3

Browse files
committed
avoid generating native code if only output ji file (#48431)
(cherry picked from commit 2eeefbe)
1 parent 26b6e81 commit 62b70e3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/precompile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ JL_DLLEXPORT void jl_write_compiler_output(void)
114114
ios_t *s = NULL;
115115
ios_t *z = NULL;
116116
int64_t srctextpos = 0 ;
117-
jl_create_system_image(&native_code, jl_options.incremental ? worklist : NULL, emit_split,
118-
&s, &z, &udeps, &srctextpos);
117+
jl_create_system_image(emit_native ? &native_code : NULL,
118+
jl_options.incremental ? worklist : NULL,
119+
emit_split, &s, &z, &udeps, &srctextpos);
119120

120121
if (!emit_split)
121122
z = s;

src/staticdata.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,7 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
26162616
if (worklist) {
26172617
mod_array = jl_get_loaded_modules(); // __toplevel__ modules loaded in this session (from Base.loaded_modules_array)
26182618
// Generate _native_data`
2619-
if (jl_options.outputo || jl_options.outputbc || jl_options.outputunoptbc || jl_options.outputasm) {
2619+
if (_native_data != NULL) {
26202620
jl_prepare_serialization_data(mod_array, newly_inferred, jl_worklist_key(worklist),
26212621
&extext_methods, &new_specializations, NULL, NULL, NULL);
26222622
jl_precompile_toplevel_module = (jl_module_t*)jl_array_ptr_ref(worklist, jl_array_len(worklist)-1);
@@ -2635,7 +2635,7 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
26352635
checksumpos_ff = checksumpos;
26362636
}
26372637
}
2638-
else {
2638+
else if (_native_data != NULL) {
26392639
*_native_data = jl_precompile(jl_options.compile_enabled == JL_OPTIONS_COMPILE_ALL);
26402640
}
26412641

@@ -2656,9 +2656,11 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
26562656
}
26572657
datastartpos = ios_pos(ff);
26582658
}
2659-
native_functions = *_native_data;
2659+
if (_native_data != NULL)
2660+
native_functions = *_native_data;
26602661
jl_save_system_image_to_stream(ff, worklist, extext_methods, new_specializations, method_roots_list, ext_targets, edges);
2661-
native_functions = NULL;
2662+
if (_native_data != NULL)
2663+
native_functions = NULL;
26622664
// make sure we don't run any Julia code concurrently before this point
26632665
// Re-enable running julia code for postoutput hooks, atexit, etc.
26642666
jl_gc_enable_finalizers(ct, 1);

0 commit comments

Comments
 (0)