Skip to content

Commit

Permalink
go extension: build for more platforms, use static binaries
Browse files Browse the repository at this point in the history
The Go extension/hello binaries where build with a dynamically linked glibc on Linux leading to incompatibilities if the build host uses a newer glibc than the execution host. This can be avoided by building the executable statically linked.

see #68608
  • Loading branch information
martinrode committed May 30, 2023
1 parent bdfbaf0 commit 0a74ce2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ extensions:
exec:
service: "exec"
commands:
- prog: "%_exec.pluginDir%/server/extension/hello/hello-%_exec.GOOS%.exe"
- prog: "%_exec.pluginDir%/server/extension/hello/hello-%_exec.GOOS%-%_exec.GOARCH%.exe"
stdin:
type: "body"
stdout:
Expand Down
9 changes: 6 additions & 3 deletions server/extension/hello/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build: ## build Go code
GOOS=linux go build -o hello-linux.exe main.go
GOOS=windows go build -o hello-windows.exe main.go
GOOS=darwin GOARCH=amd64 go build -o hello-darwin.exe main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o hello-linux-amd64.exe main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o hello-linux-arm64.exe main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o hello-darwin-amd64.exe main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o hello-darwin-arm64.exe main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o hello-windows-amd64.exe main.go
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -o hello-windows-arm64.exe main.go

clean: ## remove binaries
rm -f *.exe

0 comments on commit 0a74ce2

Please sign in to comment.