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

Revert "The return of the "Generate precompilation as part of build process #28346

Merged
merged 1 commit into from
Jul 29, 2018
Merged
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
Revert "The return of the "Generate precompilation as part of build p…
…rocess" (#28319)"

This reverts commit dfa3e2b.
  • Loading branch information
KristofferC committed Jul 29, 2018
commit 10e4795ea70f8047be0af5d4fa69b8c017659247
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ define sysimg_builder
$$(build_private_libdir)/sys$1-o.a $$(build_private_libdir)/sys$1-bc.a : $$(build_private_libdir)/sys$1-%.a : $$(build_private_libdir)/sys.ji
@$$(call PRINT_JULIA, cd $$(JULIAHOME)/base && \
if ! $$(call spawn,$3) $2 -C "$$(JULIA_CPU_TARGET)" --output-$$* $$(call cygpath_w,$$@).tmp $$(JULIA_SYSIMG_BUILD_FLAGS) \
--startup-file=no --warn-overwrite=yes --sysimage $$(call cygpath_w,$$<) $$(call cygpath_w,$$(JULIAHOME)/contrib/generate_precompile.jl) $$(call cygpath_w,$$<); then \
--startup-file=no --warn-overwrite=yes --sysimage $$(call cygpath_w,$$<) -e nothing; then \
echo '*** This error is usually fixed by running `make clean`. If the error persists$$(COMMA) try `make cleanall`. ***'; \
false; \
fi )
Expand Down
1 change: 0 additions & 1 deletion base/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct JLOptions
warn_overwrite::Int8
can_inline::Int8
polly::Int8
trace_compile::Int8
fast_math::Int8
worker::Int8
cookie::Ptr{UInt8}
Expand Down
746 changes: 746 additions & 0 deletions base/precompile.jl

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ let
:SuiteSparse,
:Distributed,
:SharedArrays,
:Pkg,
:Test,
:REPL,
:Pkg,
:Statistics,
]

Expand Down Expand Up @@ -922,9 +922,11 @@ Base.init_load_path() # want to be able to find external packages in userimg.jl

let
tot_time_userimg = @elapsed (Base.isfile("userimg.jl") && Base.include(Main, "userimg.jl"))
tot_time_precompile = Base.is_primary_base_module ? (@elapsed Base.include(Base, "precompile.jl")) : 0.0


tot_time_base = (Base.end_base_include - Base.start_base_include) * 10.0^(-9)
tot_time = tot_time_base + Base.tot_time_stdlib[] + tot_time_userimg
tot_time = tot_time_base + Base.tot_time_stdlib[] + tot_time_userimg + tot_time_precompile

println("Sysimage built. Summary:")
print("Total ─────── "); Base.time_print(tot_time * 10^9); print(" \n");
Expand All @@ -933,6 +935,7 @@ print("Stdlibs: ──── "); Base.time_print(Base.tot_time_stdlib[] * 10^9);
if isfile("userimg.jl")
print("Userimg: ──── "); Base.time_print(tot_time_userimg * 10^9); print(" "); show(IOContext(stdout, :compact=>true), (tot_time_userimg / tot_time) * 100); println("%")
end
print("Precompile: ─ "); Base.time_print(tot_time_precompile * 10^9); print(" "); show(IOContext(stdout, :compact=>true), (tot_time_precompile / tot_time) * 100); println("%")
end

empty!(LOAD_PATH)
Expand Down
1 change: 1 addition & 0 deletions contrib/add_license_to_files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const excludedirs = [

const skipfiles = [
"../contrib/add_license_to_files.jl",
"../contrib/fixup_precompile.jl",
# files to check - already copyright
# see: https://github.com/JuliaLang/julia/pull/11073#issuecomment-98099389
"../base/special/trig.jl",
Expand Down
70 changes: 70 additions & 0 deletions contrib/fixup_precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

function needs_USE_GPL_LIBS(s::String)
occursin("CHOLMOD", s) && return true
return false
end

const HEADER = """
# This file is a part of Julia. License is MIT: https://julialang.org/license

# Steps to regenerate this file:
# 1. Remove all `precompile` calls
# 2. Rebuild system image
# 3. Enable TRACE_COMPILE in options.h and rebuild
# 4. Run `./julia 2> precompiles.txt` and do various things.
# 5. Run `./julia contrib/fixup_precompile.jl precompiles.txt to overwrite `precompile.jl`
# or ./julia contrib/fixup_precompile.jl --merge precompiles.txt to merge into existing
# `precompile.jl`
"""

function fixup_precompile(new_precompile_file; merge=false)
old_precompile_file = joinpath(Sys.BINDIR, "..", "..", "base", "precompile.jl")
precompile_statements = Set{String}()

for file in [new_precompile_file; merge ? old_precompile_file : []]
for line in eachline(file)
line = strip(line)
# filter out closures, which might have different generated names in different environments
occursin(r"#[0-9]", line) && continue
# Other stuff than precompile statements might have been written to STDERR
startswith(line, "precompile(Tuple{") || continue
# Ok, add the line
push!(precompile_statements, line)
end
end

open(old_precompile_file, "w") do f
println(f, HEADER)
println(f, """
let
PrecompileStagingArea = Module()
for (_pkgid, _mod) in Base.loaded_modules
if !(_pkgid.name in ("Main", "Core", "Base"))
@eval PrecompileStagingArea \$(Symbol(_mod)) = \$_mod
end
end
@eval PrecompileStagingArea begin""")
for statement in sort(collect(precompile_statements))
isgpl = needs_USE_GPL_LIBS(statement)
isgpl && print(f, "if Base.USE_GPL_LIBS\n ")
println(f, statement)
isgpl && println(f, "end")
end
println(f, "end\nend")
end
if merge
"Merged $new_precompile_file into $old_precompile_file"
else
"Overwrite $old_precompile_file with $new_precompile_file"
end
end

if length(ARGS) == 1
fixup_precompile(joinpath(pwd(), ARGS[1]))
elseif length(ARGS) == 2
@assert ARGS[1] == "--merge"
fixup_precompile(joinpath(pwd(), ARGS[2]); merge = true)
else
error("invalid arguments")
end
139 changes: 0 additions & 139 deletions contrib/generate_precompile.jl

This file was deleted.

73 changes: 0 additions & 73 deletions contrib/precompile_replay.jl

This file was deleted.

12 changes: 6 additions & 6 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,13 +1088,13 @@ static jl_method_instance_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype
if (entry != NULL) {
jl_method_t *m = entry->func.method;
if (!jl_has_call_ambiguities((jl_value_t*)tt, m)) {
if (jl_options.trace_compile) {
if (!jl_has_free_typevars((jl_value_t*)tt)) {
jl_printf(JL_STDERR, "precompile(");
jl_static_show(JL_STDERR, (jl_value_t*)tt);
jl_printf(JL_STDERR, ")\n");
}
#ifdef TRACE_COMPILE
if (!jl_has_free_typevars((jl_value_t*)tt)) {
jl_printf(JL_STDERR, "precompile(");
jl_static_show(JL_STDERR, (jl_value_t*)tt);
jl_printf(JL_STDERR, ")\n");
}
#endif
if (!mt_cache) {
intptr_t nspec = (mt == jl_type_type_mt ? m->nargs + 1 : mt->max_args + 2);
jl_compilation_sig(tt, env, m, nspec, &newparams);
Expand Down
Loading