Skip to content

Fix #4066 ./bin/dotr -language:Scala2 fails #4598

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

Merged
merged 2 commits into from
May 31, 2018
Merged

Fix #4066 ./bin/dotr -language:Scala2 fails #4598

merged 2 commits into from
May 31, 2018

Conversation

newca12
Copy link
Contributor

@newca12 newca12 commented May 29, 2018

  • allow to pass compilation option to ./bin/dotr
  • restore standard notation for java options (using -J-Xmx512m instead of -JXmx512m introduce with Cannot pass jvm parameters to dotr #3509)
  • allow to pass java options to ./bin/dotr -repl
  • allow to pass java options to ./bin/dotc

I was a bit surprise to find dotr and dotc in such bad shape.
The code was and still is a bit fishy but as far as I can see now work in every situation.

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@newca12
Copy link
Contributor Author

newca12 commented May 29, 2018

I did sign the CLA.

dist/bin/dotc Outdated
@@ -95,8 +95,8 @@ case "$1" in
# break out -D and -J options and add them to JAVA_OPTS as well
# so they reach the JVM in time to do some good. The -D options
# will be available as system properties.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment matches the old behavior ("add them to JAVA_OPTS as well [as to the Scala options]"), could you please update accordingly? I double-checked the code, but I agree with your change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code dates back to scalac script, maybe we should keep it:

  case "$1" in
    -D*)
      # pass to scala as well: otherwise we lose it sometimes when we
      # need it, e.g. communicating with a server compiler.
      java_args+=("$1")
      scala_args+=("$1")
      # respect user-supplied -Dscala.usejavacp
      case "$1" in -Dscala.usejavacp*) OVERRIDE_USEJAVACP="";; esac
      shift
      ;;
    -J*)
      # as with -D, pass to scala even though it will almost
      # never be used.
      java_args+=("${1:2}")
      scala_args+=("$1")
      shift
      ;;

@Blaisorblade
Copy link
Contributor

CLA signed.

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the contribution @newca12 👍

Once it's ready, we can test it on windows in the following project https://github.com/lampepfl/packtest

dist/bin/dotr Outdated
# Little hack to check if all arguments are options
all_params="$*"
truncated_params="${*#-}"
not_only_options=$(( ${#all_params} - ${#truncated_params} - $# ))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename not_only_options to num_of_options?

dist/bin/dotr Outdated
@@ -65,7 +74,8 @@ while [[ $# -gt 0 ]]; do
shift
;;
-J*)
addJvmOptions "-${1:2}"
addJvmOptions "${1:2}"
addRawJvmOptions "${1}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename to something like addJvmOptionsRun/addJvmOptionsRepl or addJvmOptions/addDotcOptions, which is more clear?

dist/bin/dotc Outdated
@@ -95,8 +95,8 @@ case "$1" in
# break out -D and -J options and add them to JAVA_OPTS as well
# so they reach the JVM in time to do some good. The -D options
# will be available as system properties.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code dates back to scalac script, maybe we should keep it:

  case "$1" in
    -D*)
      # pass to scala as well: otherwise we lose it sometimes when we
      # need it, e.g. communicating with a server compiler.
      java_args+=("$1")
      scala_args+=("$1")
      # respect user-supplied -Dscala.usejavacp
      case "$1" in -Dscala.usejavacp*) OVERRIDE_USEJAVACP="";; esac
      shift
      ;;
    -J*)
      # as with -D, pass to scala even though it will almost
      # never be used.
      java_args+=("${1:2}")
      scala_args+=("$1")
      shift
      ;;

@newca12
Copy link
Contributor Author

newca12 commented May 30, 2018

@Blaisorblade, the real signification of "as well" come from a 8 years old paulp commit scala/scala@80b0d24#diff-eb4553171a4a79a0be4ea69f883e75b2R72
@liufengyun I cannot find any evidence that scala_args is used in Scala. Sound like dead code for me.
This PR does not fix problems with Windows.

@Blaisorblade
Copy link
Contributor

@liufengyun I cannot find any evidence that scala_args is used in Scala. Sound like dead code for me.

Right, that comment hints at fsc, which we don't have: the options for the fsc client had to be parsed and passed by hand to the existing fsc server.

@liufengyun
Copy link
Contributor

@liufengyun I cannot find any evidence that scala_args is used in Scala. Sound like dead code for me.

Right, that comment hints at fsc, which we don't have: the options for the fsc client had to be parsed and passed by hand to the existing fsc server.

OK, I agree with you, thanks for the clarification.

@liufengyun
Copy link
Contributor

Test succeeded on Linux/Windows/OSX lampepfl/packtest#14

@Blaisorblade
Copy link
Contributor

Assigning to @liufengyun for merge if he has no further comments.

@liufengyun
Copy link
Contributor

Thanks a lot for the contribution @newca12 🎉

@liufengyun liufengyun merged commit 3ed7421 into scala:master May 31, 2018
@newca12 newca12 deleted the fix-#4066 branch May 31, 2018 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants