Hi everyone, I'm working on a Kotlin Multiplatform...
# webassembly
a
Hi everyone, I'm working on a Kotlin Multiplatform project and encountering issues with .wasm file validation. I created a minimal test setup with the following code: kotlin
Copy code
@JsExport
fun sayHello(): Int { return 42 }
When I validate the output with: bash
Copy code
wasm-validate multiplatformlib.wasm
I get the error:
Copy code
000002a: error: expected valid result type (got -0xf)
Has anyone else encountered this issue with Kotlin 2.1.21 and WASM validation? Any suggestions on why the .wasm file validation is failing or how to fix it? Thanks!
My Gradle configuration: kotlin
Copy code
@file:OptIn(ExperimentalWasmDsl::class)
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

plugins {
    id(libs.plugins.myapp.kotlin.multiplatform.get().pluginId)
}

kotlin {
    wasmJs {
        binaries.library()
        browser()
    }
    sourceSets {
        val wasmJsMain by getting {
            kotlin.srcDir("src/wasmJsMain/kotlin")
        }
    }
}
I'm using Kotlin version 2.1.21 and generating the .wasm file with: bash
Copy code
./gradlew :shared:data:minimalwasm:clean :shared:data:minimalwasm:wasmJsProductionLibraryCompileSync
i
Hi, how did you run it?
a
Hi! This is the command i used to validate the .wasm bash
Copy code
wasm-validate multiplatformlib.wasm
and to generate it i used ./gradlew shareddataminimalwasmclean shareddataminimalwasmwasmJsProductionLibraryCompileSync
i
I believe that wasm-validate could be outdated and not supporting wasm GC proposal
a
I see, is there another way i can check the .wasm file is valid?
i
Try to check if your wasm-validate supports wasm-gc proposal and update it if needed..you can also validate it with nodejs using https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/JavaScript_interface/validate_static
a
Will try thank you color
So i used the WebAssembly.validate fun and it seems to be a valid file 🥳
K 1