Skip to content

unknown import, could not find host function for import number: 0 named env.__assert_fail #80

Description

@biggujo

Description

When I try to instantiate gifsicle.wasm (built from https://github.com/kohler/gifsicle), an exception is thrown.

The built binary gifsicle works in the CLI. But gifsicle.wasm does not work with Endive.

Steps to reproduce

  1. Clone https://github.com/biggujo/endive-gifsicle-problem.
  2. Run Main.java.

How to Build WASM

If you need to create a WASM by yourself, do the following.

  1. Clone and open https://github.com/biggujo/endive-autotools.
  2. Build Dockerfile: docker build -t emscripten-autotools:6.0.1 ..
  3. Clone and open https://github.com/kohler/gifsicle.
  4. Build:
docker run \
  --rm \
  -v $(pwd):/src \
  -u $(id -u):$(id -g) \
  emscripten-autotools:6.0.1 \
  autoreconf -i

docker run \
  --rm \
  -v $(pwd):/src \
  -u $(id -u):$(id -g) \
  emscripten-autotools:6.0.1 \
  emconfigure ./configure

docker run \
  --rm \
  -v $(pwd):/src \
  -u $(id -u):$(id -g) \
  emscripten-autotools:6.0.1 \
  emmake make
  1. Copy src/gifsicle.wasm to endive-gifsicle-problem repository folder: endive-gifsicle-problem/src/main/resources/gifsicle.wasm.

Expected Behavior

  1. gifsicle works in CLI (if you run src/gifsicle after build).
  2. gifsicle works in Endive.

Actual Behavior

  1. gifsicle works in CLI (if you run src/gifsicle after build).
  2. gifsicle does not work in Endive.

Attachments

Java source code:

package com.example;

import run.endive.wasm.Parser;
import run.endive.runtime.Instance;
import java.io.File;
import java.net.URISyntaxException;

public class Main {
  static void main() throws URISyntaxException {
    var file = new File(Main.class.getResource("/gifsicle.wasm").toURI());
    var module = Parser.parse(file);
    var instance = Instance.builder(module).build(); // throws here
  }
}

Exception output:

Exception in thread "main" run.endive.wasm.UnlinkableException: unknown import, could not find host function for import number: 0 named env.__assert_fail
	at run.endive.runtime.Instance$Builder.mapHostImports(Instance.java:1013)
	at run.endive.runtime.Instance$Builder.build(Instance.java:1075)
	at ua.karazin.Main.main(Main.java:12)

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>endive-gifsicle-problem</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>25</maven.compiler.source>
        <maven.compiler.target>25</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>run.endive</groupId>
            <artifactId>runtime</artifactId>
            <version>1.0.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>

Screenshot of the built working gifsicle in CLI:

Image

Occurrence Frequency

3/3. I tried building WASM multiple times.

Environment

  • macOS 15.5 (24F74).
  • Docker version 28.1.1, build 4eba377.

Java:

openjdk version "25" 2025-09-16
OpenJDK Runtime Environment (build 25+36-3489)
OpenJDK 64-Bit Server VM (build 25+36-3489, mixed mode, sharing)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions