Skip to content

Enable WASM build/CI: Yams fails to compile on the WASM (WASI) Swift SDK #10

Description

@leogdion

Summary

Contribute can't be built for WebAssembly (wasm32-unknown-wasi) on the nightly Swift 6.4 WASM SDK because its transitive dependency Yams doesn't compile there. As a result the WASM CI leg is disabled for Contribute (the Build on WASM step is gated off via the ENABLE_WASM repo variable).

Root cause

Yams/Sources/Yams/Representer.swift uses the C <float.h> macro DBL_DECIMAL_DIG to serialize Doubles losslessly:

import var _float.DBL_DECIMAL_DIG                              // line 12
let string = String(format: "%.*g", DBL_DECIMAL_DIG, self)    // line 342

On the WASM SDK:

  1. wasm: the WASI libc headers don't expose DBL_DECIMAL_DIG through the _float clang module, so the import is "not in scope" and compilation fails. This is reportedly fixed on Yams main but unreleased in the 6.x line we resolve (from: "6.0.0").
  2. wasm-embedded: additionally has no Foundation, which Yams requires (String(format:), Decoder/Constructor), so it can't build at all.

Options

  • Wait for a Yams release containing the main fix, then bump the dependency.
  • Pin Yams to a main commit that includes the fix.
  • Vendor + patch Yams (as we did for SwiftSoup's Swift 6.4 issue).

Acceptance

  • swift build --swift-sdk <6.4 wasm> succeeds for Contribute, and
  • the WASM CI leg is re-enabled (set the ENABLE_WASM repo variable back to true / remove it).

Context: nightly Swift 6.4 multi-platform CI sweep across the BrightDigit vendored packages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions