I have a multi-stage centos7-based dockerfile that has Julia 1.5.3 installed to /root/julia in the image base
. PackageCompiler is v1.2.4 for this.
Here is the relevant part:
#################### cleaned_repo #####################
# This strips out the non-toml files in `cleaned_repo` to avoid changes unrelated to dependencies (this stage will always be hit).
FROM base AS cleaned_repo
LABEL description="Filter to only .toml files for building the sysimage"
RUN mkdir -p /root/myproj.jl
WORKDIR /root/myproj.jl
COPY . .
RUN find -mindepth 1 -maxdepth 1 -type f -not -name "*.toml" -exec rm -rf {} \;
RUN find -mindepth 2 -maxdepth 2 -not -name "*.toml" -not -name "bake_sysimage.jl" -exec rm -rf {} \;
###################### sysimage #######################
# This copies that skeletal repository into `sysimage` and builds the sysimage using the set of remote dependencies involved.
# If the remaining files have not changed (no dependency changes) then this stage will hit the cache and save ~35 minutes of build time.
FROM base AS sysimage
LABEL description="Builds sysimage from filtered repo"
RUN mkdir -p /root/myproj.jl
WORKDIR /root/myproj.jl
COPY --from=cleaned_repo /root/myproj.jl/. .
RUN source scl_source enable devtoolset-9 && julia scripts/bake_sysimage.jl
RUN rm -rf /root/myproj.jl
###################### prod_julia #####################
# Following that, it compiles the local code into an app using `incremental=true`
FROM sysimage AS prod_julia
LABEL description="Compiles julia code"
RUN mkdir -p /root/myproj.jl
WORKDIR /root/myproj.jl
COPY . .
RUN sh /root/scl_enable.sh julia scripts/compile_app.jl
The intent here is to avoid recompiling the dependencies (sysimage
stage, >30 minutes) for every code change in MyProj.
Unfortunately, it fails on the prod_julia
stage with the error:
#23 347.7 [ Info: PackageCompiler: creating system image object file, this might take a while...
#23 347.7 ERROR: Unable to find compatible target in system image.
#23 348.8 ERROR: LoadError: failed process: Process(`/root/julia/bin/julia --color=yes --startup-file=no '--cpu-target=generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)' --sysimage=/root/julia/lib/julia/sys.so --project=/root/myproj.jl/inner.jl --output-o=/tmp/jl_UGJKKB.o -e '...'`, ProcessSignaled(11))
I can replicate this locally using the sysimage stage even when swapping the '...'
code for 'println("hi")'
. However, I would expect the CPU target to be the same for both stages considering I don’t provide it and the builds happen on the same machine.
If I switch the code to 'println("hi")'
and also remove the --cpu-target
argument, then it gives me a segfault(11). If I also remove the --object-o
argument, it prints “hi” as intended. Removing the --object-o
argument while leaving the --cpu-target
argument, causes the original error again.