https://kotlinlang.org logo
#webassembly
Title
# webassembly
a

Alexander Girke

02/25/2023, 7:41 AM
Sorry for spamming this channel, but could you please provide more information on whether Long & ULong are already compiled correctly? I tried to add a parameter with such type to an exported function, but this leads to the following: • JS-related warning is emitted:
Exported declaration uses non-exportable parameter type: ULong
-> seems to be ignorable • .wat file no longer exists • WASM Instance can be instantiated in nodeJs & function called for Long -> for ULong, WASM Instance can not be instantiated due to
Compiling function #656:"fibonacci__JsExportAdapter" failed: type error in branch[0] (expected structref, got i64) @+55427
(function signature looks like
fun fibonacci(n: ULong, a: ULong, b: ULong): ULong
) Also, if I try to add a default value for the parameters
a
&
b
in the ULong case, I get another error:
Duplicate export name 'fibonacci' for function 656 and function 657 @+14021
... Any ideas?
s

sdeleuze

02/25/2023, 7:55 AM
Try maybe with
Long
instead of
ULong
for imports/exports.
a

Alexander Girke

02/25/2023, 8:43 AM
• WASM Instance can be instantiated in nodeJs & function called for Long
Thank you, that's what worked - though the .wat file is still missing. However, the question remains what is going wrong in the ULong case...
s

sdeleuze

02/25/2023, 10:06 AM
Yeah, you will probably need to wait Kotlin/Wasm team feedback on that one
b

bashor

03/08/2023, 11:24 PM
There is a compiler option to turn on wat genration
-Xwasm-generate-wat
Add into your build.gradle.kts something like:
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile>().configureEach {
    kotlinOptions.freeCompilerArgs += listOf(
        "-Xwasm-generate-wat", 
    )
}
4 Views