From 8f80acb64fe8e201a15f3bb3de600c7cb1c8f547 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Tue, 14 Jan 2025 15:05:09 -0800 Subject: [PATCH] fix(templates/http-go): Remove scheduler flag from http-go build command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes the `-scheduler=none` flag from the build command in the http-go template. Including this flag prevents Spin applications using `http.Transport` from compiling. ``` ❯ spin build Building component http-roundtrip-test with `tinygo build -target=wasip1 -gc=leaking -scheduler=none -buildmode=c-shared -no-debug -o main.wasm .` /opt/homebrew/Cellar/tinygo/0.35.0/src/net/http/transfer.go:213:2: attempted to start a goroutine without a scheduler Error: Build command for component http-roundtrip-test failed with status Exited(1) ``` Signed-off-by: Adam Reese --- crates/componentize/src/lib.rs | 3 ++- crates/componentize/tests/go-case/main.go | 12 +++++------- crates/componentize/tests/go-case/spin.toml | 2 +- templates/http-go/content/spin.toml | 2 +- templates/http-go/metadata/snippets/component.txt | 2 +- templates/redis-go/content/spin.toml | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/componentize/src/lib.rs b/crates/componentize/src/lib.rs index 5728f19f21..e328245c35 100644 --- a/crates/componentize/src/lib.rs +++ b/crates/componentize/src/lib.rs @@ -440,8 +440,9 @@ mod tests { let mut cmd = process::Command::new("tinygo"); cmd.arg("build") .current_dir("tests/go-case") - .arg("-target=wasi") + .arg("-target=wasip1") .arg("-gc=leaking") + .arg("-buildmode=c-shared") .arg("-no-debug") .arg("-o") .arg(out_dir.join("go_case.wasm")) diff --git a/crates/componentize/tests/go-case/main.go b/crates/componentize/tests/go-case/main.go index cde630fc5a..690a0134a8 100644 --- a/crates/componentize/tests/go-case/main.go +++ b/crates/componentize/tests/go-case/main.go @@ -1,16 +1,16 @@ package main import ( - "fmt" - "net/http" "errors" - "strings" + "fmt" "io" + "net/http" "os" + "strings" - spinredis "github.com/fermyon/spin/sdk/go/redis" - spinhttp "github.com/fermyon/spin/sdk/go/http" spinconfig "github.com/fermyon/spin/sdk/go/config" + spinhttp "github.com/fermyon/spin/sdk/go/http" + spinredis "github.com/fermyon/spin/sdk/go/redis" ) func init() { @@ -65,5 +65,3 @@ func execute(v []string) error { return nil } - -func main() {} diff --git a/crates/componentize/tests/go-case/spin.toml b/crates/componentize/tests/go-case/spin.toml index 6597980c02..04c163b975 100644 --- a/crates/componentize/tests/go-case/spin.toml +++ b/crates/componentize/tests/go-case/spin.toml @@ -12,4 +12,4 @@ allowed_http_hosts = [] [component.trigger] route = "/..." [component.build] -command = "tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go" +command = "tinygo build -target=wasip1 -gc=leaking -buildmode=c-shared -no-debug -o main.wasm ." diff --git a/templates/http-go/content/spin.toml b/templates/http-go/content/spin.toml index 326a5ddc81..73d06e2d14 100644 --- a/templates/http-go/content/spin.toml +++ b/templates/http-go/content/spin.toml @@ -14,5 +14,5 @@ component = "{{project-name | kebab_case}}" source = "main.wasm" allowed_outbound_hosts = [] [component.{{project-name | kebab_case}}.build] -command = "tinygo build -target=wasip1 -gc=leaking -scheduler=none -buildmode=c-shared -no-debug -o main.wasm ." +command = "tinygo build -target=wasip1 -gc=leaking -buildmode=c-shared -no-debug -o main.wasm ." watch = ["**/*.go", "go.mod"] diff --git a/templates/http-go/metadata/snippets/component.txt b/templates/http-go/metadata/snippets/component.txt index 4fbb89ba25..54e38762d9 100644 --- a/templates/http-go/metadata/snippets/component.txt +++ b/templates/http-go/metadata/snippets/component.txt @@ -6,6 +6,6 @@ component = "{{project-name | kebab_case}}" source = "{{ output-path }}/main.wasm" allowed_outbound_hosts = [] [component.{{project-name | kebab_case}}.build] -command = "tinygo build -target=wasip1 -gc=leaking -scheduler=none -buildmode=c-shared -no-debug -o main.wasm ." +command = "tinygo build -target=wasip1 -gc=leaking -buildmode=c-shared -no-debug -o main.wasm ." workdir = "{{ output-path }}" watch = ["**/*.go", "go.mod"] diff --git a/templates/redis-go/content/spin.toml b/templates/redis-go/content/spin.toml index 9ccc0ca3d9..7997e51fac 100644 --- a/templates/redis-go/content/spin.toml +++ b/templates/redis-go/content/spin.toml @@ -17,4 +17,4 @@ component = "{{project-name | kebab_case}}" source = "main.wasm" allowed_outbound_hosts = [] [component.{{project-name | kebab_case}}.build] -command = "tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go" +command = "tinygo build -target=wasip1 -gc=leaking -buildmode=c-shared -no-debug -o main.wasm ."