How do I create a binary from .jl files?

Well, PackageCompiler.jl is not immature at all.

1 Like

Here are a few videos on how to use PackageCompiler.jl to create binary executables and shared libraries.

The documentation for this can be found below:

As for the REPL, if you do not want to use for its interactive features, I would consider using it as a development tool that implements a compilation cache.

3 Likes

PackageCompiler is amazing. But it’s also slow and creates truly enormous binaries. If you’re used to compiling go there will be no comparison. We need to be honest about that so peoples expectations will match reality.

13 Likes

Especially when the actual goal in this case appears to not be compilation but rather code organization.

6 Likes

Well, I am working on a C/C++ project with compilation times not below a few hours. Compared to that PackageCompiler is fast. And there is no need to run it after every change, I run it perhaps every other day and it takes never more than 15 minutes.

2 Likes

I am not using the .julia/dev folder. Instead, I have a repos folder where I check out my git projects. A complex Julia project usually consists of a number of related packages and (perhaps) a main project which is not a package. For me this looks like this:

ufechner@tuxedi:~/repos$ tree -d Kite*
KiteControllers.jl
β”œβ”€β”€ data
β”œβ”€β”€ doc
β”œβ”€β”€ src
└── test
KiteModels.jl
β”œβ”€β”€ bin
β”œβ”€β”€ data
β”œβ”€β”€ docs
β”‚   β”œβ”€β”€ build
β”‚   β”‚   └── assets
β”‚   β”‚       └── themes
β”‚   β”œβ”€β”€ data
β”‚   └── src
β”‚       └── assets
β”œβ”€β”€ examples
β”œβ”€β”€ src
└── test
KiteUtils.jl
β”œβ”€β”€ data
β”œβ”€β”€ docs
β”‚   └── src
β”œβ”€β”€ src
└── test
KiteViewer
β”œβ”€β”€ data
β”œβ”€β”€ doc
β”œβ”€β”€ src
└── test
KiteViewers.jl
β”œβ”€β”€ bin
β”œβ”€β”€ data
β”œβ”€β”€ examples
β”œβ”€β”€ src
└── test

30 directories

3 Likes

I’m curious how large the actual C++ code is and if parallel compilation is used? I’ve only ever had one multi-hour compilation (and have built quite a few C++ packages over the years) and that’s ParaView, which is a humongous build when its dependencies are included. Not trying to say you don’t have a multi-hour build, just trying to understand what kind of project you’re refering to.

Edit: this I don’t understand. C++ builds can easily to incremental compilation, saving lots of time, while with PackageCompiler that seems almost impossible (unless you build separate sysimages for subsets manually).

1 Like

We are using Buildroot to create a system image for an embedded system. We have a fast machine with 16 cores and use ccache. And incremental builds often do NOT work if you use Buildroot (sometimes they work).

Well, I use PackageCompiler mainly to compile the packages I am currently NOT working at. The package I currently work at gets pre-compiled on load and compiled when running a function, but this usually only takes a few seconds, worst case 10 seconds.

2 Likes

Not my experience, and from what I hear having things break with minor versions is very rare (if it in fact happens at all).

Sorry, this is nonsense. Julia has great dependency management, and if you insist on building a static executable, you are probably not using the language efficiently.

8 Likes

No need to be inflammatory. I use Julia on my PhD and used it for my internship at Amazon (as an Applied Scientist). I consider it to be a mature language. It is just not designed with compilation to a binary in mind, as many other languages were not. Even so, it has packages that allow for it if it is strictly necessary.

5 Likes

@PetrKryslUCSD

All I’ve seen in example material are things like

] add MLDatasets
using MLDatasets

with no versioning at all. No one seems to mention dependency management. I’ve yet to hear any Julia intro material mention transitive dependencies.

Example 4 here 3. Managing Packages Β· Pkg.jl

Perhaps 3. Managing Packages Β· Pkg.jl
and 6. Compatibility Β· Pkg.jl

6 Likes

The versioning may be done via Project.toml/Manifest.toml. It is not necessarily spelled out in the command line.

2 Likes

If you wanted to do spell it out on the command line, that is also very possible by appending @major.minor.patch. The default is to try to obtain the latest version that is also compatible with your current environment settings.

(@v1.7) pkg> ?add
  add [--preserve=<opt>] pkg[=uuid] [@version] [#rev] ...

  Add package pkg to the current project file. If pkg could refer to multiple different packages, specifying uuid
  allows you to disambiguate. @version optionally allows specifying which versions of packages to add. Version
  specifications are of the form @1, @1.2 or @1.2.3, allowing any version with a prefix that matches, or ranges
  thereof, such as @1.2-3.4.5. A git revision can be specified by #branch or #commit.

  If a local path is used as an argument to add, the path needs to be a git repository. The project will then track
  that git repository just like it would track a remote repository online. If the package is not located at the top of
  the git repository, a subdirectory can be specified with path:subdir/path.

  Pkg resolves the set of packages in your environment using a tiered approach. The --preserve command line option
  allows you to key into a specific tier in the resolve algorithm. The following table describes the command line
  arguments to --preserve (in order of strictness).

  Argument Description
  –––––––– –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  all      Preserve the state of all existing dependencies (including recursive dependencies)
  direct   Preserve the state of all existing direct dependencies
  semver   Preserve semver-compatible versions of direct dependencies
  none     Do not attempt to preserve any version information
  tiered   Use the tier which will preserve the most version information (this is the default)

  β”‚ Julia 1.5
  β”‚
  β”‚  Subdirectory specification requires at least Julia 1.5.

  Examples

  pkg> add Example
  pkg> add --preserve=all Example
  pkg> add Example@0.5
  pkg> add Example#master
  pkg> add Example#c37b675
  pkg> add https://github.com/JuliaLang/Example.jl#master
  pkg> add git@github.com:JuliaLang/Example.jl.git
  pkg> add Example=7876af07-990d-54b4-ab0e-23690620f79a

See the Pkg.jl links above for more information.

2 Likes

Well, in the last year I had twice the situation that a specific package version was broken and I had to manually select an older version. This happened with StaticArrays and with Rotatations…