Skip to content

Commit d01a4d7

Browse files
committed
use the truffle experimental flag to guard our internal launcher options
1 parent 34ca7fa commit d01a4d7

File tree

1 file changed

+65
-43
lines changed

1 file changed

+65
-43
lines changed

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java

Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public static void main(String[] args) {
7575
private VersionAction versionAction = VersionAction.None;
7676
private String sulongLibraryPath = null;
7777
private List<String> givenArguments;
78+
private boolean wantsExperimental = false;
7879

7980
@Override
8081
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
144145
versionAction = VersionAction.PrintAndContinue;
145146
break;
146147
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;
149155
}
150-
GraalPythonCC.main(arguments.subList(i + 1, arguments.size()).toArray(new String[0]));
151-
System.exit(0);
152-
break;
153156
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;
156164
}
157-
GraalPythonLD.main(arguments.subList(i + 1, arguments.size()).toArray(new String[0]));
158-
System.exit(0);
159-
break;
160165
case "-LLI":
161-
runLLI = true;
162-
break;
166+
if (wantsExperimental) {
167+
runLLI = true;
168+
break;
169+
}
163170
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;
167177
}
168-
break;
169178
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+
}
177188
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+
}
181194
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+
}
186201
case "-u":
187202
unbufferedIO = true;
188203
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;
189211
default:
190212
if (!arg.startsWith("-")) {
191213
inputFile = arg;
@@ -536,16 +558,9 @@ protected void printHelp(OptionCategory maxCategory) {
536558
// "-3 : warn about Python 3.x incompatibilities that 2to3 cannot trivially
537559
// fix\n" +
538560
"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" +
540562
"arg ...: arguments passed to program in sys.argv[1:]\n" +
541563
"\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" +
549564
"Other environment variables:\n" +
550565
"PYTHONSTARTUP: file executed on interactive startup (no default)\n" +
551566
"PYTHONPATH : ':'-separated list of directories prefixed to the\n" +
@@ -558,11 +573,18 @@ protected void printHelp(OptionCategory maxCategory) {
558573
" as specifying the -R option: a random value is used to seed the hashes of\n" +
559574
" str, bytes and datetime objects. It can also be set to an integer\n" +
560575
" 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 ? "\nArguments 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+
"\nEnvironment 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." : ""));
566588
}
567589

568590
@Override

0 commit comments

Comments
 (0)