Package Images
Package images in Julia provide object caches (machine code) for Julia packages. They look like system image Julia and support many of its features. In particular, the basic serialization format is similar, and the system image is the basic image from which package images are created.
General overview
Package images are shared libraries containing both code and data. Like .ji
cache files, they are created for individual packages. The data section contains both global data (global package variables) and the necessary metadata about the methods and types defined in the package. The code section contains machine objects that cache the final output of the LLVM-based Julia compiler.
Using the command line parameter --pkgimages=no
, you can disable object caching in the current session. Please note that because of this, the cache files will most likely need to be re-created. For information about the maximum number of options cached by Julia by default, see the description of the environment variable JULIA_MAX_NUM_PRECOMPILE_FILES
.
Although the package images, at first glance, represent common machine code libraries, in fact they are only external similarities. You will not be able to do their layout from your own program, and they must be downloaded from Julia. |
Layout
Since package images contain machine code, they must be passed through the linker before usage. To compose a package image with detailed information output, you can assign an environment variable `JULIA_VERBOSE_LINKING' value `true'.
In addition, we cannot proceed from the assumption that the linker is installed on the user’s working system. Therefore, in order not to need to install additional components, Julia already includes an LLVM linker called LLD. base/linking.jl
implements a limited interface that allows you to link package images on all supported platforms.
Some subtleties
Although LLD is a multiplatform linker, it does not have a unified interface for all platforms. In addition, it assumes the usage of 'clang' or another compiler driver, so the implementation of some logic from llvm-project/clang/lib/Driver/ToolChains' has been redesigned. Fortunately, with the help of `lld -flavor
it is possible to select the LLD for the correct platform.
Windows
So that you don’t have to deal with link.exe `, we use `-flavor gnu
, which essentially turns lld' into a cross-compositor from the mingw32 environment. Windows DLL libraries should contain the `_DllMainCRTStartup
function, and to minimize dependence on mingw32 libraries, we introduce a stub definition.
Package images optimized for multiple microarchitectures
As in the case of system images, package images support multiple versioning. In a heterogeneous environment with a unified cache, you can set the environment variable JULIA_CPU_TARGET=generic
for multiple versioning of object caches.
Flags that affect the creation and selection of package images
The Julia command line flags that affect cache selection are listed below. Package images created with different flags are rejected.
-
`-g', `--debug-info': An exact match is required, as this affects code generation.
-
`--check-bounds': An exact match is required, as this affects code generation.
-
'--inline': An exact match is required, as this affects code generation.
-
--pkgimages
: allows execution when object caching is disabled. -
-O
, `--optimize': Package images created for a lower optimization level are rejected, but higher optimization levels are allowed to be downloaded.