Skip to content

Commit

Permalink
add --compiled-modules=strict option (JuliaLang#52174)
Browse files Browse the repository at this point in the history
This is useful for ensuring that all modules were precompiled
successfully.
  • Loading branch information
simonbyrne committed Feb 10, 2024
1 parent a333f1c commit baa36e4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,10 @@ function _require(pkg::PkgId, env=nothing)
end
end

if JLOptions().use_compiled_modules == 3
error("Precompiled image $pkg not available with flags $(CacheFlags())")
end

# if the module being required was supposed to have a particular version
# but it was not handled by the precompile loader, complain
for (concrete_pkg, concrete_build_id) in _concrete_dependencies
Expand Down
1 change: 1 addition & 0 deletions base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ function julia_cmd(julia=joinpath(Sys.BINDIR, julia_exename()); cpu_target::Unio
opts.can_inline == 0 && push!(addflags, "--inline=no")
opts.use_compiled_modules == 0 && push!(addflags, "--compiled-modules=no")
opts.use_compiled_modules == 2 && push!(addflags, "--compiled-modules=existing")
opts.use_compiled_modules == 3 && push!(addflags, "--compiled-modules=strict")
opts.use_pkgimages == 0 && push!(addflags, "--pkgimages=no")
opts.use_pkgimages == 2 && push!(addflags, "--pkgimages=existing")
opts.opt_level == 2 || push!(addflags, "-O$(opts.opt_level)")
Expand Down
4 changes: 3 additions & 1 deletion doc/man/julia.1
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ Enable or disable Julia's default signal handlers
Use native code from system image if available

.TP
--compiled-modules={yes*|no|existing}
--compiled-modules={yes*|no|existing|strict}
Enable or disable incremental precompilation of modules.
The "existing" option allows use of existing compiled modules that were previously precompiled, but disallows creation of new precompile files.
The "strict" option is similar, but will error if no precompile file is found.

.TP
--pkgimages={yes*|no|existing}
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/command-line-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ The following is a complete list of command-line switches available when launchi
|`--startup-file={yes*\|no}` |Load `JULIA_DEPOT_PATH/config/startup.jl`; if [`JULIA_DEPOT_PATH`](@ref JULIA_DEPOT_PATH) environment variable is unset, load `~/.julia/config/startup.jl`|
|`--handle-signals={yes*\|no}` |Enable or disable Julia's default signal handlers|
|`--sysimage-native-code={yes*\|no}` |Use native code from system image if available|
|`--compiled-modules={yes*\|no\|existing}` |Enable or disable incremental precompilation of modules. The `existing` option allows use of existing compiled modules that were previously precompiled, but disallows creation of new precompile files.|
|`--compiled-modules={yes*\|no\|existing|strict}` |Enable or disable incremental precompilation of modules. The `existing` option allows use of existing compiled modules that were previously precompiled, but disallows creation of new precompile files. The `strict` option is similar, but will error if no precompile file is found. |
|`--pkgimages={yes*\|no}` |Enable or disable usage of native code caching in the form of pkgimages|
|`-e`, `--eval <expr>` |Evaluate `<expr>`|
|`-E`, `--print <expr>` |Evaluate `<expr>` and display the result|
Expand Down
6 changes: 4 additions & 2 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static const char opts[] =
" --handle-signals={yes*|no} Enable or disable Julia's default signal handlers\n"
" --sysimage-native-code={yes*|no}\n"
" Use native code from system image if available\n"
" --compiled-modules={yes*|no|existing}\n"
" --compiled-modules={yes*|no|existing|strict}\n"
" Enable or disable incremental precompilation of modules\n"
" --pkgimages={yes*|no|existing}\n"
" Enable or disable usage of native code caching in the form of pkgimages ($)\n\n"
Expand Down Expand Up @@ -464,8 +464,10 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
jl_options.use_compiled_modules = JL_OPTIONS_USE_COMPILED_MODULES_NO;
else if (!strcmp(optarg,"existing"))
jl_options.use_compiled_modules = JL_OPTIONS_USE_COMPILED_MODULES_EXISTING;
else if (!strcmp(optarg,"strict"))
jl_options.use_compiled_modules = JL_OPTIONS_USE_COMPILED_MODULES_STRICT;
else
jl_errorf("julia: invalid argument to --compiled-modules={yes|no|existing} (%s)", optarg);
jl_errorf("julia: invalid argument to --compiled-modules={yes|no|existing|strict} (%s)", optarg);
break;
case opt_pkgimages:
if (!strcmp(optarg,"yes"))
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -2489,6 +2489,7 @@ JL_DLLEXPORT int jl_generating_output(void) JL_NOTSAFEPOINT;
#define JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES 1
#define JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_NO 0

#define JL_OPTIONS_USE_COMPILED_MODULES_STRICT 3
#define JL_OPTIONS_USE_COMPILED_MODULES_EXISTING 2
#define JL_OPTIONS_USE_COMPILED_MODULES_YES 1
#define JL_OPTIONS_USE_COMPILED_MODULES_NO 0
Expand Down

0 comments on commit baa36e4

Please sign in to comment.