Skip to content

Commit 49fb929

Browse files
authored
Merge pull request #51 from lucatrv/add-julia-compilation-flags
Add Julia compilation flags
2 parents da6c8a6 + 0e12921 commit 49fb929

File tree

3 files changed

+177
-119
lines changed

3 files changed

+177
-119
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.ji
12
*.o
23
*.so
34
*.so.*

README.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,63 @@
1-
## Building a shared library and executable from your julia code
1+
# Julia AOT compiler
22

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.
54

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")
719
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+
```
949

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
1851

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.
2053

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
2258
driver binary `hello` are created in the `builddir` directory.
59+
Running `hello` produces the following output:
60+
2361
```
2462
$ ./hello
2563
hello, world
@@ -62,4 +100,3 @@ sections in the Julia manual.
62100
With Julia 0.7, a single large binary can be created, which does not
63101
require the driver program to load the shared library. An example of
64102
that is in `program2.c`, where the image file is the binary itself.
65-

0 commit comments

Comments
 (0)