|
1 | | -## Building a shared library and executable from your julia code |
| 1 | +# Julia AOT compiler |
2 | 2 |
|
3 | | -1. Make sure all the packages and modules used by `hello.jl` are precompiled. |
4 | | - The `juliac.jl` script uses the `ArgParse` package, make sure it is installed as well. |
| 3 | +Helper script to build libraries and executables from Julia code. |
5 | 4 |
|
6 | | -2. Clone this repo and use the `juliac.jl` script. The way to call it is as follows: |
| 5 | +``` |
| 6 | +usage: juliac.jl [-v] [-q] [-c] [-C <target>] [-O {0,1,2,3}] |
| 7 | + [-g {0,1,2}] [--inline {yes|no}] |
| 8 | + [--check-bounds {yes|no}] [--math-mode {ieee,fast}] |
| 9 | + [--depwarn {yes|no|error}] [-o] [-s] [-e] [-j] |
| 10 | + [--version] [-h] juliaprog [cprog] [builddir] |
| 11 | +
|
| 12 | +positional arguments: |
| 13 | + juliaprog Julia program to compile |
| 14 | + cprog C program to compile (if not provided, a |
| 15 | + minimal standard program is used) |
| 16 | + builddir build directory, either absolute or relative |
| 17 | + to the Julia program directory (default: |
| 18 | + "builddir") |
7 | 19 |
|
8 | | - Usage: `juliac.jl [-v] [-q] [-o] [-s] [-e] [-j] [-h] juliaprog [cprog] [builddir]` |
| 20 | +optional arguments: |
| 21 | + -v, --verbose increase verbosity |
| 22 | + -q, --quiet suppress non-error messages |
| 23 | + -c, --clean delete builddir |
| 24 | + -C, --cpu-target <target> |
| 25 | + limit usage of CPU features up to <target> |
| 26 | + -O, --optimize {0,1,2,3} |
| 27 | + set optimization level (type: Int64) |
| 28 | + -g {0,1,2} set debugging information level (type: Int64) |
| 29 | + --inline {yes|no} control whether inlining is permitted |
| 30 | + --check-bounds {yes|no} |
| 31 | + emit bounds checks always or never |
| 32 | + --math-mode {ieee,fast} |
| 33 | + set floating point optimizations |
| 34 | + --depwarn {yes|no|error} |
| 35 | + set syntax and method deprecation warnings |
| 36 | + -o, --object build object file |
| 37 | + -s, --shared build shared library |
| 38 | + -e, --executable build executable file |
| 39 | + -j, --julialibs sync Julia libraries to builddir |
| 40 | + --version show version information and exit |
| 41 | + -h, --help show this help message and exit |
| 42 | +
|
| 43 | +examples: |
| 44 | + juliac.jl -ve hello.jl # verbose, build executable |
| 45 | + juliac.jl -ve hello.jl myprog.c # embed into user defined C program |
| 46 | + juliac.jl -qo hello.jl # quiet, build object file |
| 47 | + juliac.jl -vosej hello.jl # build all and sync Julia libs |
| 48 | +``` |
9 | 49 |
|
10 | | - Examples: |
11 | | - ``` |
12 | | - julia juliac.jl -ve hello.jl # verbose, create an executable |
13 | | - julia juliac.jl -ve hello.jl myprogram.c # embed into a user defined c program |
14 | | - julia juliac.jl --quiet --object hello.jl # builds just the `hello.o` object file |
15 | | - julia juliac.jl -vosej hello.jl buildtest # build object, shared lib, exec, and sync julia libs |
16 | | - julia juliac.jl -h # print help message |
17 | | - ``` |
| 50 | +### Notes |
18 | 51 |
|
19 | | - Note: `hello.jl` does not need to be in the `static-julia` directory. |
| 52 | +1. The `juliac.jl` script uses the `ArgParse` package, make sure it is installed. |
20 | 53 |
|
21 | | -3. A shared library containing the system image `libhello.so`, and a |
| 54 | +3. On Windows install `Cygwin` and the `mingw64-x86_64-gcc-core` package, see:\ |
| 55 | + https://github.com/JuliaLang/julia/blob/master/README.windows.md |
| 56 | + |
| 57 | +2. A shared library containing the system image `libhello.so`, and a |
22 | 58 | driver binary `hello` are created in the `builddir` directory. |
| 59 | + Running `hello` produces the following output: |
| 60 | + |
23 | 61 | ``` |
24 | 62 | $ ./hello |
25 | 63 | hello, world |
@@ -62,4 +100,3 @@ sections in the Julia manual. |
62 | 100 | With Julia 0.7, a single large binary can be created, which does not |
63 | 101 | require the driver program to load the shared library. An example of |
64 | 102 | that is in `program2.c`, where the image file is the binary itself. |
65 | | - |
|
0 commit comments