Chore: Disable cgo by default for local builds (#111807)

* disable cgo by default for local builds, also set cgo variable in either case

* actually do not set the default value

* disable cgo for darwin, display sqlite driver in logs

* fix linter warning, although I do not fully agree with it
This commit is contained in:
Serge Zaitsev
2025-09-30 23:06:40 +02:00
committed by GitHub
parent 901dd9506f
commit 174e924e15
5 changed files with 22 additions and 8 deletions
+9 -5
View File
@@ -18,6 +18,7 @@ import (
const (
GoOSWindows = "windows"
GoOSLinux = "linux"
GoOSDarwin = "darwin"
BackendBinary = "grafana"
ServerBinary = "grafana-server"
@@ -288,8 +289,9 @@ func setBuildEnv(opts BuildOpts) error {
}
}
if opts.goarch != "amd64" || opts.goos != GoOSLinux {
// needed for all other archs
if (opts.goos != GoOSLinux || opts.goarch != "amd64") &&
opts.goos != GoOSDarwin {
// needed for archs other than linux/amd64 and darwin/arm64 + darwin/amd64
opts.cgo = true
}
@@ -307,10 +309,12 @@ func setBuildEnv(opts BuildOpts) error {
}
}
cgoEnabled := "0"
if opts.cgo {
if err := os.Setenv("CGO_ENABLED", "1"); err != nil {
return err
}
cgoEnabled = "1"
}
if err := os.Setenv("CGO_ENABLED", cgoEnabled); err != nil {
return err
}
if opts.gocc == "" {