Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename --precompiled and --compilecache command line options #23616

Merged
merged 1 commit into from
Sep 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ Command-line option changes
The `--quiet` option implies `--banner=no` even in REPL mode but can be overridden by
passing `--quiet` together with `--banner=yes` ([#23342]).

* The option `--precompiled` has been renamed to `--sysimage-native-code` ([#23054]).

* The option `--compilecache` has been renamed to `--compiled-modules` ([#23054]).

Julia v0.6.0 Release Notes
==========================

Expand Down
6 changes: 3 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ order to throw an error if Julia attempts to precompile it.
using `__precompile__()`. Failure to do so can result in a runtime error when loading the module.
"""
function __precompile__(isprecompilable::Bool=true)
if (JLOptions().use_compilecache != 0 &&
if (JLOptions().use_compiled_modules != 0 &&
isprecompilable != (0 != ccall(:jl_generating_output, Cint, ())) &&
!(isprecompilable && toplevel_load[]))
throw(PrecompilableError(isprecompilable))
Expand Down Expand Up @@ -361,7 +361,7 @@ function _require(mod::Symbol)

# attempt to load the module file via the precompile cache locations
doneprecompile = false
if JLOptions().use_compilecache != 0
if JLOptions().use_compiled_modules != 0
doneprecompile = _require_search_from_serialized(mod, path)
if !isa(doneprecompile, Bool)
return # success
Expand Down Expand Up @@ -400,7 +400,7 @@ function _require(mod::Symbol)
try
Base.include_relative(Main, path)
catch ex
if doneprecompile === true || JLOptions().use_compilecache == 0 || !precompilableerror(ex, true)
if doneprecompile === true || JLOptions().use_compiled_modules == 0 || !precompilableerror(ex, true)
rethrow() # rethrow non-precompilable=true errors
end
# the file requested `__precompile__`, so try to build a cache file and use that
Expand Down
4 changes: 2 additions & 2 deletions base/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ struct JLOptions
worker::Int8
cookie::Ptr{UInt8}
handle_signals::Int8
use_precompiled::Int8
use_compilecache::Int8
use_sysimage_native_code::Int8
use_compiled_modules::Int8
bindto::Ptr{UInt8}
outputbc::Ptr{UInt8}
outputunoptbc::Ptr{UInt8}
Expand Down
4 changes: 2 additions & 2 deletions base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ function build(pkg::AbstractString, build_file::AbstractString, errfile::Abstrac
cmd = ```
$(Base.julia_cmd()) -O0
--color=$(Base.have_color ? "yes" : "no")
--compilecache=$(Bool(Base.JLOptions().use_compilecache) ? "yes" : "no")
--compiled-modules=$(Bool(Base.JLOptions().use_compiled_modules) ? "yes" : "no")
--history-file=no
--startup-file=$(Base.JLOptions().startupfile != 2 ? "yes" : "no")
--eval $code
Expand Down Expand Up @@ -717,7 +717,7 @@ function test!(pkg::AbstractString,
$(Base.julia_cmd())
--code-coverage=$(coverage ? "user" : "none")
--color=$(Base.have_color ? "yes" : "no")
--compilecache=$(Bool(Base.JLOptions().use_compilecache) ? "yes" : "no")
--compiled-modules=$(Bool(Base.JLOptions().use_compiled_modules) ? "yes" : "no")
--check-bounds=yes
--warn-overwrite=yes
--startup-file=$(Base.JLOptions().startupfile != 2 ? "yes" : "no")
Expand Down
12 changes: 7 additions & 5 deletions doc/src/manual/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ julia [switches] -- [programfile] [args...]
-h, --help Print this message

-J, --sysimage <file> Start up with the given system image file
--precompiled={yes|no} Use precompiled code from system image if available
--compilecache={yes|no} Enable/disable incremental precompilation of modules
-H, --home <dir> Set location of `julia` executable
--startup-file={yes|no} Load ~/.juliarc.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}
Enable or disable incremental precompilation of modules

-e, --eval <expr> Evaluate <expr>
-E, --print <expr> Evaluate and show <expr>
Expand All @@ -118,6 +120,9 @@ julia [switches] -- [programfile] [args...]
--color={yes|no} Enable or disable color text
--history-file={yes|no} Load or save history

--depwarn={yes|no|error} Enable or disable syntax and method deprecation warnings ("error" turns warnings into errors)
--warn-overwrite={yes|no} Enable or disable method overwrite warnings

--compile={yes|no|all|min}Enable or disable JIT compiler, or request exhaustive compilation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appears that we should add a couple spaces, or split this one over multiple lines?

-C, --cpu-target <target> Limit usage of cpu features up to <target>
-O, --optimize={0,1,2,3} Set the optimization level (default is 2 if unspecified or 3 if specified as -O)
Expand All @@ -126,9 +131,6 @@ julia [switches] -- [programfile] [args...]
--check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations)
--math-mode={ieee,fast} Disallow or enable unsafe floating point optimizations (overrides @fastmath declaration)

--depwarn={yes|no|error} Enable or disable syntax and method deprecation warnings ("error" turns warnings into errors)
--warn-overwrite={yes|no} Enable or disable method overwrite warnings

--output-o name Generate an object file (including system image data)
--output-ji name Generate a system image data file (.ji)
--output-bc name Generate LLVM bitcode (.bc)
Expand Down
4 changes: 2 additions & 2 deletions doc/src/manual/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ A few other points to be aware of:
of these and to create a single unique instance of others.

It is sometimes helpful during module development to turn off incremental precompilation. The
command line flag `--compilecache={yes|no}` enables you to toggle module precompilation on and
off. When Julia is started with `--compilecache=no` the serialized modules in the compile cache
command line flag `--compiled-modules={yes|no}` enables you to toggle module precompilation on and
off. When Julia is started with `--compiled-modules=no` the serialized modules in the compile cache
are ignored when loading modules and module dependencies. `Base.compilecache` can still be called
manually and it will respect `__precompile__()` directives for the module. The state of this command
line flag is passed to [`Pkg.build`](@ref) to disable automatic precompilation triggering when installing,
Expand Down
48 changes: 30 additions & 18 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ jl_options_t jl_options = { 0, // quiet
0, // worker
NULL, // cookie
JL_OPTIONS_HANDLE_SIGNALS_ON,
JL_OPTIONS_USE_PRECOMPILED_YES,
JL_OPTIONS_USE_COMPILECACHE_YES,
JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES,
JL_OPTIONS_USE_COMPILED_MODULES_YES,
NULL, // bind-to
NULL, // output-bc
NULL, // output-unopt-bc
Expand All @@ -86,11 +86,13 @@ static const char opts[] =

// startup options
" -J, --sysimage <file> Start up with the given system image file\n"
" --precompiled={yes|no} Use precompiled code from system image if available\n"
" --compilecache={yes|no} Enable/disable incremental precompilation of modules\n"
" -H, --home <dir> Set location of `julia` executable\n"
" --startup-file={yes|no} Load ~/.juliarc.jl\n"
" --handle-signals={yes|no} Enable or disable Julia's default signal handlers\n\n"
" --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}\n"
" Enable or disable incremental precompilation of modules\n\n"

// actions
" -e, --eval <expr> Evaluate <expr>\n"
Expand All @@ -109,6 +111,10 @@ static const char opts[] =
" --color={yes|no} Enable or disable color text\n"
" --history-file={yes|no} Load or save history\n\n"

// error and warning options
" --depwarn={yes|no|error} Enable or disable syntax and method deprecation warnings (\"error\" turns warnings into errors)\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we name this --warn-deprecations? (doesn't need to be the same PR though)

" --warn-overwrite={yes|no} Enable or disable method overwrite warnings\n\n"

// code generation options
" --compile={yes|no|all|min}Enable or disable JIT compiler, or request exhaustive compilation\n"
" -C, --cpu-target <target> Limit usage of cpu features up to <target>; set to \"help\" to see the available options\n"
Expand All @@ -126,10 +132,6 @@ static const char opts[] =
#endif
" --math-mode={ieee,fast} Disallow or enable unsafe floating point optimizations (overrides @fastmath declaration)\n\n"

// error and warning options
" --depwarn={yes|no|error} Enable or disable syntax and method deprecation warnings (\"error\" turns warnings into errors)\n\n"
" --warn-overwrite={yes|no} Enable or disable method overwrite warnings"

// compiler output options
" --output-o name Generate an object file (including system image data)\n"
" --output-ji name Generate a system image data file (.ji)\n"
Expand Down Expand Up @@ -174,7 +176,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
opt_use_precompiled,
opt_use_compilecache,
opt_incremental,
opt_banner
opt_banner,
opt_sysimage_native_code,
opt_compiled_modules
};
static const char* const shortopts = "+vhqH:e:E:L:J:C:ip:O:g:";
static const struct option longopts[] = {
Expand All @@ -190,8 +194,10 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
{ "print", required_argument, 0, 'E' },
{ "load", required_argument, 0, 'L' },
{ "sysimage", required_argument, 0, 'J' },
{ "precompiled", required_argument, 0, opt_use_precompiled },
{ "compilecache", required_argument, 0, opt_use_compilecache },
{ "precompiled", required_argument, 0, opt_use_precompiled }, // deprecated
{ "sysimage-native-code", required_argument, 0, opt_sysimage_native_code },
{ "compilecache", required_argument, 0, opt_use_compilecache }, // deprecated
{ "compiled-modules", required_argument, 0, opt_compiled_modules },
{ "cpu-target", required_argument, 0, 'C' },
{ "procs", required_argument, 0, 'p' },
{ "machinefile", required_argument, 0, opt_machinefile },
Expand Down Expand Up @@ -331,20 +337,26 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
jl_errorf("julia: invalid argument to --banner={yes|no} (%s)", optarg);
break;
case opt_use_precompiled:
jl_printf(JL_STDOUT, "WARNING: julia --precompiled option is deprecated, use --sysimage-native-code instead.\n");
// fall through
case opt_sysimage_native_code:
if (!strcmp(optarg,"yes"))
jl_options.use_precompiled = JL_OPTIONS_USE_PRECOMPILED_YES;
jl_options.use_sysimage_native_code = JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES;
else if (!strcmp(optarg,"no"))
jl_options.use_precompiled = JL_OPTIONS_USE_PRECOMPILED_NO;
jl_options.use_sysimage_native_code = JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_NO;
else
jl_errorf("julia: invalid argument to --precompiled={yes|no} (%s)", optarg);
jl_errorf("julia: invalid argument to --sysimage-native-code={yes|no} (%s)", optarg);
break;
case opt_use_compilecache:
jl_printf(JL_STDOUT, "WARNING: julia --compilecache option is deprecated, use --compiled-modules instead.\n");
// fall through
case opt_compiled_modules:
if (!strcmp(optarg,"yes"))
jl_options.use_compilecache = JL_OPTIONS_USE_COMPILECACHE_YES;
jl_options.use_compiled_modules = JL_OPTIONS_USE_COMPILED_MODULES_YES;
else if (!strcmp(optarg,"no"))
jl_options.use_compilecache = JL_OPTIONS_USE_COMPILECACHE_NO;
jl_options.use_compiled_modules = JL_OPTIONS_USE_COMPILED_MODULES_NO;
else
jl_errorf("julia: invalid argument to --compilecache={yes|no} (%s)", optarg);
jl_errorf("julia: invalid argument to --compiled-modules={yes|no} (%s)", optarg);
break;
case 'C': // cpu-target
jl_options.cpu_target = strdup(optarg);
Expand Down
12 changes: 6 additions & 6 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1702,8 +1702,8 @@ typedef struct {
int8_t worker;
const char *cookie;
int8_t handle_signals;
int8_t use_precompiled;
int8_t use_compilecache;
int8_t use_sysimage_native_code;
int8_t use_compiled_modules;
const char *bindto;
const char *outputbc;
const char *outputunoptbc;
Expand Down Expand Up @@ -1769,11 +1769,11 @@ JL_DLLEXPORT int jl_generating_output(void);
#define JL_OPTIONS_HANDLE_SIGNALS_ON 1
#define JL_OPTIONS_HANDLE_SIGNALS_OFF 0

#define JL_OPTIONS_USE_PRECOMPILED_YES 1
#define JL_OPTIONS_USE_PRECOMPILED_NO 0
#define JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES 1
#define JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_NO 0

#define JL_OPTIONS_USE_COMPILECACHE_YES 1
#define JL_OPTIONS_USE_COMPILECACHE_NO 0
#define JL_OPTIONS_USE_COMPILED_MODULES_YES 1
#define JL_OPTIONS_USE_COMPILED_MODULES_NO 0

// Version information
#include "julia_version.h"
Expand Down
2 changes: 1 addition & 1 deletion src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static void jl_load_sysimg_so(void)
#endif
int imaging_mode = jl_generating_output() && !jl_options.incremental;
// in --build mode only use sysimg data, not precompiled native code
if (!imaging_mode && jl_options.use_precompiled==JL_OPTIONS_USE_PRECOMPILED_YES) {
if (!imaging_mode && jl_options.use_sysimage_native_code==JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES) {
sysimg_gvars_base = (uintptr_t*)jl_dlsym(jl_sysimg_handle, "jl_sysimg_gvars_base");
sysimg_gvars_offsets = (const int32_t*)jl_dlsym(jl_sysimg_handle,
"jl_sysimg_gvars_offsets");
Expand Down
34 changes: 17 additions & 17 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if Sys.iswindows()
end
end

let exename = `$(Base.julia_cmd()) --precompiled=yes --startup-file=no`
let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no`
# --version
let v = split(read(`$exename -v`, String), "julia version ")[end]
@test Base.VERSION_STRING == chomp(v)
Expand Down Expand Up @@ -75,8 +75,8 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes --startup-file=no`
# --cpu-target
# NOTE: this test only holds true if image_file is a shared library.
if Libdl.dlopen_e(unsafe_string(Base.JLOptions().image_file)) != C_NULL
@test !success(`$exename -C invalidtarget --precompiled=yes`)
@test !success(`$exename --cpu-target=invalidtarget --precompiled=yes`)
@test !success(`$exename -C invalidtarget --sysimage-native-code=yes`)
@test !success(`$exename --cpu-target=invalidtarget --sysimage-native-code=yes`)
else
warn("--cpu-target test not runnable")
end
Expand Down Expand Up @@ -342,13 +342,13 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes --startup-file=no`
@test readchomp(pipeline(ignorestatus(`$exename --startup-file=no -e "@show ARGS" -now -- julia RUN.jl`),
stderr=catcmd)) == "ERROR: unknown option `-n`"

# --compilecache={yes|no}
@test readchomp(`$exename -E "Bool(Base.JLOptions().use_compilecache)"`) == "true"
@test readchomp(`$exename --compilecache=yes -E
"Bool(Base.JLOptions().use_compilecache)"`) == "true"
@test readchomp(`$exename --compilecache=no -E
"Bool(Base.JLOptions().use_compilecache)"`) == "false"
@test !success(`$exename --compilecache=foo -e "exit(0)"`)
# --compiled-modules={yes|no}
@test readchomp(`$exename -E "Bool(Base.JLOptions().use_compiled_modules)"`) == "true"
@test readchomp(`$exename --compiled-modules=yes -E
"Bool(Base.JLOptions().use_compiled_modules)"`) == "true"
@test readchomp(`$exename --compiled-modules=no -E
"Bool(Base.JLOptions().use_compiled_modules)"`) == "false"
@test !success(`$exename --compiled-modules=foo -e "exit(0)"`)

# issue #12671, starting from a non-directory
# rm(dir) fails on windows with Permission denied
Expand Down Expand Up @@ -399,7 +399,7 @@ let exename = joinpath(JULIA_HOME, Base.julia_exename()),
end
end

let exename = `$(Base.julia_cmd()) --precompiled=yes`
let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes`
# --startup-file
let JL_OPTIONS_STARTUPFILE_ON = 1,
JL_OPTIONS_STARTUPFILE_OFF = 2
Expand All @@ -422,17 +422,17 @@ run(pipeline(DevNull, `$(joinpath(JULIA_HOME, Base.julia_exename())) --lisp`, De
@test_throws ErrorException run(pipeline(DevNull, pipeline(`$(joinpath(JULIA_HOME,
Base.julia_exename())) -Cnative --lisp`, stderr=DevNull), DevNull))

# --precompiled={yes|no}
# --sysimage-native-code={yes|no}
let exename = `$(Base.julia_cmd()) --startup-file=no`
@test readchomp(`$exename --precompiled=yes -E
"Bool(Base.JLOptions().use_precompiled)"`) == "true"
@test readchomp(`$exename --precompiled=no -E
"Bool(Base.JLOptions().use_precompiled)"`) == "false"
@test readchomp(`$exename --sysimage-native-code=yes -E
"Bool(Base.JLOptions().use_sysimage_native_code)"`) == "true"
@test readchomp(`$exename --sysimage-native-code=no -E
"Bool(Base.JLOptions().use_sysimage_native_code)"`) == "false"
end

# backtrace contains type and line number info (esp. on windows #17179)
for precomp in ("yes", "no")
bt = read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --precompiled=$precomp
bt = read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --sysimage-native-code=$precomp
-E 'include("____nonexistent_file")'`), stderr=catcmd), String)
@test contains(bt, "include_relative(::Module, ::String) at $(joinpath(".", "loading.jl"))")
lno = match(r"at \.[\/\\]loading\.jl:(\d+)", bt)
Expand Down
12 changes: 6 additions & 6 deletions test/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ finally
rm(dir2, recursive=true)
end

# test --compilecache=no command line option
# test --compiled-modules=no command line option
let dir = mktempdir(),
Time_module = :Time4b3a94a1a081a8cb

Expand All @@ -406,7 +406,7 @@ let dir = mktempdir(),
Base.compilecache(:Time4b3a94a1a081a8cb)
end)

exename = `$(Base.julia_cmd()) --precompiled=yes --startup-file=no`
exename = `$(Base.julia_cmd()) --compiled-modules=yes --startup-file=no`

testcode = """
insert!(LOAD_PATH, 1, $(repr(dir)))
Expand All @@ -415,12 +415,12 @@ let dir = mktempdir(),
getfield($Time_module, :time)
"""

t1_yes = readchomp(`$exename --compilecache=yes -E $(testcode)`)
t2_yes = readchomp(`$exename --compilecache=yes -E $(testcode)`)
t1_yes = readchomp(`$exename --compiled-modules=yes -E $(testcode)`)
t2_yes = readchomp(`$exename --compiled-modules=yes -E $(testcode)`)
@test t1_yes == t2_yes

t1_no = readchomp(`$exename --compilecache=no -E $(testcode)`)
t2_no = readchomp(`$exename --compilecache=no -E $(testcode)`)
t1_no = readchomp(`$exename --compiled-modules=no -E $(testcode)`)
t2_no = readchomp(`$exename --compiled-modules=no -E $(testcode)`)
@test t1_no != t2_no
@test parse(Float64, t1_no) < parse(Float64, t2_no)

Expand Down
2 changes: 1 addition & 1 deletion test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ include_string_test_func = include_string(@__MODULE__, "include_string_test() =

@test isdir(@__DIR__)
@test @__DIR__() == dirname(@__FILE__)
let exename = `$(Base.julia_cmd()) --precompiled=yes --startup-file=no`,
let exename = `$(Base.julia_cmd()) --compiled-modules=yes --startup-file=no`,
wd = sprint(show, abspath(pwd(), "")),
s_dir = sprint(show, joinpath(realpath(tempdir()), ""))
@test wd != s_dir
Expand Down
Loading