# Building Julia from source

**URL:** <https://discourse.julialang.org/t/building-julia-from-source/91747>\
**Category:** General Usage\
**Created:** [December 16, 2022, 3:38pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747 "2022-12-16T15:38:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 16, 2022, 3:38pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/1 "2022-12-16T15:38:05Z")

</div>

Hi,  
I have the following questions regarding building Julia from source:

1/ Is there a way to build a “light” version of Julia, for example without the documentation or even the REPL? If yes, how?

2/ Is there an option to add packages like DataFrames or CSV when building Julia to reduce functions compilations? If so how?  
(I know I can use PackageCompiler to build sysimage, just want to known if the above is possible)

Thank you  
Kind regards

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [December 16, 2022, 4:13pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/2 "2022-12-16T16:13:01Z")

</div>

Thoughts:

1. I have no idea how to do that simply and easily as the REPL is tied extremely to Julia.

2. Yes, you can do that using PackageCompiler (see example here: [Creating a sysimage with OhMyREPL · PackageCompiler](https://julialang.github.io/PackageCompiler.jl/stable/examples/ohmyrepl.html))

What’s your use case here?

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [December 16, 2022, 4:23pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/3 "2022-12-16T16:23:02Z")

</div>

Isn’t the REPL a standard library? If so, I think you can also filter out standard libraries when creating a custom sysimage. Again, not sure how useful Julia will be without the REPL though.

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 16, 2022, 4:34pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/4 "2022-12-16T16:34:20Z")

</div>

I know I can do that PackageCompiler, my question is more how to do it when I build Julia from source.  
No particular use case, it is just that it takes a lot of time to build Julia and I wanted to know if there is way to reduce that time by removing some part of the build process. Documentation and REPL are just example.

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 16, 2022, 4:37pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/5 "2022-12-16T16:37:14Z")

</div>

I can run a script by doing the following:  
julia my\_script.jl  
In that case I don’t need the REPL.

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [December 16, 2022, 4:42pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/6 "2022-12-16T16:42:53Z")

</div>

Oh got it. Sadly, I have no idea. 😞 Sorry! Are you trying to do some Julia development work?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [December 16, 2022, 4:44pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/7 "2022-12-16T16:44:57Z")

</div>

I don’t think this currently exists, but probably wouldn’t be too hard to add.

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 16, 2022, 4:47pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/8 "2022-12-16T16:47:30Z")

</div>

Yes, trying 😅

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 16, 2022, 4:48pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/9 "2022-12-16T16:48:36Z")

</div>

@Oscar_Smith , are you a core developer? I would be happy to add this functionality if you are happy to guide me.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [December 16, 2022, 6:05pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/10 "2022-12-16T18:05:24Z")

</div>

