Skip to content

Provide missing native 128-bit arithmetic runtime helpers #805

Closed

Description

@LunaStev

Problem

Native i128 division/remainder and u128-to-f32 conversion compile to object files but fail to link on Linux amd64. LLVM introduces arithmetic helper references that wavec does not provide, so otherwise valid programs cannot produce an executable.

Reproduction

Reproduced at 648ade28 on Linux amd64 with LLVM 21.1.8, at both -O0 and -O2:

export(c, "quotient") fun quotient(a: i128, b: i128) -> i128 { return a / b; }
export(c, "remainder") fun remainder(a: i128, b: i128) -> i128 { return a % b; }
export(c, "to_float") fun to_float(value: u128) -> f32 { return value as f32; }
fun main() -> i32 { return 0; }
wavec --std-root ./std build native128.wave -O0 -o native128

The linker reports undefined symbols __divti3, __modti3, and __floatuntisf. Emitting an object with --emit=obj and inspecting it with llvm-nm --undefined-only confirms those references. Repeat with -O2 for the same failure.

Scope

Provide the required native arithmetic support using compiler-owned, freestanding helpers, included only when needed with compiler-private symbols. This design has been approved by @LunaStev. Preserve existing arithmetic semantics and C ABI; do not require users to install compiler-rt, libgcc, or libc. Audit supported native targets for equivalent helper dependencies.

Completion criteria

  • Native wide arithmetic and integer/float conversions link and produce correct results at O0 and O2, including boundary values and signed/unsigned cases.
  • Final artifacts have no unresolved arithmetic helper dependencies, and unused helpers are omitted.
  • Regression coverage preserves the existing wasm64 arithmetic runtime behavior and native C ABI.

Activity

  1. self-assigned this
    on Sep 28, 2026
  2. added
    bug
    on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions