Skip to content

Commit 6ce51d3

Browse files
authored
precompile_utils: Don't auto-enqueue macro methods for pre-compilation (#57833)
Despite disabling these from being compiled in `gf.c` for dynamic invocations, the pre-compilation code was adding `macro` Methods anyway to the workqueue. Replaces #57782
1 parent 7cce1d3 commit 6ce51d3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/precompile_utils.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ static void jl_compile_all_defs(jl_array_t *mis, int all)
170170
size_t i, l = jl_array_nrows(allmeths);
171171
for (i = 0; i < l; i++) {
172172
jl_method_t *m = (jl_method_t*)jl_array_ptr_ref(allmeths, i);
173+
int is_macro_method = jl_symbol_name(m->name)[0] == '@';
174+
if (is_macro_method && !all)
175+
continue; // Avoid inference / pre-compilation for macros
176+
173177
if (jl_is_datatype(m->sig) && jl_isa_compileable_sig((jl_tupletype_t*)m->sig, jl_emptysvec, m)) {
174178
// method has a single compilable specialization, e.g. its definition
175179
// signature is concrete. in this case we can just hint it.

test/precompile.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,4 +2410,9 @@ precompile_test_harness("Package top-level load itself") do load_path
24102410
end
24112411
end
24122412

2413+
# Verify that inference / caching was not performed for any macros in the sysimage
2414+
let m = only(methods(Base.var"@big_str"))
2415+
@test m.specializations === Core.svec() || !isdefined(m.specializations, :cache)
2416+
end
2417+
24132418
finish_precompile_test!()

0 commit comments

Comments
 (0)