> [@gitboy16](#):
>
> I would be happy to add this functionality if you are happy to guide me.

I suspect your work would be made mostly useless by

> <https://github.com/JuliaLang/julia/pull/47184>
>
> 1. We split a cache file into two files
> 1. \`.ji\` contains a full-header and a…ll the source for Revise
> 2. pkimage/\`.so\` That contains all the data and the native code
> 2. During compilation we delay resolution of functions already present in a pkgimage
> This uses \`jl\_code\_instance\_t\` as the relocation key and emits a table into the binary code
> against which to later perform relocation.  
> 
> \## TODO:
> \- \[x\] Cleanup \`link\_image\_cmd\` 
> \- \[x\] Revisit what to hash on
> - Hash on objectcache enabled to minimize direct collision
> \- \[x\] Write out hash flags to header file so to verify 
> \- \[x\] Documentation
> \- \[x\] ? Distinct header for so vs ji? For \`jl\_validate\_cache\_file\`

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 16, 2022, 6:29pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/11 "2022-12-16T18:29:07Z")

</div>

If I understand correctly that would made package like DataFrames and CSV load faster as well as remove the need for re-compilation because the code (functions and objects) would be cached? Is that correct? If so that would solve the issue in my second question, however I am not sure to understand how it would make building Julia from source faster?

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 18, 2022, 8:30am UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/12 "2022-12-18T08:30:05Z")

</div>

I was wondering if someone would be able to provide further feedack or help on my questions?  
Thank you

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [December 18, 2022, 12:38pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/13 "2022-12-18T12:38:01Z")

</div>

Is it like running c or cpp code in terminal basically?

```julia
gcc test.cpp

```

gcc is the compiler for C++.

But you want to run julia file. thus

```julia
julia test.jl

```

Same things to obtain same results, but different languages. Different computation time.

If you want a plot and computation, yes you don’t need REPL indeed, because you just need to make `Plots` / `PyPlot` / `GLMakie` showing the window like `gnuplot` show the plot of your code in other language. The details need hard work.

---

<div class="post-metadata">

**Author:** ![woclass](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/woclass/32/212699_2.png) [@woclass](https://discourse.julialang.org/u/woclass)\
**Post date:** [December 18, 2022, 12:44pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/14 "2022-12-18T12:44:58Z")

</div>

> [@gitboy16](#):
>
> 1/ Is there a way to build a “light” version of Julia, for example without the documentation or even the REPL? If yes, how?

“without the documentation”

If you just `make`, the document will not be built.  
The documentation will only be built when you execute `make docs`.

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 18, 2022, 2:28pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/15 "2022-12-18T14:28:19Z")

</div>

Thank you @woclass, And what shoukd I do if I wanted to remove the REPL module from the build process or if I wanted to add a module to the build process?

---

<div class="post-metadata">

**Author:** ![woclass](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/woclass/32/212699_2.png) [@woclass](https://discourse.julialang.org/u/woclass)\
**Post date:** [December 18, 2022, 2:34pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/16 "2022-12-18T14:34:31Z")

</div>

I haven’t tried to add or remove the standard library, but you can take a look at this pr.

It looks like two main changes were made:

- Remove the symbol in `base/sysimg.jl`
- Remove the associated test

> <https://github.com/JuliaLang/julia/pull/45594/files>
>
> And remove uses of it in the manual and tests.
> 
> Follow-up from https://github.…com/JuliaLang/julia/pull/44247. Should probably run PkgEval if the PR looks OK.
> 
> I'd suggest trying this, and only move \`mean\` and/or \`std\` to Base if people complain too loudly before 1.9 is released. Personally I would rather keep these in Statistics to be group statistics function in a single package at last (merging with StatsBase). This makes sense e.g. because these have methods taking weight vectors that we have considered turning into a keyword argument. Also \`std\` relies on \`var\` so these cannot really be separated.

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 18, 2022, 2:48pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/17 "2022-12-18T14:48:17Z")

</div>

Thank you @woclass . That’s helpful!

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [December 18, 2022, 3:48pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/18 "2022-12-18T15:48:22Z")

</div>

> [@gitboy16](#):
>
> there

Yes, add a `base/userimg.jl` [System Image Building · The Julia Language](https://docs.julialang.org/en/v1/devdocs/sysimg/)

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [December 18, 2022, 7:40pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/19 "2022-12-18T19:40:33Z")

</div>

Thank you @Elrod , so not sure to understand what goes inside that userimg.jl file.  
For example let’s say I just created a module called ABC and I want to include it when building Julia from source. Then I should:

- include my module ABC.jl in the directory base/
- add a file called userimg.jl in that same folder
- in the file userimg.jl write the following line of code `include(“ABC.jl”)
- then build Julia from source by running `make`

Is that correct?

If so, what about including package CSV and DataFrames? Should I include them in the same base/ folder? What about their dependencies? Are these automatically taken into account?

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [December 18, 2022, 9:54pm UTC](https://discourse.julialang.org/t/building-julia-from-source/91747/20 "2022-12-18T21:54:08Z")

</div>

> [@gitboy16](#):
>
> Is that correct?

I hadn’t tried that before, but sounds like it should work.

> [@gitboy16](#):
>
> what about including package CSV and DataFrames?

This I have done. Simply `using CSV, DataFrames` works.  
You can do more than this, executing a few commands. However, there are a lot of things that won’t work (`using OhMyREPL`, for example, does not), so I suggest you start minimally.  
Installing packages also will not work inside your `userimg.jl`, therefore they will already have to be installed.  
Activating a project does work.  
So make sure you have some project in which the packages you wish to use have already been installed for the Julia version you’re building, and then

```julia
using Pkg
Pkg.activate("/path/to/that/project")
using CSV, DataFrames, OtherPackage

```

should work.

If you’re using Julia’s master branch, I definitely suggest you checkout

> <https://github.com/JuliaLang/julia/pull/47184>
>
> 1. We split a cache file into two files
> 1. \`.ji\` contains a full-header and a…ll the source for Revise
> 2. pkimage/\`.so\` That contains all the data and the native code
> 2. During compilation we delay resolution of functions already present in a pkgimage
> This uses \`jl\_code\_instance\_t\` as the relocation key and emits a table into the binary code
> against which to later perform relocation.  
> 
> \## TODO:
> \- \[x\] Cleanup \`link\_image\_cmd\` 
> \- \[x\] Revisit what to hash on
> - Hash on objectcache enabled to minimize direct collision
> \- \[x\] Write out hash flags to header file so to verify 
> \- \[x\] Documentation
> \- \[x\] ? Distinct header for so vs ji? For \`jl\_validate\_cache\_file\`

which was linked by @giordano earlier.  
The benefit putting a package in your `userimg.jl` has is that it almost eliminates `using` time, which that PR does not.

[Next page](https://discourse.julialang.org/t/building-julia-from-source/91747.md?page=2)
