Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MacOS binaries downloaded from “Releases” fail WASM compilation #4016

Open
@knaka

Description

@knaka

Version

1.29.0

What happened?

MacOS binaries downloaded from Releases fail WASM compilation. As mentioned in the issue below, this is likely because JIT-enabling entitlements are not granted. Therefore, removing the signature allows execution to succeed.

Code-signing entitlements needed for OSX · Issue #2393 · tetratelabs/wazero

Execution fails with the downloaded binary:

$ curl --location -o - https://github.com/sqlc-dev/sqlc/releases/download/v1.29.0/sqlc_1.29.0_darwin_amd64.tar.gz | tar zxf -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 14.9M  100 14.9M    0     0  2902k      0  0:00:05  0:00:05 --:--:-- 3765k
$ ./sqlc generate -f sqlc.yaml
panic: permission denied

        runtime/debug.Stack()
                /Users/runner/hostedtoolcache/go/1.24.2/x64/src/runtime/debug/stack.go:26 +0x5e
        golang.org/x/sync/singleflight.newPanicError({0x10568b560, 0x1052e8d08})
                /Users/runner/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:44 +0x25
        golang.org/x/sync/singleflight.(*Group).doCall.func2.1()
                /Users/runner/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:193 +0x34
        panic({0x10568b560?, 0x1052e8d08?})
                /Users/runner/hostedtoolcache/go/1.24.2/x64/src/runtime/panic.go:792 +0x132
        github.com/tetratelabs/wazero/internal/engine/wazevo.mmapExecutable(...)
                /Users/runner/go/pkg/mod/github.com/tetratelabs/[email protected]/internal/engine/wazevo/engine.go:776
        github.com/tetratelabs/wazero/internal/engine/wazevo.(*engine).compileSharedFunctions(0xc001370e10)
                /Users/runner/go/pkg/mod/github.com/tetratelabs/[email protected]/internal/engine/wazevo/engine.go:605 +0xc71
        github.com/tetratelabs/wazero/internal/engine/wazevo.NewEngine({0x1058afaf0, 0xc0007c4230}, 0x103becc25?, {0x1058acf68, 0xc001076010})
                /Users/runner/go/pkg/mod/github.com/tetratelabs/[email protected]/internal/engine/wazevo/engine.go:115 +0x145
        github.com/tetratelabs/wazero.(*cache).initEngine.func1()
                /Users/runner/go/pkg/mod/github.com/tetratelabs/[email protected]/cache.go:72 +0x45
        sync.(*Once).doSlow(0x104f877bf?, 0x7?)
                /Users/runner/hostedtoolcache/go/1.24.2/x64/src/sync/once.go:78 +0xab
        sync.(*Once).Do(...)
                /Users/runner/hostedtoolcache/go/1.24.2/x64/src/sync/once.go:69
        github.com/tetratelabs/wazero.(*cache).initEngine(0xc0013a0000, 0x0, 0x2f?, {0x1058afaf0?, 0xc0007c4230?}, 0xc00159d9b0?)
                /Users/runner/go/pkg/mod/github.com/tetratelabs/[email protected]/cache.go:72 +0x85
        github.com/tetratelabs/wazero.NewRuntimeWithConfig({0x1058afaf0?, 0xc0007c4230?}, {0x1058ba1d0?, 0xc00159da58})
                /Users/runner/go/pkg/mod/github.com/tetratelabs/[email protected]/runtime.go:175 +0xf6
        github.com/sqlc-dev/sqlc/internal/ext/wasm.(*Runner).loadAndCompileWASM(0xc0012cec00, {0x1058afaf0, 0xc0007c4230}, {0xc000de3c80, 0x28}, {0xc00005a440, 0x40})
                /Users/runner/work/release-workflow/release-workflow/internal/ext/wasm/wasm.go:151 +0x46a
        github.com/sqlc-dev/sqlc/internal/ext/wasm.(*Runner).loadAndCompile.func1()
                /Users/runner/work/release-workflow/release-workflow/internal/ext/wasm/wasm.go:63 +0x2f
        golang.org/x/sync/singleflight.(*Group).doCall.func2(0xc00159dc2e, 0xc0013a05a0, 0x103c45839?)
                /Users/runner/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:198 +0x55
        golang.org/x/sync/singleflight.(*Group).doCall(0x10564eee0?, 0xc000d600f0?, {0xc00005a440?, 0x40?}, 0xc0013a4000?)
                /Users/runner/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:200 +0x7e
        golang.org/x/sync/singleflight.(*Group).Do(0x1070df5a0, {0xc00005a440, 0x40}, 0xc0007e5d00)
                /Users/runner/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:113 +0x15b
        github.com/sqlc-dev/sqlc/internal/ext/wasm.(*Runner).loadAndCompile(0xc0012cec00, {0x1058afaf0, 0xc0007c4230})
                /Users/runner/work/release-workflow/release-workflow/internal/ext/wasm/wasm.go:62 +0xca
        github.com/sqlc-dev/sqlc/internal/ext/wasm.(*Runner).Invoke(0xc0012cec00, {0x1058afaf0, 0xc0007c4230}, {0x104fbf870, 0x1f}, {0x1057b2060?, 0xc000febcb0?}, {0x1057054a0, 0xc0012cec40}, {0x0, ...})
                /Users/runner/work/release-workflow/release-workflow/internal/ext/wasm/wasm.go:206 +0x2b9
        github.com/sqlc-dev/sqlc/internal/plugin.(*codegenServiceClient).Generate(0xc0007e6ac0, {0x1058afaf0, 0xc0007c4230}, 0xc000febcb0, {0x0, 0x0, 0x0})
                /Users/runner/work/release-workflow/release-workflow/internal/plugin/codegen_grpc.pb.go:42 +0xc8
        github.com/sqlc-dev/sqlc/internal/cmd.codegen({_, _}, {{{0x1052e8e30, 0x1}, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...}, ...}, ...)
                /Users/runner/work/release-workflow/release-workflow/internal/cmd/generate.go:411 +0x552
        github.com/sqlc-dev/sqlc/internal/cmd.(*generator).ProcessResult(_, {_, _}, {{{0x1052e8e30, 0x1}, {{0x0, 0x0}, {0x0, 0x0}, {0x0, ...}, ...}, ...}, ...}, ...)
                /Users/runner/work/release-workflow/release-workflow/internal/cmd/generate.go:203 +0xc5
        github.com/sqlc-dev/sqlc/internal/cmd.processQuerySets.func1()
                /Users/runner/work/release-workflow/release-workflow/internal/cmd/process.go:113 +0x93a
        golang.org/x/sync/errgroup.(*Group).Go.func1()
                /Users/runner/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:79 +0x50
        created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
                /Users/runner/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:76 +0x93


