Skip to content

Commit c5899c2

Browse files
authored
cli: Add required --experimental flag for experimental features (e.g. --trim) (JuliaLang#56045)
The intention here is to clearly signal when a feature is "not yet fully implemented" vs. "feature-complete and in pre-release" vs. "fully released and ready for production use" The only feature gated behind this right now is `--trim`. Trim has its core functionality implemented (and folks seem to be enjoying it!) but the deployment / linking story in particular is still in its very early stages, esp. because our existing techniques for, e.g., pre-loading `libunwind`, `libstdc++`, etc. no longer work in a shared library context. Once `--trim` is ready for a broader chunk of the ecosystem / language, we can peel off the `--experimental` flag
1 parent deac82a commit c5899c2

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

base/options.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct JLOptions
3939
worker::Int8
4040
cookie::Ptr{UInt8}
4141
handle_signals::Int8
42+
use_experimental_features::Int8
4243
use_sysimage_native_code::Int8
4344
use_compiled_modules::Int8
4445
use_pkgimages::Int8

src/jloptions.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ JL_DLLEXPORT void jl_init_options(void)
130130
0, // worker
131131
NULL, // cookie
132132
JL_OPTIONS_HANDLE_SIGNALS_ON,
133+
JL_OPTIONS_USE_EXPERIMENTAL_FEATURES_NO,
133134
JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES,
134135
JL_OPTIONS_USE_COMPILED_MODULES_YES,
135136
JL_OPTIONS_USE_PKGIMAGES_YES,
@@ -150,7 +151,7 @@ JL_DLLEXPORT void jl_init_options(void)
150151
0, // permalloc_pkgimg
151152
0, // heap-size-hint
152153
0, // trace_compile_timing
153-
0, // trim
154+
JL_TRIM_NO, // trim
154155
};
155156
jl_options_initialized = 1;
156157
}
@@ -303,6 +304,7 @@ static const char opts_hidden[] =
303304
" functions\n\n"
304305

305306
// compiler debugging and experimental (see the devdocs for tips on using these options)
307+
" --experimental Enable the use of experimental (alpha) features\n"
306308
" --output-unopt-bc <name> Generate unoptimized LLVM bitcode (.bc)\n"
307309
" --output-bc <name> Generate LLVM bitcode (.bc)\n"
308310
" --output-asm <name> Generate an assembly file (.s)\n"
@@ -372,6 +374,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
372374
opt_gc_threads,
373375
opt_permalloc_pkgimg,
374376
opt_trim,
377+
opt_experimental_features,
375378
};
376379
static const char* const shortopts = "+vhqH:e:E:L:J:C:it:p:O:g:m:";
377380
static const struct option longopts[] = {
@@ -427,6 +430,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
427430
{ "math-mode", required_argument, 0, opt_math_mode },
428431
{ "handle-signals", required_argument, 0, opt_handle_signals },
429432
// hidden command line options
433+
{ "experimental", no_argument, 0, opt_experimental_features },
430434
{ "worker", optional_argument, 0, opt_worker },
431435
{ "bind-to", required_argument, 0, opt_bind_to },
432436
{ "lisp", no_argument, 0, 1 },
@@ -570,6 +574,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
570574
else
571575
jl_errorf("julia: invalid argument to --banner={yes|no|auto|short} (%s)", optarg);
572576
break;
577+
case opt_experimental_features:
578+
jl_options.use_experimental_features = JL_OPTIONS_USE_EXPERIMENTAL_FEATURES_YES;
579+
break;
573580
case opt_sysimage_native_code:
574581
if (!strcmp(optarg,"yes"))
575582
jl_options.use_sysimage_native_code = JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES;
@@ -977,6 +984,10 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
977984
}
978985
}
979986
parsing_args_done:
987+
if (!jl_options.use_experimental_features) {
988+
if (jl_options.trim != JL_TRIM_NO)
989+
jl_errorf("julia: --trim is an experimental feature, you must enable it with --experimental");
990+
}
980991
jl_options.code_coverage = codecov;
981992
jl_options.malloc_log = malloclog;
982993
int proc_args = *argcp < optind ? *argcp : optind;

src/jloptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ typedef struct {
4343
int8_t worker;
4444
const char *cookie;
4545
int8_t handle_signals;
46+
int8_t use_experimental_features;
4647
int8_t use_sysimage_native_code;
4748
int8_t use_compiled_modules;
4849
int8_t use_pkgimages;

src/julia.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,9 @@ JL_DLLEXPORT int jl_generating_output(void) JL_NOTSAFEPOINT;
25992599
#define JL_OPTIONS_HANDLE_SIGNALS_ON 1
26002600
#define JL_OPTIONS_HANDLE_SIGNALS_OFF 0
26012601

2602+
#define JL_OPTIONS_USE_EXPERIMENTAL_FEATURES_YES 1
2603+
#define JL_OPTIONS_USE_EXPERIMENTAL_FEATURES_NO 0
2604+
26022605
#define JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES 1
26032606
#define JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_NO 0
26042607

0 commit comments

Comments
 (0)