Last active
February 24, 2019 00:29
-
-
Save tkf/bb020c3e2d64d049696c7e549f0120ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.a | |
*.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
code_print_image_file="print(unsafe_string(Base.JLOptions().image_file))" | |
JULIA="${JULIA:-julia}" | |
IMAGE="$("$JULIA" -e "$code_print_image_file")" | |
OUTPUT_O=sys.a | |
OUTPUT_S=sys.so | |
set -ex | |
${JULIA} --output-o="$OUTPUT_O" \ | |
-g1 --startup-file=no --code-coverage=none \ | |
--history-file=yes --inline=yes --math-mode=ieee --handle-signals=yes \ | |
--startup-file=no --warn-overwrite=no --compile=yes --depwarn=yes \ | |
--cpu-target=native --track-allocation=none --sysimage-native-code=yes \ | |
--sysimage="$IMAGE" \ | |
--compiled-modules=yes --optimize=2 \ | |
./precompile_wrapper.jl | |
${JULIA} --startup-file=no \ | |
-e " | |
using PackageCompiler | |
s_file = \"$OUTPUT_S\" | |
o_file = \"$OUTPUT_O\" | |
init_shared = false | |
builddir = \"$PWD\" | |
verbose = true | |
optimize = \"3\" | |
debug = false | |
cc = PackageCompiler.system_compiler | |
cc_flags = nothing | |
PackageCompiler.build_shared( | |
s_file, o_file, init_shared, builddir, verbose, optimize, | |
debug, cc, cc_flags) | |
" | |
${JULIA} --startup-file=no --sysimage "$OUTPUT_S" -e "$code_print_image_file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
JULIA="${JULIA:-julia}" | |
JULIA_PROJECT="${JULIA_PROJECT:-$PWD}" | |
export JULIA_PROJECT | |
set -ex | |
${JULIA} --startup-file=no -e "using Pkg; Pkg.instantiate(); using PyCall" | |
exec "$(dirname "${BASH_SOURCE[0]}")"/compile.bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MacroTools | |
isdefined(MacroTools, :__init__) && MacroTools.__init__() | |
# Put `println(MacroTools.@expand @time foo())` (say) in | |
# `PyCall.__init__` (say) and then comment out above. You'll get an | |
# exception below. | |
using PyCall | |
PyCall.__init__() # https://github.com/JuliaLang/julia/issues/22910 | |
PyCall.pyimport("sys")[:executable] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
atexit_hook_copy = copy(Base.atexit_hooks) # make backup | |
# clean state so that any package we use can carelessly call atexit | |
empty!(Base.atexit_hooks) | |
Base.__init__() | |
Sys.__init__() #fix https://github.com/JuliaLang/julia/issues/30479 | |
using REPL | |
Base.REPL_MODULE_REF[] = REPL | |
M = Module() | |
# Include into anonymous module to not polute namespace | |
@eval(M, (Base.include($M, $(joinpath(@__DIR__, "precompile.jl"))))) | |
Base._atexit() # run all exit hooks we registered during precompile | |
empty!(Base.atexit_hooks) # don't serialize the exit hooks we run + added | |
# atexit_hook_copy should be empty, but who knows what base will do in the future | |
append!(Base.atexit_hooks, atexit_hook_copy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[deps] | |
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment