Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

precompile_utils: Don't auto-enqueue macro methods for pre-compilation #57833

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/precompile_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ static void jl_compile_all_defs(jl_array_t *mis, int all)
size_t i, l = jl_array_nrows(allmeths);
for (i = 0; i < l; i++) {
jl_method_t *m = (jl_method_t*)jl_array_ptr_ref(allmeths, i);
int is_macro_method = jl_symbol_name(m->name)[0] == '@';
if (is_macro_method)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (is_macro_method)
if (is_macro_method && !all)

continue; // Avoid inference / pre-compilation for macros

if (jl_is_datatype(m->sig) && jl_isa_compileable_sig((jl_tupletype_t*)m->sig, jl_emptysvec, m)) {
// method has a single compilable specialization, e.g. its definition
// signature is concrete. in this case we can just hint it.
Expand Down
5 changes: 5 additions & 0 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2369,4 +2369,9 @@ precompile_test_harness("Package top-level load itself") do load_path
end
end

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

finish_precompile_test!()
Loading