mdedetrich / scalajson

ScalaJSON - JSON for Scala, currently contains minimal AST
BSD 3-Clause "New" or "Revised" License
55 stars 10 forks source link

Optimization settings in Scala 2.12 need to be tweaked #43

Closed jvican closed 6 years ago

jvican commented 6 years ago

2.12 introduced a new inliner and the previous -opt:l:project flag has been deprecated. See:

[warn] -opt:l:project is deprecated, use -opt:l:inline and -opt-inline-from

On an aside, I'm curious, what is the original motivation to enable the optimizer? It is important to be careful with it because -optimize can break binary compatibility. It is best enabled in the leaf projects (applications) rather than libraries.

mdedetrich commented 6 years ago

This deprecated flag was specific for just optimizing libraries which actually made it really convenient (see release notes for http://www.scala-lang.org/news/2.12.0/#new-optimizer). I actually asked in scalac and reddit what an equivalent new flag would be and I never got an answer.

I am actually not entirely sure what I should be using as a replacement?

SethTisue commented 6 years ago

@lrytz?

lrytz commented 6 years ago

You can get the same behavior with -opt-inline-from:<sources>

$ scalac -opt-inline-from:help
...
  <sources>      Classes defined in source files compiled in the current compilation, either
                 passed explicitly to the compiler or picked up from the `-sourcepath`
...
lrytz commented 6 years ago

And, using that option is safe with respect to binary compatibility.

jvican commented 6 years ago

@lrytz Which are the options that can affect bincompat? I was registered to a ticket that discussed it, but cannot find it.

mdedetrich commented 6 years ago

@jvican The -opt:l:classpath (if it still exists) can effect binary compatibility since it uses all files from the class path (hence why its only recommended for applications/fatjars and not libraries)

jvican commented 6 years ago

Ah, alright, it was l:classpath. There's a wip bincompat guide that will be merged into the official website, so I'll suggest the author to elaborate on how the optimizer affects bincompat. /cc @jatcwang

mdedetrich commented 6 years ago

@jvican I have done this in master, feel free to merge into your branch if you want to do so

jvican commented 6 years ago

Sure, will do.