Skip to content

Cannot pass jvm parameters to dotr #3509

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

Closed
nicolasstucki opened this issue Nov 20, 2017 · 8 comments
Closed

Cannot pass jvm parameters to dotr #3509

nicolasstucki opened this issue Nov 20, 2017 · 8 comments

Comments

@nicolasstucki
Copy link
Contributor

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.

@jiminhsieh
Copy link
Member

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

@nicolasstucki
Copy link
Contributor Author

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.

@nicolasstucki
Copy link
Contributor Author

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

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Nov 28, 2017

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?

@nicolasstucki
Copy link
Contributor Author

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

@jiminhsieh
Copy link
Member

@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! :)

@nicolasstucki
Copy link
Contributor Author

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.

@jiminhsieh
Copy link
Member

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 <jvmopt>* then keep the last one. Maybe emit a warning.

Which cases you meant:

  1. -classpath <my/class/path/one> -classpath <my/class/path/two>

  2. -classpath <my/class/path/one> <my/class/path/two>

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! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants