It looks like IC is working differently, depending...
# compiler
o
It looks like IC is working differently, depending on the KGP variant: KT-82560 shows a case where it works with
kotlin("multiplatform")
, but not
kotlin("jvm")
. Is this a known situation and will it change?
t
JVM IC in KMP is disabled inside project. Only compilation avoidance is working
o
OK, good to know. Why is this different for JVM?
t
I suppose the problem should be fixed in 2.3.0 via KT-75864 Implement a conservative mechanism of the IC with compiler plugins generated top-level declarations
if not - needs further investigation
o
In 2.3.0-Beta2 it was still not working. I haven't tried the RC yet.
t
then it needs investigation fyi @dmitriy.novozhilov
👍 1
d
According to what you've describe, you need to mark as dirty all of the files with declarations you've referenced from the plugin and the file with newly generated declaration. And the regular lookups API is not enough here, you need the one I've implemented in KT-75864 (precisely, from the commit 0561560f,
FirLookupTrackerComponent.recordDirtyDeclaration
). Also you need to add
irFile.fileForTopLevelPluginDeclarations = true
for the IR file with the declaration you're creating, to mark it always dirty.
As an alternative you can just disable the incremental compilation for JVM modules which have the plugin applied.
Observation: if you change the design of your plugin, so you'll look for declarations to reference by some annotation, not by the name of the called function and then reference them once using
LookupPredicate
in the frontend and also generate the entrypoint on the frontend too (e.g. the logic will be "create entrypoint function if there was at least one function by this predicate"), then IC will work out of box.
o
Thanks for looking into it! Note that currently the plugin doesn't do name-based lookups, but type-based ones. I'd consider collecting top-level declarations based on their type a perfectly legitimate use case, so it should not depend on adding additional boilerplate (annotations) by users. So per your suggestion, would the predicate mechanism work if the plugin generates the annotations for top-level declarations of interest? For top-level symbol collectors, could you consider a more lightweight IC mechanism? Basically, a top-level symbol collector only dirties its entry point file. It does not necessarily change referenced files. The root problem in this case is the visitor pattern, which does not let the plugin see the whole picture of its module in case of IC, where only some files get recompiled. To solve the problem, a plugin could store collected symbols from a previous compilation (ideally via the compiler offering such a storage mechanism). In an IC recompilation, the plugin would then – as usual – visit changed files, and also new files, so it could update its collection from those. But it would need to be informed about removed files, otherwise it would fail to remove their symbols from the collection. So what do you think about providing such an indication (files removed in an IC iteration), and, ideally, a storage mechanism (even a simple
Set<IrFile>
of referenced files would help)?
d
So per your suggestion, would the predicate mechanism work if the plugin generates the annotations for top-level declarations of interest?
No, this mechanism works only for annotations declared in the code.
For top-level symbol collectors, could you consider a more lightweight IC mechanism? Basically, a top-level symbol collector only dirties its entry point file. It does not necessarily change referenced files.
The IC in its core works by the following algorithm • during the first compilation compiler records which fq names were referenced from which files • on the second compilation IC creates ABI dump difference, calculates what fqns could change and computes which files become dirty based on this information Note that "referenced" in this context is not equal to "resolved":
Copy code
// 1.kt
package foo

fun foo() {}

// 2.kt
package bar

fun foo(x: Int) {}

// 3.kt
import foo.*
import bar.foo

fun test() {
    foo()
}
In this example name
foo.foo
was referenced despite the fact that the call was actually resolved to
bar.foo
. So if IC detects that there was a change of a declaration with
foo.foo
fqname,
3.kt
will become dirty. So with compiler plugins things become much more complicated, as plugins usually are interested in declarations by some arbitrary predicate, which cannot be simplified to "fqname X was referenced from file Y" (even in your example you're interested in "any declaration with specific type"). We considered different approaches, but all of them fall into a problem that "arbitrary predicate" is too wide thing. So for now we started with an approach that • any file, generated by the plugin is dirty, as it could depend on any new code which will be added on the second compilation • any file referenced by the plugin is dirty, as we don't know exact logic what the plugin checked in that declartion
One additional complicated thing is that if some files are provided from cache instead of being recompiled during IC, they appear in the compiler as classes from dependencies, which means that predicate API won't work for them (as it indexes only source declarations) and they won't appear in
irModuleFragment.files
, so both frontend and backend plugins won't be able to reference/iterate over them, as they do in case of clean compilation.
o
I understand that a wide predicate would meet performance concerns. But wouldn't the simple mechanism I suggested cover IC cases nicely, even the one with reference/resolve differences and caching, as a symbol-collecting plugin would be OK with visiting just the files the compiler is actually processing? Everything else you mentioned could just remain as is, including the IC model, right? To solve it in the mean time: What's the recommended way to turn off IC for a K/JVM module? Could I do it in
KotlinCompilerPluginSupportPlugin.applyToCompilation()
?
t
no, it is not possible to disable IC for given compilation
d
But wouldn't the simple mechanism I suggested cover IC cases nicely, ...? Everything else you mentioned could just remain as is, including the IC model, right?
Assume that we have files
a
,
b
and
c
.
a
and
b
contain declarations you're interested in and you generate new
d
with something. Then the user changes
c
by adding the declaration of type you're interested in. But with your suggestion IC considers
a
,
b
and
d
clean, so only new
c
is compiled, and your plugin generates new file
f
which contains generated code which processing declaration from
c
. But if you compile everything, then there would be only
d
generated with processing of declarations from
a
,
b
and
c
.
o
But with your suggestion IC considers
a
,
b
and
d
clean, so only new
c
is compiled
OK, I get the problem. I would want to dirty
d
by seeing the new declaration in
c
, but at this time it's too late. In that case, we'd need an extra iteration to compile those files which were newly dirtied during an initial iteration (like KSP doing multi-iteration processing). So am I right in assuming that a very simple solution could be to let a compiler plugin instruct the compiler to do a full compilation if files are added or removed?
d
if files are added or removed?
You mean input source files or output files produced by the plugin?
o
Input source files. At least in my case, I have one entry point file with a known path.
d
But in my example none of files were added or removed, just existing one changed.
o
Ah, OK I had overlooked that.
c
changed from being uninteresting to interesting.
And that's why we're back to the predicates.
d
So the solution we made for frontend plugins, and which you can also use in the backend is to mark all files which you've based to generate something as always dirty. So in the example above
a
and
b
will be always recompiled, and your plugin will either produce the same result or more (if in the changed files there was something interesting for you).
And that's why we're back to the predicates.
You can achieve the same behavior manually in the backend, without predicates. I wrote how to do it above.
o
I'll look into that and come up with a solution. Luckily I have integration tests for that and can add the edge cases discussed here. Thanks a lot!
👍 1
Unfortunately, the suggested solution does not work with backend IR in 2.3.0-RC. As soon as I add
entryPointFile.fileForTopLevelPluginDeclarations = true
, the compiler fails with the error shown below. A reproducer is here (run
./gradlew integration-tests
).
Copy code
java.lang.IllegalStateException: Plugin generated file shouldn't have sources, but got .../testBalloon/integration-test/build/generated/testBalloon/src/commonTest/kotlin/EntryPointAnchor.kt
	at org.jetbrains.kotlin.cli.common.output.OutputUtilsKt.writeAll$lambda$0(outputUtils.kt:64)
	at org.jetbrains.kotlin.cli.common.output.OutputUtilsKt.writeAll(outputUtils.kt:32)
	at org.jetbrains.kotlin.cli.common.output.OutputUtilsKt.writeAll(outputUtils.kt:59)
	at org.jetbrains.kotlin.cli.jvm.compiler.CliCompilerUtilsKt.writeOutput(cliCompilerUtils.kt:104)
	at org.jetbrains.kotlin.cli.jvm.compiler.CliCompilerUtilsKt.writeOutputsIfNeeded(cliCompilerUtils.kt:124)
	at org.jetbrains.kotlin.cli.pipeline.jvm.JvmWriteOutputsPhase.executePhase(JvmWriteOutputsPhase.kt:17)
	at org.jetbrains.kotlin.cli.pipeline.jvm.JvmWriteOutputsPhase.executePhase(JvmWriteOutputsPhase.kt:12)
	at org.jetbrains.kotlin.cli.pipeline.PipelinePhase.phaseBody(PipelinePhase.kt:68)
	at org.jetbrains.kotlin.cli.pipeline.PipelinePhase.phaseBody(PipelinePhase.kt:58)
	at org.jetbrains.kotlin.config.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:102)
