Simon Danisch / Jul 25 2019
PackageCompiler
Features
- create a system image containing
precompile
statements - convenience API for the above:
compile_incremental(packages...)
- create a shared library out of a Julia script
- create an executable
- https://nextjournal.com/julia
History
- refactored Jameson Nash script into a package
- Luca Trevisani & Nathan Daly helped a lot
- Snooping comes from Tim Holy
State
- written very hastily
- my main use case is satisfied
- infamous sd-notomls
- no fun to work on in my free-time
How to rewrite PackageCompiler
At its Core:
Code you want to get into your system Image:
Base.__init__(); Sys.__init__() function test() # This will be added to your image println("hi binaries") end test() # Global scope won't stay
precompile.jl
Julia
Compile it:
lib = abspath(joinpath( Sys.BINDIR, Base.PRIVATE_LIBDIR )) img = unsafe_string(Base.JLOptions().image_file) # compile image run(`julia -J$(img) -O3 --output-o sys.a /precompile.jl`) # Link it run(`g++ -m64 -shared -fPIC -L$(lib) -L$(dirname(lib)) -o sys.so -Wl,--whole-archive sys.a -Wl,--no-whole-archive`);
run(`julia -J/sys.so -e 'test()'`);
Snooping
Problems
- reverse engineer this
- what to snoop?
- package dependencies
- projects & system images
Code behaves differently with output-o
output-o
]add PackageCompiler
using PackageCompiler println(PackageCompiler.PrecompileCommand(snoop.jl))
Final Remarks
- if anyone wants to rewrite PackageCompiler: read through our hacks and ask :P
- Try out David Anthoff Visual Studio plugin