Skip to content

Commit d0e9129

Browse files
committed
Update README.md
1 parent 0a9f366 commit d0e9129

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

README.md

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,74 @@
55

66
[![codecov.io](http://codecov.io/github/JuliaLang/PackageCompiler.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaLang/PackageCompiler.jl?branch=master)
77

8-
Remove jit overhead from your package and compile it into a system image.
9-
8+
Remove just-in-time compilation overhead from your package and compile it into a system image.
109

1110
## Usage example
1211
E.g. do:
12+
1313
```Julia
1414
using PackageCompiler
1515

1616
# This command will use the runtest.jl of Matcha + UnicodeFun to find out what functions to precompile!
17-
# force = false to not force overwriting julia's current system image
17+
# `force = false` to not force overwriting Julia's current system image
1818
compile_package("Matcha", "UnicodeFun", force = false, reuse = false)
1919

20-
# build again, reusing the snoop file
20+
# Build again, reusing the snoop file
2121
compile_package("Matcha", "UnicodeFun", force = false, reuse = true)
2222

2323
# You can define a file that will get run for snooping explicitly like this:
2424
# this makes sure, that binary gets cached for all functions called in `for_snooping.jl`
2525
compile_package("Matcha", "relative/path/for_snooping.jl")
2626

27-
# if you used force and want your old system image back (force will overwrite the default system image Julia uses) you can run:
27+
# If you used force and want your old system image back (force will overwrite the default system image Julia uses) you can run:
2828
revert()
2929

3030
# Or if you simply want to get a native system image e.g. when you have downloaded the generic Julia install:
3131
force_native_image!()
3232

33-
# building an executable
34-
33+
# Build an executable
3534
build_executable(
3635
"hello.jl", # Julia script containing a `julia_main` function, e.g. like `examples/hello.jl`
3736
snoopfile = "call_functions.jl", # Julia script which calls functions that you want to make sure to have precompiled [optional]
3837
builddir = "path/to/builddir" # that's where the compiled artifacts will end up [optional]
3938
)
4039

41-
# Building a shared library
40+
# Build a shared library
4241
build_shared_lib("hello.jl")
4342
```
4443

45-
4644
## Troubleshooting:
4745

48-
- You might need to tweak your runtest, since SnoopCompile can have problems with some statements. Please open issues about concrete problems! This is also why there is a way to point to a file different from runtests.jl, for the case it becomes impossible to combine testing and snoop compiling (just pass `("package", "snoopfile.jl")`)!
46+
- You might need to tweak your runtest, since `SnoopCompile` can have problems
47+
with some statements. Please open issues about concrete problems! This is also
48+
why there is a way to point to a file different from `runtests.jl`, for the case
49+
it becomes impossible to combine testing and snoop compiling, just pass
50+
`("package", "snoopfile.jl")`!
4951

50-
- non const globals are problematic, or globals defined in functions - removing those got me to 95% of making the package safe for static compilation
52+
- Non constant globals and globals defined in functions are problematic.
53+
Removing those got me to 95% of making the package safe for static compilation.
5154

52-
- type unstable code had some inference issues (around 2 occurrence, where I’m still not sure what was happening) - both cases happened with dictionaries… Only way to find those was investigating the segfaults with `gdb`, but then it was relatively easy to just juggle around the code, since the stacktraces accurately pointed to the problem. The non const globals might be related since they introduce type instabilities.
55+
- Type unstable code had some inference issues (around 2 occurrence, where I’m
56+
still not sure what was happening, and both cases happened with dictionaries).
57+
The only way to find those was investigating the segfaults with `gdb`, but then
58+
it was relatively easy to just juggle around the code, since the stacktraces
59+
accurately pointed to the problem. The non constant globals might be related
60+
since they introduce type instabilities.
5361

54-
- some generated functions needed reordering of the functions they call ( actually, even for normal compilation, all functions that get called in a generated function should be defined before it)
62+
- Some generated functions needed reordering of the functions they call
63+
(actually, even for normal compilation, all functions that get called in a
64+
generated function should be defined before it).
5565

56-
- I uncovered one out of bounds issue, that somehow was not coming up without static-compilation
57-
- I used julia-debug to uncover most bugs, but actually, the last errors I was trying to uncover where due to using julia-debug!
66+
- I uncovered one out-of-bounds issue, that somehow was not coming up without
67+
static compilation.
5868

59-
- you’re pretty much on your own and need to use gdb to find the issues and I still don’t know what the underlying julia issues are and when they will get fixed :wink: See: https://github.com/JuliaLang/julia/issues/24533. Hopefully we look at a better story with Julia 1.0!
69+
- I used `julia-debug` to uncover most bugs, but actually the last errors I was
70+
trying to uncover where due to `julia-debug` itself!
71+
72+
- You’re pretty much on your own and need to use `gdb` to find any issues and I
73+
still don’t know what the underlying julia issues are and when they will get
74+
fixed :wink: See: https://github.com/JuliaLang/julia/issues/24533.
75+
Hopefully we'll look at a better story with Julia 1.0!
6076

6177

6278
# Static Julia Compiler
@@ -170,7 +186,7 @@ Note that for a julia function to be callable from `C`, it must be defined with
170186
`Base.@ccallable`, e.g. `Base.@ccallable foo()::Cint = 3`.
171187

172188
## Building an executable
173-
To compile a julia program into an executable, you can use either the julia
189+
To compile a Julia program into an executable, you can use either the julia
174190
api, `build_executable("hello.jl", "hello")`, or the command line, `$
175191
juliac.jl -vae hello.jl`.
176192

@@ -194,7 +210,7 @@ end
194210

195211
Please see
196212
[examples/hello.jl](https://github.com/JuliaLang/PackageCompiler.jl/blob/master/examples/hello.jl)
197-
for an example julia program.
213+
for an example Julia program.
198214

199215
### Notes
200216

@@ -245,17 +261,11 @@ code. A driver script such as the one in `program.c` can then be used
245261
to build a binary that runs the Julia code.
246262

247263
Instead of a driver script, the generated system image can be embedded
248-
into a larger program following the embedding examples and relevant
249-
sections in the Julia manual. Note that the name of the generated system
264+
into a larger program, see the
265+
[Embedding Julia](https://docs.julialang.org/en/stable/manual/embedding/)
266+
section of the Julia manual. Note that the name of the generated system
250267
image (`"libhello"` for `hello.jl`) is accessible from C in the
251268
preprocessor macro `JULIAC_PROGRAM_LIBNAME`.
252269

253-
With Julia 0.7, a single large binary can be created, which does not
254-
require the driver program to load the shared library. An example of
255-
that is in `program2.c`, where the image file is the binary itself.
256-
257270
For more information on static Julia compilation see:\
258271
https://juliacomputing.com/blog/2016/02/09/static-julia.html
259-
260-
For more information on embedding Julia see:\
261-
https://github.com/JuliaLang/julia/blob/master/doc/src/manual/embedding.md

0 commit comments

Comments
 (0)