Could that be fixed in the compiler or would I have to use FIR to create the entry point file? If so, what would be the compiler APIs to use?
d
Do you generate your entry point in a new
IrFile
or in some existing one? It should be new.
Could that be fixed in the compiler or would I have to use FIR to create the entry point file?
Compiler works as expected here,
generatedForCompilerPlugin
should be set only for generated files.
o
I generate an empty entry point file in a Gradle plugin, then insert IR in the compiler plugin. I could not find an API to create a new IrFile within a compiler plugin.
d
Copy code
fun test(module: IrModuleFragment) {
    val packageFqName = FqName.fromSegments("foo.bar".split("."))
    val irFile = IrFileImpl(
        NaiveSourceBasedFileEntryImpl("generatedFile.kt"),
        IrFileSymbolImpl(),
        packageFqName,
    ).also { it.generatedForCompilerPlugin = true }
    module.files += irFile
}
thank you color 1
BTW is it expected to be able to call your entrypoint function from the user code? If yes, you either need to create it on a FIR level instead (with proper body generation in the IR) or create it in IR and then add it to metadata using
IrPluginContext.metadataDeclarationRegistrar.registerFunctionAsMetadataVisible
.
o
No, it is not. The entry point file is just a replacement for a
main
function which does not (always) exist in tests.
I'll try to create the entry point file within a `CompilerPluginIrGenerationExtension`'s
generate()
function and will report back how that works.
👍 1
Observations so far: • In 2.3.0-RC,
IrFileImpl
has no symbol
generatedForCompilerPlugin
, but that does not seem to matter (the ISE from above no longer appears). • Creating the IrFile in the backend produces an error on JS, Wasm/JS, Wasm/WASI and Native:
Copy code
e: java.lang.AssertionError: The number of source files (1) does not match the number of IrFiles (2)
	at org.jetbrains.kotlin.backend.common.serialization.SerializeModuleIntoKlibKt.serializeModuleIntoKlib(serializeModuleIntoKlib.kt:108)
	at org.jetbrains.kotlin.ir.backend.js.KlibKt.serializeModuleIntoKlib(klib.kt:535)
	at org.jetbrains.kotlin.cli.pipeline.web.WebKlibSerializationPipelinePhase.serializeFirKlib(WebKlibSerializationPipelinePhase.kt:69)
	at org.jetbrains.kotlin.cli.pipeline.web.WebKlibSerializationPipelinePhase.executePhase(WebKlibSerializationPipelinePhase.kt:31)
	at org.jetbrains.kotlin.cli.pipeline.web.WebKlibSerializationPipelinePhase.executePhase(WebKlibSerializationPipelinePhase.kt:24)
	at org.jetbrains.kotlin.cli.pipeline.PipelinePhase.phaseBody(PipelinePhase.kt:68)
• on JVM, removing an "interesting" file from the sources, then compiling, then adding it back, then compiling, makes the plugin miss top-level symbols, so IC still does not work. In the compilation before (after the file was removed), the build report shows this error:
Copy code
Incremental compilation was attempted but failed:
    Failed to close caches: org.jetbrains.kotlin.incremental.CachesManagerCloseException: Failed to close caches
d
In 2.3.0-RC, IrFileImpl has no symbol generatedForCompilerPlugin, but that does not seem to matter (the ISE from above no longer appears).
My bad, the attribute is called fileForTopLevelPluginDeclarations.
Creating the IrFile in the backend produces an error on JS, Wasm/JS, Wasm/WASI and Native:
I fixed it 2.3.20 (KT-58886).
on JVM, removing an "interesting" file from the sources, then compiling, then adding it back, then compiling, makes the plugin miss top-level symbols, so IC still does not work. In the compilation before (after the file was removed), the build report shows this error:
That's interesting. Could you share a stable reproducer?
o
the attribute is called fileForTopLevelPluginDeclarations.
I did set that, so everything good on that side.
I fixed it 2.3.20 (KT-58886).
That's super cool as it would make the Gradle integration a lot easier.
That's interesting. Could you share a stable reproducer?
Will do. AFK for an hour, but after that I'll put something together.
👍 1
Here's a reproducer, with info in integration-test/README-IC-REPRODUCER.md. Observations: • The next to last build report shows "Failed to close caches". • The final compilation fails with "Unresolved reference 'log'.", with the referring "File1.kt" having just been restored, and the "log" symbol residing in a third file which was always part of all compilations. Does that help? Should I create a YouTrack issue in addition?
d
If you check the stacktrace, there is the following exception message:
Copy code
Expected absolute path but found relative path: EntryPointAnchor.kt
So when I replaced
NaiveSourceBasedFileEntryImpl(Constants.ENTRY_POINT_ANCHOR_FILE_NAME)
with
NaiveSourceBasedFileEntryImpl(File(Constants.ENTRY_POINT_ANCHOR_FILE_NAME).absolutePath)
the test started to pass.
o
Can confirm that it works for K/JVM. kodee happy For KMP, I'm currently checking with 2.3.20-dev-4294. Just to make sure that I'm using the IC API as intended with backend IR transformation. Is this code OK to register references from my synthetic entry point file to top-level symbols in other sources (including the use of
lookupTracker
,
fileMappingTracker
and the
synchronized
lock)?
Copy code
/**
     * Registers a reference from [this] file to [referencedDeclaration], potentially residing in another file.
     *
     * This is required for incremental compilation.
     */
    private fun IrFile.registerReference(referencedDeclaration: IrDeclarationWithName) {
        val lookupTracker = configuration.lookupTracker ?: return

        synchronized(lookupTracker) {
            lookupTracker.record(
                filePath = path,
                position = Position.NO_POSITION,
                scopeFqName = referencedDeclaration.fileParent.packageFqName.asString(),
                scopeKind = ScopeKind.CLASSIFIER,
                name = referencedDeclaration.name.asString()
            )

            configuration.fileMappingTracker?.recordSourceReferencedByCompilerPlugin(
                File(referencedDeclaration.fileParent.path)
            )
        }
    }
d
Synchronization is not needed, as there is no parallelism at the stage when plugins are executed. For lookup recording there is more appropriate function in the IrPluginContext. The fileMappingTracker usage is fine.
thank you color 1
o
KMP tests work for the JVM part. On Native and JS I'm seeing class cast errors. Could this be related to the synthetic entry point file and is there something I should change for 2.3.20?
Copy code
> Task :compileTestKotlinLinuxX64 FAILED
e: Compilation failed: class org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl cannot be cast to class org.jetbrains.kotlin.ir.declarations.IrDeclaration (org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl and org.jetbrains.kotlin.ir.declarations.IrDeclaration are in unnamed module of loader java.net.URLClassLoader @42c72e21)
 * Source files: File1.kt, File2.kt, log.kt
 * Compiler version: 2.3.20-dev-4294
 * Output kind: LIBRARY
e: java.lang.ClassCastException: class org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl cannot be cast to class org.jetbrains.kotlin.ir.declarations.IrDeclaration (org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl and org.jetbrains.kotlin.ir.declarations.IrDeclaration are in unnamed module of loader java.net.URLClassLoader @42c72e21)
	at org.jetbrains.kotlin.ir.symbols.impl.IrSymbolBase.getDescriptor(IrSymbolImpl.kt:28)
	at org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl.getDescriptor(IrSymbolImpl.kt:20)
	at org.jetbrains.kotlin.ir.declarations.IrPackageFragmentsKt.getPackageFragmentDescriptor(IrPackageFragments.kt:22)
	at org.jetbrains.kotlin.backend.common.serialization.IrModuleSerializer.serializedIrModule(IrModuleSerializer.kt:45)
	at org.jetbrains.kotlin.backend.common.serialization.SerializeModuleIntoKlibKt.serializeModuleIntoKlib(serializeModuleIntoKlib.kt:122)
	at org.jetbrains.kotlin.backend.common.serialization.SerializeModuleIntoKlibKt.serializeModuleIntoKlib$default(serializeModuleIntoKlib.kt:92)
	at org.jetbrains.kotlin.native.FirNativeSerializerKt.firSerializerBase-jlVyY7s(FirNativeSerializer.kt:53)
	at org.jetbrains.kotlin.native.FirNativeSerializerKt.fir2IrSerializer(FirNativeSerializer.kt:34)

> Task :compileTestKotlinJs FAILED
e: java.lang.ClassCastException: class org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl cannot be cast to class org.jetbrains.kotlin.ir.declarations.IrDeclaration (org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl and org.jetbrains.kotlin.ir.declarations.IrDeclaration are in unnamed module of loader 'app')
    at org.jetbrains.kotlin.ir.symbols.impl.IrSymbolBase.getDescriptor(IrSymbolImpl.kt:28)
    at org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl.getDescriptor(IrSymbolImpl.kt:20)
    at org.jetbrains.kotlin.ir.declarations.IrPackageFragmentsKt.getPackageFragmentDescriptor(IrPackageFragments.kt:22)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleSerializer.serializedIrModule(IrModuleSerializer.kt:45)
    at org.jetbrains.kotlin.backend.common.serialization.SerializeModuleIntoKlibKt.serializeModuleIntoKlib(serializeModuleIntoKlib.kt:122)
    at org.jetbrains.kotlin.ir.backend.js.KlibKt.serializeModuleIntoKlib(klib.kt:534)
    at org.jetbrains.kotlin.cli.pipeline.web.WebKlibSerializationPipelinePhase.executePhase(WebKlibSerializationPipelinePhase.kt:40)
    at org.jetbrains.kotlin.cli.pipeline.web.WebKlibSerializationPipelinePhase.executePhase(WebKlibSerializationPipelinePhase.kt:22)
d
You need to create file symbol like this:
Copy code
fun test(context: IrPluginContext) {
    @OptIn(ObsoleteDescriptorBasedAPI::class)
    val descriptor = EmptyPackageFragmentDescriptor(context.moduleDescriptor, FqName("my.file.package"))
    val symbol = IrFileSymbolImpl(descriptor)
}
Unfortunately there are still some places which use descriptors.
o
OK, I'll do. No big deal. 🙂 Will the synthetic file always need an absolute path or is that going to change at some point? (We need the name for the facade class but the path seems strange.)
d
This path is not actually used anywhere, as the required condition for it is that it doesn't exist. But the assertions you've encountered is about regular files, and the IC expects full paths there.
👍 1
o
With the latest change, compilation succeeds on all platforms. What does not yet work on non-JVM targets is the invocation of entry points: On JS and Wasm, the invocation uses a generated
suspend fun main()
, which previously got invoked automatically for test targets. On Native, I'm relying on a property annotated with
kotlin.native.EagerInitialization
. I'll check whether there were changes to these mechanisms. Otherwise, there might still be something missing in the way entry point file was created. (For the generated
suspend fun main()
, calling
IrPluginContext.metadataDeclarationRegistrar.registerFunctionAsMetadataVisible
had no effect.)
Checked it: Entry points within a Gradle-created entry point file work just fine with Kotlin 2.3.20-dev-4294 as this branch shows. Something in the way the synthetic entry point file is created (in this branch) makes the compiler miss the main function and eagerly initialized properties as it creates its startup/initialization code.
d
Did you try generating the main function at the FIR level?
o
Not yet. I can do that next.
d
@svyatoslav.scherbina do you know how the Native backend processes the
main
function and why it could not take it from the
IrFile
generated by the backend compiler plugin? Does it maybe rely on some frontend information which is missing?
o
Note that we are in a "test" module. Also, on Native I'm using eagerly initialized properties. AFAIK, a main function in the test module was never recognized on Native. The main function applied to JS and Wasm (still in a "test" module).
d
cc @broadway_lamb regarding JS.
o
It seems that there is no
FirExtension
which would allow me to directly generate an entry point
FirFile
. Seems like I would have to use
FirDeclarationGenerationExtension.generateTopLevelClassLikeDeclaration()
, and hope for
FrontendFilesForPluginsGenerationPipelinePhase.createFilesWithGeneratedDeclarations()
to create the synthetic entry point file for me, correct?
d
You don't need to generate the file, just generate the top-level function. The file will be created automatically before fir2ir conversion (frontend doesn't operate files for generated declarations).
hope for
Not hope, but expect to.
🙂 1
s
o
That does not apply, a main function is not used there: On Native, it is eagerly initialized properties which are not recognized if the entry point file is an
IrFile
generated by the backend compiler plugin. They are recognized if the entry point file is an external source file and the properties are generated for that source file by the backend compiler plugin. (The latter version cannot be used with IC, which is the reaseon for a change.)
s
Not sure, needs investigation. What does
Copy code
~/.konan/kotlin-native-prebuilt-$os-$arch-$version/bin/klib dump-ir $pathToKlib
show for the klib with such files? Are those properties present there?
o
No. Actually, the entire synthetic entry point file does not appear. It was generated in backend IR by this code:
Copy code
val entryPointFile = IrFileImpl(
            NaiveSourceBasedFileEntryImpl(Path(Constants.ENTRY_POINT_ANCHOR_FILE_NAME).absolutePathString()),
            IrFileSymbolImpl(
                @OptIn(ObsoleteDescriptorBasedAPI::class)
                EmptyPackageFragmentDescriptor(pluginContext.moduleDescriptor, configuration.entryPointPackageName)
            ),
            configuration.entryPointPackageName
        ).apply {
            fileForTopLevelPluginDeclarations = true
        }
        moduleFragment.files += entryPointFile
