Kotinc gives up trying to compile wasm2kotlin'ed lua

uh can’t upload 20MB .kt files here so have a github: https://github.com/SoniEx2/kotlinc_bug

it seems kotlinc just gives up when compiling this, as the generated jar doesn’t have any of the lua-related stuff.

kotlinc version:

$ kotlinc -version
info: kotlinc-jvm 1.4.20 (JRE 1.8.0_265-b01)

build command:

JAVA_OPTS='-Xmx2G -Xms32M' kotlinc -d lua53.jar lua.kt wasm_rt_impl.kt

Why do you have a 20mb source file? I mean maybe you could argue that the compiler should still be able to handle this but I don’t think so.
Any decent best practice guide will tell you that a file should only contain a single class (maybe a handful if they are strongly related) or a few utility functions grouped by topic. In any case anything above a few hundred lines of code(lets say more than 400-500) is a sign that your code has some design issues that should be fixed and 20mb is way above that. Even for generated code that is just excessive.


Don’t think anyone here in this forum can help you directly (except for maybe advising you to split up the file). If you want to file a bug report you can do that at https://kotl.in/issue. Although I wouldn’t get my hopes up. I don’t think this sort of issue will be a priority but I can always be wrong.

1 Like

It’s definitely not excessive for generated code, keeping in mind this isn’t bindings, but transpilation.

The original source is about 400kB of C code. The generated kotlin is 20MB. It is also basically “amalgamated” so every C source file gets combined together into one kotlin file. Except it does that by turning the C into a binary first.

But we’ll check out kotl.in/issue. Thanks.

1 Like