goroutine 6 [running]:
golang.org/x/sync/singleflight.(*Group).doCall.func1()
        /Users/runner/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:170 +0x2b2
golang.org/x/sync/singleflight.(*Group).doCall(0x10564eee0?, 0xc000d600f0?, {0xc00005a440?, 0x40?}, 0xc0013a4000?)
        /Users/runner/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:205 +0x99
golang.org/x/sync/singleflight.(*Group).Do(0x1070df5a0, {0xc00005a440, 0x40}, 0xc0007e5d00)
        /Users/runner/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:113 +0x15b
github.com/sqlc-dev/sqlc/internal/ext/wasm.(*Runner).loadAndCompile(0xc0012cec00, {0x1058afaf0, 0xc0007c4230})
        /Users/runner/work/release-workflow/release-workflow/internal/ext/wasm/wasm.go:62 +0xca
github.com/sqlc-dev/sqlc/internal/ext/wasm.(*Runner).Invoke(0xc0012cec00, {0x1058afaf0, 0xc0007c4230}, {0x104fbf870, 0x1f}, {0x1057b2060?, 0xc000febcb0?}, {0x1057054a0, 0xc0012cec40}, {0x0, ...})
        /Users/runner/work/release-workflow/release-workflow/internal/ext/wasm/wasm.go:206 +0x2b9
github.com/sqlc-dev/sqlc/internal/plugin.(*codegenServiceClient).Generate(0xc0007e6ac0, {0x1058afaf0, 0xc0007c4230}, 0xc000febcb0, {0x0, 0x0, 0x0})
        /Users/runner/work/release-workflow/release-workflow/internal/plugin/codegen_grpc.pb.go:42 +0xc8
github.com/sqlc-dev/sqlc/internal/cmd.codegen({_, _}, {{{0x1052e8e30, 0x1}, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...}, ...}, ...)
        /Users/runner/work/release-workflow/release-workflow/internal/cmd/generate.go:411 +0x552
github.com/sqlc-dev/sqlc/internal/cmd.(*generator).ProcessResult(_, {_, _}, {{{0x1052e8e30, 0x1}, {{0x0, 0x0}, {0x0, 0x0}, {0x0, ...}, ...}, ...}, ...}, ...)
        /Users/runner/work/release-workflow/release-workflow/internal/cmd/generate.go:203 +0xc5
github.com/sqlc-dev/sqlc/internal/cmd.processQuerySets.func1()
        /Users/runner/work/release-workflow/release-workflow/internal/cmd/process.go:113 +0x93a
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /Users/runner/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:79 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
        /Users/runner/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:76 +0x93

Removing the signature with the codesign command eliminates the restriction, allowing execution:

$ codesign --remove-signature sqlc
$ ./sqlc generate -f sqlc.yaml
$ ls -l sqlcgen
total 24
-rw-r--r--  1 knaka  wheel   688  7 11 15:29 models.ts
-rw-r--r--  1 knaka  wheel  6393  7 11 15:29 querier.ts
$

Relevant log output

Database schema

SQL queries

Configuration

version: "2"
plugins:
- name: ts-d1
  wasm:
    url: https://github.com/orisano/sqlc-gen-ts-d1/releases/download/v0.0.0-a/sqlc-gen-ts-d1.wasm
    sha256: dfd4bfef4736967ca17cc23d18de20920fbd196998fe7aa191a205439d63fb58
sql:
  - engine: "sqlite"
    queries: "./queries/*"
    schema: "./schema.sql"
    codegen:
    - out: sqlcgen
      plugin: ts-d1

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

SQLite

What type of code are you generating?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions