Name: static-julia
Owner: Julia Computing, Inc.
Description: Static AOT Julia compilation, demos and instructions
Created: 2015-11-02 23:51:15.0
Updated: 2018-01-13 18:18:27.0
Pushed: 2018-01-17 00:15:43.0
Homepage: null
Size: 46
Language: Julia
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Building shared libraries and executables from Julia code.
Run juliac.jl -h
for help:
e: juliac.jl [-v] [-q] [-c] [-J <file>]
[--compile {yes|no|all|min}] [-C <target>]
[-O {0,1,2,3}] [-g {0,1,2}] [--inline {yes|no}]
[--check-bounds {yes|no}] [--math-mode {ieee,fast}]
[--depwarn {yes|no|error}] [-a] [-o] [-s] [-e] [-j]
[--version] [-h] juliaprog [cprog] [builddir]
ic Julia Compiler
tional arguments:
liaprog Julia program to compile
rog C program to compile (required only when
building an executable; if not provided a
minimal standard program is used)
ilddir build directory, either absolute or relative
to the Julia program directory (default:
"builddir")
onal arguments:
, --verbose increase verbosity
, --quiet suppress non-error messages
, --clean delete builddir
, --sysimage <file>
start up with the given system image file
compile {yes|no|all|min}
enable or disable JIT compiler, or request
exhaustive compilation
, --cpu-target <target>
limit usage of CPU features up to <target>
, --optimize {0,1,2,3}
set optimization level (type: Int64)
{0,1,2} set debugging information level (type: Int64)
inline {yes|no} control whether inlining is permitted
check-bounds {yes|no}
emit bounds checks always or never
math-mode {ieee,fast}
set floating point optimizations
depwarn {yes|no|error}
set syntax and method deprecation warnings
, --autodeps automatically build required dependencies
, --object build object file
, --shared build shared library
, --executable build executable file
, --julialibs sync Julia libraries to builddir
version show version information and exit
, --help show this help message and exit
ples:
liac.jl -vae hello.jl # verbose, build executable and deps
liac.jl -vae hello.jl prog.c # embed into user defined C program
liac.jl -qo hello.jl # quiet, build object file only
liac.jl -vosej hello.jl # build all and sync Julia libs
The juliac.jl
script uses the ArgParse
package, make sure it is installed.
On Windows install Cygwin
and the mingw64-x86_64-gcc-core
package, see:\
https://github.com/JuliaLang/julia/blob/master/README.windows.md
A shared library containing the system image libhello.so
, and a
driver binary hello
are created in the builddir
directory.
Running hello
produces the following output:
./hello
ello, world
() = -0.37549581296986956
???????????????????????????????????????????????????
00 ??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????
0 ??????????????????????????????????????????
???????????????????????????????????????????????????
1 10
The juliac.jl
script uses the --output-o
switch to compile the user
script into object code, and then builds it into the system image
specified by the -J
switch. This prepares an object file, which is
then linked into a shared library containing the system image and user
code. A driver script such as the one in program.c
can then be used to
build a binary that runs the julia code.
Instead of a driver script, the generated system image can be embedded
into a larger program following the embedding examples and relevant
sections in the Julia manual. Note that the name of the generated system
image ("libhello"
for hello.jl
) is accessible from C in the
preprocessor macro JULIAC_PROGRAM_LIBNAME
.
With Julia 0.7, a single large binary can be created, which does not
require the driver program to load the shared library. An example of
that is in program2.c
, where the image file is the binary itself.
For more information on static Julia compilation see:\ https://juliacomputing.com/blog/2016/02/09/static-julia.html
For more information on embedding Julia see:\ https://github.com/JuliaLang/julia/blob/master/doc/src/manual/embedding.md