https://kotlinlang.org logo
c

Czar

01/06/2019, 12:23 AM
HA! After couple of hours of digging through kotlin code I've found the problem, will try to contribute fix next week 🙂
💯 2
2
i

ilya.chernikov

01/16/2019, 2:08 PM
Could you, please, share, what problem you’ve found and what happened with the fix?
c

Czar

01/16/2019, 2:13 PM
problem: compiler is created without ever consulting the parameters passed in the configuration solution: actually add the configured parameters to the compiler, I've got sidetracked by work projects, thing is I haven't contributed to Kotlin before, so I'll probably have to allocate some time to learn the ropes and setup environment. Maybe I'll have some time for that later today To confirm the problem I've hooked into the running application via debug and injected the parameters into the compiler at creation, which worked.
i

ilya.chernikov

01/16/2019, 2:16 PM
c

Czar

01/16/2019, 2:16 PM
yes
i

ilya.chernikov

01/16/2019, 2:21 PM
Ok, I see. I do have a proper (from my point of view) fix for it. It required quite bit of changes in other parts of the compiler itself, therefore took some time. Unfortunately it doesn;t fit into 1.3.20 timeframe, so probably will be released in 1.3.30 only. But I hope to fix https://youtrack.jetbrains.com/issue/KT-29319 in 1.3.20, which should solve one of the typical problems. And I’m open for the suggestions for other quick fixes about it.
c

Czar

01/16/2019, 2:25 PM
Oh, I was actually planning to do quick and dirty fix until someone from you guys had time to invest. So if you already have the proper fix in the pipeline and 1.3.20 is already fixing the most painful problem (inlining error), I'd rather not embarrass myself 😄
I'll still describe what I was planning to do a bit later, when I have the access to my home PC.
i

ilya.chernikov

01/16/2019, 2:28 PM
Thank you! Looking forward to see your description.
c

Czar

01/16/2019, 6:14 PM
@ilya.chernikov So based on kotlin-scripting-jvm-host 1.3.20-eap-52 my idea was to extract frequently used / most common properties from
scriptCompilationCOnfiguration
and install them into
kotlinCompilerConfiguration
in
kotlin.script.experimental.jvmhost.impl.KJvmCompilerImpl#compile
. Something along the lines of this snippet I used to test that it would work:
Copy code
K2JVMCompilerArguments().also {
		parseCommandLineArguments(
			updatedConfiguration[PropertiesCollection.Key<List<String>>("compilerOptions")]!!,
			it
		)
		kotlinCompilerConfiguration.put(JVMConfigurationKeys.JVM_TARGET, JvmTarget.fromString(it.jvmTarget!!)!!)
Pardon all the exclamation marks, it's just a quick test code 🙂 To be honest I do not see a lot of difference between getting
jdkHome
in that same method and what I thought to do to fix the problem. I may of course be missing something, as this is my first foray into the scripting host code. Please do ping me if you think I can be of help in any way, I do have some free time this week 🙂
i

ilya.chernikov

01/17/2019, 4:43 PM
Ok, I see. Thank you for the explanation. The proper fix that is in the pipeline uses the same functionality as in the command line compiler, so with it we will not have a second place where arguments are parsed, checked and properly passed to the compiler config. But I hope that intermediate solution that you’re suggesting is not actually needed, and for a moment simply setting jvmTarget to 1.8 will suffice. If you think that it is not, or there are other options that need to be addressed in 1.2.30 - please tell.
c

Czar

01/17/2019, 4:49 PM
It's fine by me, I'm not actually using this currently anyway, the issue just came up in the discussion. @Nikky you seem to be more invested in this, want to comment?
n

Nikky

01/17/2019, 6:27 PM
the biggest pain is inlining indeed, and setting the jvmTarget to 1.8 by default should take care of that, i also works if you add all the .kt files containing inline functions via importScripts, but thats often not possible since they are already compiled