Dotty: Cannot pass jvm parameters to dotr

Created on 20 Nov 2017  路  8Comments  路  Source: lampepfl/dotty

When calling dotr (without launching the repl) we cannot pass JVM arguments such as -Xmx512. We should probably support the -JXmx512 notation the dotc supports. All flags starting with -J should be passed to the JVM without the J.

infrastructure novice help wanted enhancement

All 8 comments

I can give it a shot. :)
If I understand correctly, it would be like how dotc handle -JXmx512. Thanks!

Similarly. When we run dotr -JXmx512 Foo we should end up executing java -Xms512 -classpath <dotty runtime ...> Foo .

Or maybe it is enough to run dotr -Xmx512 Foo? That might be the case.

Maybe wait a day before starting, I will write down the exact way to handle arguments in dotr.

dotr [-repl|-run] <jvmopt>* [<Main> <main-args>*]

<jvmopt> = -classpath <some-classpath>
         | -J<jvm-option>

Run the REPL if -repl is set or if -run is not set and [<Main> <main-args>*] not is present.
Run the app if -run is set or [<Main> <main-args>*] is present.

Running should call java <jvmopt-transformed>* <Main> <main-args>* where jvmopt-transformed removes the J from -J<jvm-option> and merges the classpaths toghether.
-classpath and the dotty library classpath (currently in the script) in that order.

If several -classpath are found in <jvmopt>* then keep the last one. Maybe emit a warning.

For the REPL keep -classpath as is.

@allanrenucci WDYT?

@jiminhsieh if you are still interested, now you can have a stab at it.

@nicolasstucki If I don't misunderstand, this ticket should change scripts of dotr or dotc. If I'm correct, I have some questions about scripts of dotr and dotc. Should I discuss in gitter or in this ticket? Thanks! :)

This should only change the dotr script. The reason for this special handling of is that when we run a dotty program we do not enter through one of our Mains which handle the args. We instead boot the JVM directly, hence we have to adapt the args that are passed to java .... I belive it would be better to keep discussions on this issue in this GitHub issue to allow others to give their opinion.

Basically, we introduce a new command line option -run for dotr. It seems -run is used to execute the app, Main directly.

dotr [-repl|-run] <jvmopt>* [<Main> <main-args>*]

<jvmopt> = -classpath <some-classpath> | -J<jvm-option>

This means dotr has to pass JVM option/flag to

  • java... which is used for -run
  • dotc which is used for -repl.

However, I did try to pass JVM option/flag (dotc -J-Xmx1024m) to dotc, but it gave me bad option '-J-Xmx1024m' was ignored. This is because of scala_args in dotc saved those values. This issue isn't exactly about this ticket and didn't cause any issue, but I think it would be better to let you know.

If several -classpath are found in \

Which cases you meant:

  1. > -classpath \
  2. > -classpath \

In the first situation, dotr did keep the last one, but it will not emit a warning. In the second situation, other classpaths will fall into residual_args then cause JVM executes fail.

BTW, I have one question about dotc. In dotc, -run and -repl have no difference because of they do boot dotty.tools.repl.Main.

Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings