Gleb Minaev
11/08/2026, 11:02 AMmain function (tried generating both main() and main(args: Array<out String>)), but it seems that the function is ignored (and maybe, it is even swallowed by DCE). What should I do? I don’t want to expose the function in FIR, but if it’s a must then OK, I’ll expose it.Gleb Minaev
11/08/2026, 11:19 AMmingwX64): for some reason my main function cannot be found by the FQ name.Gleb Minaev
11/08/2026, 11:21 AMPavel Kunyavskiy [JB]
11/08/2026, 11:26 AMGleb Minaev
11/08/2026, 11:27 AMGleb Minaev
11/08/2026, 11:47 AMIrFile which has to have metadata before the entry point is registered to metadata. But I don’t see a way to add the file to metadata. I am finding a workaround for now…Gleb Minaev
11/08/2026, 12:09 PMFir2IrIrGeneratedDeclarationsRegistrar.session accessible via reflection. Saying a fact. Nothing more.) But adding the metadata didn’t help 😞Gleb Minaev
11/08/2026, 12:11 PMPavel Kunyavskiy [JB]
11/08/2026, 1:12 PMGleb Minaev
11/08/2026, 1:21 PMdev.lounres.kone.plugin.benchmarks.kotlinxBenchmarkSupport.generated and name run.kt. In it, I generate a function with name main. Then I configure executable entry point via
mingwX64 {
binaries {
executable {
entryPoint = "dev.lounres.kone.plugin.benchmarks.kotlinxBenchmarkSupport.generated.main"
}
}
}
I hope, I didn’t mess up in the configuration.Pavel Kunyavskiy [JB]
11/08/2026, 1:30 PMGleb Minaev
11/08/2026, 1:33 PMPavel Kunyavskiy [JB]
11/08/2026, 1:37 PMGleb Minaev
11/08/2026, 9:56 PMKone where there are several modules with one compiler plugin each. (Not all modules contain compiler plugins but there are 5 of them that contain.) One of the modules is called :plugins:suppliedTypes and another one (the one that I discussed earlier here) is :plugins:benchmarksKotlinxBenchmarkSupport. The project is accessible on GitHub (I push all commits to the main branch for now, so there are no other branches to check out): github.com/lounres/kone
2. To test functionality of the project in place, I created another (Gradle) project Kone-sandbox in a sibling directory. The project consists of only one module. The module declares dependencies on modules of the Kone project.
3. Usual KMP dependencies are declared using the standard way, via kotlin.sourceSets.<source set name>.dependencies DSL. Also, the plugin modules are applied as well using the following DSL:
dependencies {
add(PLUGIN_CLASSPATH_CONFIGURATION_NAME, <plugin module dependecy notation>)
add(NATIVE_COMPILER_PLUGIN_CLASSPATH_CONFIGURATION_NAME, <plugin module dependecy notation>)
}
That’s the setup. Now I move to the experiment itself.
1. In suppliedTypes module, plugin modifies only existing files. Specifically, it changes (and copies in IR) functions and classes marked with @Suppliable annotation and replaces behaviour of calls to the functions. Yeah, it’s not a simple plugin, but it is tested more or less. And in the following text, it will be used just in one case as a litmus test that the plugins are actually consumed by the compiler.
2. In benchmarksKotlinxBenchmarkSupport module, plugin only creates a new file with a new simple content in it. It’s not tested well. There is exactly one test in it. But it’s obvious to me that the plugin adds a new file. (It’s very bad argumentation. But I hope you believe me here.)
3. Now, I add some code to the Kone-sandbox module and run mingwX64Klib task. After which, I use klib dump-ir from the klib distribution (that is found by path in Kone-sandbox/build/konan.txt) to review the generated bytecode.
4. In the IR I find traces of suppliedTypes compiler plugin. But no traces of a new file that should have been added by the benchmarksKotlinxBenchmarkSupport compiler plugin. (Even the specific package dev.lounres.kone.plugin.benchmarks.kotlinxBenchmarkSupport.generated where the new file should be placed does not appear anywhere.) That’s why I think that the compiler just ignores the file.
So it looks like a compiler bug to me. I can create minimized reproducible example of Kone-snadbox if you (or someone else) need. Should I create a ticket on this in YouTrack? I can also try to create a plugin that adds a new file and changes an existing one to reveal the bug even more so that the example might be more trustworthy.Gleb Minaev
11/08/2026, 11:00 PMbenchmarksKotlinxBenchmarkSupport compiler to do anything on Native platform. This is very stupid of me… But now I have a similar plugin in the same source set that uses FIR for generation of the entry point and shares most of its IR logic with a IR-only version. And this version works perfectly! So I still think it’s an unusual compiler bug.