CLI app for compiling and bundling julia binaries, especially trimmed ones
Julia
296
114 commits
updated Sep 8, 2026
JuliaC is a companion to PackageCompiler that streamlines turning Julia code into a native executable, shared library, system image, or intermediate object/bitcode. It provides:
juliaclibjulia/stdlibs and artifacts for portable distributionBuilt on top of PackageCompiler.jl.
clang/gcc on macOS/Linux; MSYS2 mingw on Windows)Install JuliaC as a Julia app:
pkg> app add JuliaC
Optional: enable Pkg app shims on your shell PATH so you can run juliac directly:
echo 'export PATH="$HOME/.julia/bin:$PATH"' >> ~/.bashrc # adapt for your shell
Given an app in test/AppProject (see the files in this repository),
compile an executable and produce a self-contained bundle in build/:
juliac \
--output-exe app_test_exe \
--bundle build \
--trim=safe \
--experimental \
test/AppProject
Notes:
--trim[=mode] enables removing unreachable code; on 1.12 prereleases this implies --experimental.function @main(args::Vector{String}) in your package or source file to build an executable.julia --project -e "using JuliaC; JuliaC.main(ARGS)" -- \
--output-exe app_test_exe \
--bundle build \
--trim=safe \
--experimental \
test/AppProject
--output-exe <name>: Output native executable name (no path). Use --bundle to choose destination directory.--output-lib|--output-sysimage|--output-o|--output-bc <path>: Output path for non-executable artifacts.--project <path>: Project to instantiate/precompile (defaults to active project).--bundle <dir>: Copy required Julia libs/stdlibs and artifacts next to the output; also sets a relative rpath.--bundle-lazy-artifacts: Also copy lazy artifacts into the bundle (off by default; opt in
when your dependencies download artifacts on first use).--privatize[=<salt>]: Prefix bundled libjulia filenames and symbol versions with a salt
(Unix), isolating runtimes loaded into the same process. By default, the salt is derived
from the product and Julia versions. An explicit salt must match
[A-Za-z_][A-Za-z0-9_]* and contain at most 8 characters.--trim[=mode]: Enable code trimming (e.g. --trim=safe). Use --trim=no to disable.--compile-ccallable: Export ccallable entrypoints (see C-callable section).--experimental: Forwarded to Julia; required for --trim on some builds.--verbose: Print underlying commands and timing.<file>: The Julia entry file or package to compile (must define @main for executables).using JuliaC
img = ImageRecipe(
output_type = "--output-exe",
file = "test/AppProject",
trim_mode = "safe",
add_ccallables = false,
verbose = true,
)
link = LinkRecipe(
image_recipe = img,
outname = "build/app_test_exe",
)
bun = BundleRecipe(
link_recipe = link,
output_dir = "build", # or `nothing` to skip bundling
)
compile_products(img)
link_products(link)
bundle_products(bun)
When --bundle (or BundleRecipe.output_dir) is set, JuliaC:
<output_dir>/bin and libraries in <output_dir>/lib and <output_dir>/lib/julia (Windows: everything under <output_dir>/bin).@loader_path/../lib or $ORIGIN/../lib)..dylib symlinks if missing.This produces a relocatable directory you can distribute.
When using the Library API, set rpath = "@bundle" in LinkRecipe to use relative rpaths
suitable for a relocatable bundle. The default ("@julia") uses absolute paths to the
current Julia installation, which is convenient for development but not for distribution.
On Julia 1.12+, JuliaC can exclude code proven not to be reachable from entry points, reducing binary size:
--trim=safe
On certain builds, --trim requires --experimental (JuliaC will pass it through if needed).
If you pass --compile-ccallable (or set ImageRecipe.add_ccallables = true), JuliaC will export ccallable entrypoints discovered in your code. This is often used when building libraries intended to be called from C or other languages.
clang or gcc available on PATHLazyArtifacts or JULIA_CCENV["JULIA_CC"] (e.g. clang/gcc path)JuliaC builds on PackageCompiler.jl and Julia's own build machinery. Many thanks to their authors and contributors.
Issues and PRs are welcome. Please provide OS, Julia version, and a minimal reproducer when reporting problems.
MIT. See the LICENSE file for details.
Julia
95.9%
C
4.1%
CLI app for compiling and bundling julia binaries, especially trimmed ones
Julia
296
114 commits
updated Sep 8, 2026
JuliaC is a companion to PackageCompiler that streamlines turning Julia code into a native executable, shared library, system image, or intermediate object/bitcode. It provides:
juliaclibjulia/stdlibs and artifacts for portable distributionBuilt on top of PackageCompiler.jl.
clang/gcc on macOS/Linux; MSYS2 mingw on Windows)Install JuliaC as a Julia app:
pkg> app add JuliaC
Optional: enable Pkg app shims on your shell PATH so you can run juliac directly:
echo 'export PATH="$HOME/.julia/bin:$PATH"' >> ~/.bashrc # adapt for your shell
Given an app in test/AppProject (see the files in this repository),
compile an executable and produce a self-contained bundle in build/:
juliac \
--output-exe app_test_exe \
--bundle build \
--trim=safe \
--experimental \
test/AppProject
Notes:
--trim[=mode] enables removing unreachable code; on 1.12 prereleases this implies --experimental.function @main(args::Vector{String}) in your package or source file to build an executable.julia --project -e "using JuliaC; JuliaC.main(ARGS)" -- \
--output-exe app_test_exe \
--bundle build \
--trim=safe \
--experimental \
test/AppProject
--output-exe <name>: Output native executable name (no path). Use --bundle to choose destination directory.--output-lib|--output-sysimage|--output-o|--output-bc <path>: Output path for non-executable artifacts.--project <path>: Project to instantiate/precompile (defaults to active project).--bundle <dir>: Copy required Julia libs/stdlibs and artifacts next to the output; also sets a relative rpath.--bundle-lazy-artifacts: Also copy lazy artifacts into the bundle (off by default; opt in
when your dependencies download artifacts on first use).--privatize[=<salt>]: Prefix bundled libjulia filenames and symbol versions with a salt
(Unix), isolating runtimes loaded into the same process. By default, the salt is derived
from the product and Julia versions. An explicit salt must match
[A-Za-z_][A-Za-z0-9_]* and contain at most 8 characters.--trim[=mode]: Enable code trimming (e.g. --trim=safe). Use --trim=no to disable.--compile-ccallable: Export ccallable entrypoints (see C-callable section).--experimental: Forwarded to Julia; required for --trim on some builds.--verbose: Print underlying commands and timing.<file>: The Julia entry file or package to compile (must define @main for executables).using JuliaC
img = ImageRecipe(
output_type = "--output-exe",
file = "test/AppProject",
trim_mode = "safe",
add_ccallables = false,
verbose = true,
)
link = LinkRecipe(
image_recipe = img,
outname = "build/app_test_exe",
)
bun = BundleRecipe(
link_recipe = link,
output_dir = "build", # or `nothing` to skip bundling
)
compile_products(img)
link_products(link)
bundle_products(bun)
When --bundle (or BundleRecipe.output_dir) is set, JuliaC:
<output_dir>/bin and libraries in <output_dir>/lib and <output_dir>/lib/julia (Windows: everything under <output_dir>/bin).@loader_path/../lib or $ORIGIN/../lib)..dylib symlinks if missing.This produces a relocatable directory you can distribute.
When using the Library API, set rpath = "@bundle" in LinkRecipe to use relative rpaths
suitable for a relocatable bundle. The default ("@julia") uses absolute paths to the
current Julia installation, which is convenient for development but not for distribution.
On Julia 1.12+, JuliaC can exclude code proven not to be reachable from entry points, reducing binary size:
--trim=safe
On certain builds, --trim requires --experimental (JuliaC will pass it through if needed).
If you pass --compile-ccallable (or set ImageRecipe.add_ccallables = true), JuliaC will export ccallable entrypoints discovered in your code. This is often used when building libraries intended to be called from C or other languages.
clang or gcc available on PATHLazyArtifacts or JULIA_CCENV["JULIA_CC"] (e.g. clang/gcc path)JuliaC builds on PackageCompiler.jl and Julia's own build machinery. Many thanks to their authors and contributors.
Issues and PRs are welcome. Please provide OS, Julia version, and a minimal reproducer when reporting problems.
MIT. See the LICENSE file for details.
Julia
95.9%
C
4.1%