@@ -75,6 +75,7 @@ public static void main(String[] args) {
75
75
private VersionAction versionAction = VersionAction .None ;
76
76
private String sulongLibraryPath = null ;
77
77
private List <String > givenArguments ;
78
+ private boolean wantsExperimental = false ;
78
79
79
80
@ Override
80
81
protected List <String > preprocessArguments (List <String > givenArgs , Map <String , String > polyglotOptions ) {
@@ -144,48 +145,69 @@ protected List<String> preprocessArguments(List<String> givenArgs, Map<String, S
144
145
versionAction = VersionAction .PrintAndContinue ;
145
146
break ;
146
147
case "-CC" :
147
- if (i != defaultEnvironmentArgs .size ()) {
148
- throw new IllegalArgumentException ("-CC must be the first given argument" );
148
+ if (wantsExperimental ) {
149
+ if (i != defaultEnvironmentArgs .size ()) {
150
+ throw new IllegalArgumentException ("-CC must be the first given argument" );
151
+ }
152
+ GraalPythonCC .main (arguments .subList (i + 1 , arguments .size ()).toArray (new String [0 ]));
153
+ System .exit (0 );
154
+ break ;
149
155
}
150
- GraalPythonCC .main (arguments .subList (i + 1 , arguments .size ()).toArray (new String [0 ]));
151
- System .exit (0 );
152
- break ;
153
156
case "-LD" :
154
- if (i != defaultEnvironmentArgs .size ()) {
155
- throw new IllegalArgumentException ("-LD must be the first given argument" );
157
+ if (wantsExperimental ) {
158
+ if (i != defaultEnvironmentArgs .size ()) {
159
+ throw new IllegalArgumentException ("-LD must be the first given argument" );
160
+ }
161
+ GraalPythonLD .main (arguments .subList (i + 1 , arguments .size ()).toArray (new String [0 ]));
162
+ System .exit (0 );
163
+ break ;
156
164
}
157
- GraalPythonLD .main (arguments .subList (i + 1 , arguments .size ()).toArray (new String [0 ]));
158
- System .exit (0 );
159
- break ;
160
165
case "-LLI" :
161
- runLLI = true ;
162
- break ;
166
+ if (wantsExperimental ) {
167
+ runLLI = true ;
168
+ break ;
169
+ }
163
170
case "-debug-java" :
164
- if (!isAOT ()) {
165
- subprocessArgs .add ("Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y" );
166
- inputArgs .remove ("-debug-java" );
171
+ if (wantsExperimental ) {
172
+ if (!isAOT ()) {
173
+ subprocessArgs .add ("Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y" );
174
+ inputArgs .remove ("-debug-java" );
175
+ }
176
+ break ;
167
177
}
168
- break ;
169
178
case "-debug-perf" :
170
- subprocessArgs .add ("Dgraal.TraceTruffleCompilation=true" );
171
- subprocessArgs .add ("Dgraal.TraceTrufflePerformanceWarnings=true" );
172
- subprocessArgs .add ("Dgraal.TruffleCompilationExceptionsArePrinted=true" );
173
- subprocessArgs .add ("Dgraal.TraceTruffleInlining=true" );
174
- subprocessArgs .add ("Dgraal.TruffleTraceSplittingSummary=true" );
175
- inputArgs .remove ("-debug-perf" );
176
- break ;
179
+ if (wantsExperimental ) {
180
+ subprocessArgs .add ("Dgraal.TraceTruffleCompilation=true" );
181
+ subprocessArgs .add ("Dgraal.TraceTrufflePerformanceWarnings=true" );
182
+ subprocessArgs .add ("Dgraal.TruffleCompilationExceptionsArePrinted=true" );
183
+ subprocessArgs .add ("Dgraal.TraceTruffleInlining=true" );
184
+ subprocessArgs .add ("Dgraal.TruffleTraceSplittingSummary=true" );
185
+ inputArgs .remove ("-debug-perf" );
186
+ break ;
187
+ }
177
188
case "-dump" :
178
- subprocessArgs .add ("Dgraal.Dump=" );
179
- inputArgs .remove ("-dump" );
180
- break ;
189
+ if (wantsExperimental ) {
190
+ subprocessArgs .add ("Dgraal.Dump=" );
191
+ inputArgs .remove ("-dump" );
192
+ break ;
193
+ }
181
194
case "-compile-truffle-immediately" :
182
- subprocessArgs .add ("Dgraal.TruffleCompileImmediately=true" );
183
- subprocessArgs .add ("Dgraal.TruffleCompilationExceptionsAreThrown=true" );
184
- inputArgs .remove ("-compile-truffle-immediately" );
185
- break ;
195
+ if (wantsExperimental ) {
196
+ subprocessArgs .add ("Dgraal.TruffleCompileImmediately=true" );
197
+ subprocessArgs .add ("Dgraal.TruffleCompilationExceptionsAreThrown=true" );
198
+ inputArgs .remove ("-compile-truffle-immediately" );
199
+ break ;
200
+ }
186
201
case "-u" :
187
202
unbufferedIO = true ;
188
203
break ;
204
+ case "--experimental-options" :
205
+ case "--experimental-options=true" :
206
+ // this is the default Truffle experimental option flag. We also use it for
207
+ // our custom launcher options
208
+ wantsExperimental = true ;
209
+ unrecognized .add (arg );
210
+ break ;
189
211
default :
190
212
if (!arg .startsWith ("-" )) {
191
213
inputFile = arg ;
@@ -536,16 +558,9 @@ protected void printHelp(OptionCategory maxCategory) {
536
558
// "-3 : warn about Python 3.x incompatibilities that 2to3 cannot trivially
537
559
// fix\n" +
538
560
"file : program read from script file\n " +
539
- // "- : program read from stdin (default; interactive mode if a tty) \n" +
561
+ "- : program read from stdin \n " +
540
562
"arg ...: arguments passed to program in sys.argv[1:]\n " +
541
563
"\n " +
542
- "Arguments specific to GraalPython:\n " +
543
- "--show-version : print the Python version number and continue.\n " +
544
- "-CC : run the C compiler used for generating GraalPython C extensions.\n " +
545
- " All following arguments are passed to the compiler.\n " +
546
- "-LD : run the linker used for generating GraalPython C extensions.\n " +
547
- " All following arguments are passed to the linker.\n " +
548
- "\n " +
549
564
"Other environment variables:\n " +
550
565
"PYTHONSTARTUP: file executed on interactive startup (no default)\n " +
551
566
"PYTHONPATH : ':'-separated list of directories prefixed to the\n " +
@@ -558,11 +573,18 @@ protected void printHelp(OptionCategory maxCategory) {
558
573
" as specifying the -R option: a random value is used to seed the hashes of\n " +
559
574
" str, bytes and datetime objects. It can also be set to an integer\n " +
560
575
" in the range [0,4294967295] to get hash values with a predictable seed.\n " +
561
- "SULONG_LIBRARY_PATH: Specifies the library path for Sulong.\n " +
562
- " This is required when starting subprocesses of python.\n " +
563
- "GRAAL_PYTHON_OPTIONS: This environment variable can include default options that\n " +
564
- " are always passed to the launcher. These are not shell expanded and given to\n " +
565
- " the launcher as-is." );
576
+ (wantsExperimental ? "\n Arguments specific to the Graal Python launcher:\n " +
577
+ "--show-version : print the Python version number and continue.\n " +
578
+ "-CC : run the C compiler used for generating GraalPython C extensions.\n " +
579
+ " All following arguments are passed to the compiler.\n " +
580
+ "-LD : run the linker used for generating GraalPython C extensions.\n " +
581
+ " All following arguments are passed to the linker.\n " +
582
+ "\n Environment variables specific to the Graal Python launcher:\n " +
583
+ "SULONG_LIBRARY_PATH: Specifies the library path for Sulong.\n " +
584
+ " This is required when starting subprocesses of python.\n " +
585
+ "GRAAL_PYTHON_OPTIONS: This environment variable can include default options that\n " +
586
+ " are always passed to the launcher. These are not shell expanded and given to\n " +
587
+ " the launcher as-is." : "" ));
566
588
}
567
589
568
590
@ Override
0 commit comments