Skip to content

Commit 75bf576

Browse files
committed
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 618c74e commit 75bf576

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/precompile_utils.c

+4
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ static void jl_compile_all_defs(jl_array_t *mis)
157157
size_t i, l = jl_array_nrows(allmeths);
158158
for (i = 0; i < l; i++) {
159159
jl_method_t *m = (jl_method_t*)jl_array_ptr_ref(allmeths, i);
160+
int is_macro_method = jl_symbol_name(m->name)[0] == '@';
161+
if (is_macro_method && !all)
162+
continue; // Avoid inference / pre-compilation for macros
163+
160164
if (jl_is_datatype(m->sig) && jl_isa_compileable_sig((jl_tupletype_t*)m->sig, jl_emptysvec, m)) {
161165
// method has a single compilable specialization, e.g. its definition
162166
// signature is concrete. in this case we can just hint it.

test/precompile.jl

+5
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,11 @@ precompile_test_harness("No package module") do load_path
22882288
String(take!(io)))
22892289
end
22902290

2291+
# Verify that inference / caching was not performed for any macros in the sysimage
2292+
let m = only(methods(Base.var"@big_str"))
2293+
@test m.specializations === Core.svec() || !isdefined(m.specializations, :cache)
2294+
end
2295+
22912296
empty!(Base.DEPOT_PATH)
22922297
append!(Base.DEPOT_PATH, original_depot_path)
22932298
empty!(Base.LOAD_PATH)

0 commit comments

Comments
 (0)