google / google/cql

Explore WebAssembly Build (WASM)

Open
#38 0 comments 0 reactions 0 assignees View on GitHub
enhancement exploration
Dominant language
Go
Stars
113
Forks
20
PR merge metrics
No merged PRs in 30d

Description

## Overview
The [Go tool is able to build WebAsssembly binaries](https://go.dev/wiki/WebAssembly) which can be run inside browsers. This capability may allow our CQL evaluation library to run locally within a browser (and rely on static serving instead of a custom server like `cqlplay` currently does).

That said, complex programs seem to run into various issues compiling to WebAssembly. This issue will be a lower-priority tracker for explorations on this front. Help is welcome!

## Progress

Blindly trying to build the CLI with a WASM target results in the following errors:

```
@suyashkumar ➜ /workspaces/cql/cmd/cli (main) $ GOOS=js GOARCH=wasm go1.21.11 build -o main.wasm
# github.com/google/cql/cmd/cli
type:*github.com/google/fhir/go/jsonformat/internal/protopath.Path: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/protopath.(*Path).Append is too big: 0x12c360000
type:*github.com/google/fhir/go/jsonformat/internal/protopath.Path: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/protopath.(*Path).Append is too big: 0x12c360000
type:*github.com/google/fhir/go/jsonformat/internal/protopath.Path: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/protopath.(*Path).IsValid is too big: 0x12c370000
type:*github.com/google/fhir/go/jsonformat/internal/protopath.Path: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/protopath.(*Path).IsValid is too big: 0x12c370000
type:*github.com/google/fhir/go/jsonformat/internal/protopath.Path: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/protopath.(*Path).Parent is too big: 0x12c380000
type:*github.com/google/fhir/go/jsonformat/internal/protopath.Path: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/protopath.(*Path).Parent is too big: 0x12c380000
type:*github.com/google/fhir/go/jsonformat/internal/protopath.Path: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/protopath.(*Path).String is too big: 0x12c390000
type:*github.com/google/fhir/go/jsonformat/internal/protopath.Path: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/protopath.(*Path).String is too big: 0x12c390000
type:*github.com/google/cql/retriever/local.Retriever: non-pc-relative relocation address for github.com/google/cql/retriever/local.(*Retriever).Retrieve is too big: 0x12cb40000
type:*github.com/google/cql/retriever/local.Retriever: non-pc-relative relocation address for github.com/google/cql/retriever/local.(*Retriever).Retrieve is too big: 0x12cb40000
type:*github.com/google/fhir/go/jsonformat/internal/jsonpbhelper.UnmarshalErrorList: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/jsonpbhelper.(*UnmarshalErrorList).Error is too big: 0x12c210000
type:*github.com/google/fhir/go/jsonformat/internal/jsonpbhelper.UnmarshalErrorList: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/jsonpbhelper.(*UnmarshalErrorList).Error is too big: 0x12c210000
type:github.com/google/fhir/go/jsonformat/internal/jsonpbhelper.UnmarshalErrorList: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/jsonpbhelper.(*UnmarshalErrorList).Error is too big: 0x12c210000
type:github.com/google/fhir/go/jsonformat/internal/jsonpbhelper.UnmarshalErrorList: non-pc-relative relocation address for github.com/google/fhir/go/jsonformat/internal/jsonpbhelper.UnmarshalErrorList.Error is too big: 0x12c020000
type:*github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.DataRequirement_CodeFilter_ValueSet: non-pc-relative relocation address for github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.(*DataRequirement_CodeFilter_ValueSet).Descriptor is too big: 0x1068d0000
type:*github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.DataRequirement_CodeFilter_ValueSet: non-pc-relative relocation address for github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.(*DataRequirement_CodeFilter_ValueSet).Descriptor is too big: 0x1068d0000
type:*github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.DataRequirement_CodeFilter_ValueSet: non-pc-relative relocation address for github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.(*DataRequirement_CodeFilter_ValueSet).GetReference is too big: 0x106900000
type:*github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.DataRequirement_CodeFilter_ValueSet: non-pc-relative relocation address for github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.(*DataRequirement_CodeFilter_ValueSet).GetReference is too big: 0x106900000
type:*github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.DataRequirement_CodeFilter_ValueSet: non-pc-relative relocation address for github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.(*DataRequirement_CodeFilter_ValueSet).GetStringValue is too big: 0x1068f0000
type:*github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.DataRequirement_CodeFilter_ValueSet: non-pc-relative relocation address for github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.(*DataRequirement_CodeFilter_ValueSet).GetStringValue is too big: 0x1068f0000
type:*github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.DataRequirement_CodeFilter_ValueSet: non-pc-relative relocation address for github.com/google/fhir/go/proto/google/fhir/proto/stu3/metadatatypes_go_proto.(*DataRequirement_CodeFilter_ValueSet).GetValueSet is too big: 0x1068e0000
/home/codespace/sdk/go1.21.11/pkg/tool/linux_amd64/link: too many errors
type:*github.com/google/fhir/go/proto/google/fhir/proto/stu3/resources_go_proto.ClaimResponse_AddedItem: non-pc-relative relocation address for github.com/google/fhir/go/proto/google/fhir/proto/stu3/resources_go_proto.(*ClaimResponse_AddedItem).Descriptor is too big: 0x118a50000
/home/codespace/sdk/go1.21.11/pkg/tool/linux_amd64/link: too many errors
```

Both `go1.21.11` and `go1.22.3` returned similar errors. I think this issue is related: https://github.com/golang/go/issues/64856 and indicated go1.21 worked for their build, so I tried that to no avail. Need to look more into the issue details to see what might be going on.

At a high-level, many of these seem to be problems related to FHIR proto libraries and the protos themselves, which doesn't surprise me.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.