When switching to Kotlin 2.10-Beta2 from 2.10-Beta...
# webassembly
p
When switching to Kotlin 2.10-Beta2 from 2.10-Beta1 got error while building production. (More in thread...)
Copy code
Fatal: Internal GlobalTypeRewriter build error: Heap type has an invalid supertype at index 6

Execution failed for task ':app:compileProductionExecutableKotlinWasmJsOptimize'.
> Process 'command '/home/user/.gradle/binaryen/binaryen-version_119/bin/wasm-opt'' finished with non-zero exit value 1
Only Compose compiler plugin is used
Is it known issue?
Development build is fine while building and at runtime.
If it is not known issue, please advice where to dig to be able to narrow project to make reproducible.
b
Looks like a but in binaryen we using for optimization in production. Could you please file an issue there? (And share it here)
b
Great, thanks for the report!
@PHondogo I’m wondering if could share the original kotlin project as well.
p
I'll try to extract problem source then. Now for wasm repro it can have some private code, sources of which i need to remove.
🙏 1
@bashor there is one comment in issue that i've created. I don't know what they are talking about (i'm not working with wasm directly), but i think it gives you some info that helps to make generated code Kotlin->Wasm more optimized/minimized. Here is the link to this comment: https://github.com/WebAssembly/binaryen/issues/7015#issuecomment-2420308261
b
@PHondogo thanks!
@PHondogo I guess you have
suspend fun main
in the code, could you please try the same without it?
👍 1
p
It helps! Thanks!
@bashor by the way, i noticed when Gradle task compileProductionExecutableKotlinWasmJsOptimize calling wasm-opt command there are several O3 and Oz options passed. Is it expected? The command for reference:
Copy code
/home/user/.gradle/binaryen/binaryen-version_119/bin/wasm-opt --enable-gc --enable-reference-types --enable-exception-handling --enable-bulk-memory --enable-nontrapping-float-to-int --closed-world --inline-functions-with-loops --traps-never-happen --fast-math --type-ssa -O3 -O3 --gufa -O3 --type-merging -O3 -Oz in.wasm -o out.wasm
b
@PHondogo yes, it’s intended, it’s a way to setup optimization pipeline in binaryen, here is a reference.
🙏 1
@PHondogo am I right that in the original code your
suspend fun main
had
@JsExport
annotation? If so, I’m wondering why.
p
No. I have no annotations on 'suspend fun main()'
🙏 1