o
I'll just try to resort to a FIR-generated property then. I'd also appreciate an easier solution: All I need is one entry point (
main()
like) called at startup. I'm bringing my own test runner and do proper test reporting. I just need to have it called (the "standard" entry point can also get called, I don't mind). Ideally, there was one entry point mechanism in tests I could rely on for all targets.
With FIR generation of top-level symbols, we now have the following results for 2.3.20-dev-4294: • Native works, but seemingly never uses IC, • JS works if IC is turned off, • JS fails with IC ("No file found for source null", "KT-82395"), • JVM fails with IC in different ways: ◦ If IR adds symbols to a FIR-generated entry point file, it fails with "Expected absolute path but found relative path" causing "Could not close incremental caches". ◦ If IR adds symbols to an IR-generated entry point file, it fails with "Could not close incremental caches" without giving an additional cause. • JVM works if ◦ IC is turned off and ◦ IR adds symbols to an IR-generated entry point file (adding them in IR to the FIR-generated one seemingly makes the JVM miss them on the classpath, so no tests run). A reproducer is here. The branch is https://github.com/infix-de/testBalloon/tree/reproducers/ic-with-top-level-plugin-declarations
s
I'd also appreciate an easier solution: All I need is one entry point (
main()
like) called at startup. I'm bringing my own test runner and do proper test reporting. I just need to have it called (the "standard" entry point can also get called, I don't mind). Ideally, there was one entry point mechanism in tests I could rely on for all targets.
Not sure how to achieve that with Kotlin/JVM. With Kotlin/Native, you can have this by passing the flags
-entry your.package.main
to the compiler in the
linkDebugTest*
task.
but seemingly never uses IC,
There is no incremental compilation for K/N
compileKotlin*
tasks. For
linkDebug*
tasks, there is https://kotlinlang.org/docs/native-improving-compilation-time.html#try-incremental-compilation-of-klib-artifacts, but it is likely irrelevant here.
o
> Not sure how to achieve that with Kotlin/JVM. On the JVM, TestBalloon does that: It integrates with JUnit Platform and the JUnit 4 runner API. From both, it calls its own cross-platform entry point function. If we would use such a mechanism, make the entry point configurable, and make KGP on JVM use the same TeamCity-based notification listener as on the non-JVM targets, we could have a common pluggable test framework API on all platforms. (Some more details would need to be considered, such as passing filtering options and having a configurable entry point in the JS part as well. Currently, it's all solved in TestBalloon, and could be generalized.) > With Kotlin/Native, you can have this by passing the flags
-entry your.package.main
to the compiler in the
linkDebugTest*
task. That would be an option if KGP lets me do that. I'll look into that. > There is no incremental compilation for K/N
compileKotlin*
tasks. Good to know. Then we're good on Native, as long as we use FIR. Thanks!
👍 1
Note: What I described as the JVM missing entry point symbols from a FIR-generated file on the classpath (so no tests run), is caused by a failed attempt to load the file's facade class under the well-known name. FIR assigns its own name unknown to the JVM library, so these cannot match. To solve this without depending on a compiler-generated name, I should probably use a regular top-level class instead and put the symbols there.
d
JVM fails with IC in different ways: If IR adds symbols to a FIR-generated entry point file, it fails with "Expected absolute path but found relative path" causing "Could not close incremental caches".
I'm working on that in scope of KT-82809.
👍 1
o
Cool. If there is anything else I could help with, please let me know.
With Kotlin 2.3.20-dev-6091, enabling IC works with compiler plugins generating top-level declarations on JVM (with JVM/KMP disabled due to KT-62686) and Native (IC is not used). What's still missing is JS, Wasm/JS, Wasm/WASI, where IC produces the ISE "No file found for source null", "KT-82395". This can be corrected by disabling IC for JS tasks, which is possible from a Gradle plugin, but only by using the internal
incrementalJsKlib
property of the
Kotlin2JsCompile
task class. I have created KT-82989 to address this.