add compile-time flag to disable Go GC (MR 56)

I hate this, but it's the only good way I could find to allow working around this ugly QEMU bug:
https://gitlab.com/qemu-project/qemu/-/issues/2560
This commit is contained in:
Clayton Craft
2024-09-28 08:11:19 -07:00
parent 741c0553d5
commit d63e600614
2 changed files with 13 additions and 0 deletions

View File

@@ -13,6 +13,11 @@ GOFLAGS?=
LDFLAGS+=-s -w -X main.Version=$(VERSION) LDFLAGS+=-s -w -X main.Version=$(VERSION)
RM?=rm -f RM?=rm -f
GOTEST=go test -count=1 -race GOTEST=go test -count=1 -race
DISABLE_GOGC?=
ifeq ($(DISABLE_GOGC),1)
LDFLAGS+=-X main.DisableGC=true
endif
GOSRC!=find * -name '*.go' GOSRC!=find * -name '*.go'
GOSRC+=go.mod go.sum GOSRC+=go.mod go.sum

View File

@@ -9,6 +9,8 @@ import (
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"runtime/debug"
"strings"
"time" "time"
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/archive" "gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/archive"
@@ -26,8 +28,14 @@ import (
// set at build time // set at build time
var Version string var Version string
var DisableGC string
func main() { func main() {
// To allow working around silly GC-related issues, like https://gitlab.com/qemu-project/qemu/-/issues/2560
if strings.ToLower(DisableGC) == "true" {
debug.SetGCPercent(-1)
}
retCode := 0 retCode := 0
defer func() { os.Exit(retCode) }() defer func() { os.Exit(retCode) }()