Skip to content
Snippets Groups Projects
Unverified Commit f92702dc authored by Clayton Craft's avatar Clayton Craft :speech_balloon:
Browse files

main/postmarketos-mkinitfs: add workaround for x86_64 qemu on aarch64 (MR 5653)

This adds a workaround for:
https://gitlab.com/qemu-project/qemu/-/issues/2560

The tl;dr is that there's a qemu bug that prevents running mkinitfs (or
any go apps) on a aarch64 host using qemu-x86_64. I've basically been
unable to build x86_64 images on my aarch64 system for months now, which
is less than ideal :(

Patch is in mkinitfs 2.6.1, but picked to the older version in master until !5636 is merged

[ci:skip-build]: already built successfully in CI
parent 993b5d15
No related branches found
No related tags found
No related merge requests found
Pipeline #206490 passed
From d63e60061419cb1cb1591c9f7f5f238d1201b7f1 Mon Sep 17 00:00:00 2001
From: Clayton Craft <clayton@craftyguy.net>
Date: Sat, 28 Sep 2024 08:11:19 -0700
Subject: [PATCH] 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
---
Makefile | 5 +++++
cmd/mkinitfs/main.go | 8 ++++++++
2 files changed, 13 insertions(+)
diff --git a/Makefile b/Makefile
index e4fbcdd..0b1e841 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,11 @@ GOFLAGS?=
LDFLAGS+=-s -w -X main.Version=$(VERSION)
RM?=rm -f
GOTEST=go test -count=1 -race
+DISABLE_GOGC?=
+
+ifeq ($(DISABLE_GOGC),1)
+ LDFLAGS+=-X main.DisableGC=true
+endif
GOSRC!=find * -name '*.go'
GOSRC+=go.mod go.sum
diff --git a/cmd/mkinitfs/main.go b/cmd/mkinitfs/main.go
index 138667b..6494504 100644
--- a/cmd/mkinitfs/main.go
+++ b/cmd/mkinitfs/main.go
@@ -9,6 +9,8 @@ import (
"log"
"os"
"path/filepath"
+ "runtime/debug"
+ "strings"
"time"
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/archive"
@@ -26,8 +28,14 @@ import (
// set at build time
var Version string
+var DisableGC string
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
defer func() { os.Exit(retCode) }()
--
2.46.2
......@@ -2,7 +2,7 @@
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=postmarketos-mkinitfs
pkgver=2.5.1
pkgrel=0
pkgrel=1
pkgdesc="Tool to generate initramfs images for postmarketOS"
url="https://postmarketos.org"
depends="
......@@ -26,6 +26,7 @@ triggers="$pkgname.trigger=\
source="
https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/archive/$pkgver/postmarketos-mkinitfs-$pkgver.tar.gz
https://gitlab.com/api/v4/projects/postmarketOS%2Fpostmarketos-mkinitfs/packages/generic/mkinitfs-vendor-$pkgver/$pkgver/mkinitfs-vendor-$pkgver.tar.gz
0001-add-compile-time-flag-to-disable-Go-GC-MR-56.patch
"
install="$pkgname.post-upgrade"
......@@ -47,7 +48,15 @@ prepare() {
build() {
unset LDFLAGS # passed to Go as linker flags, which are invalid
make VERSION="$pkgver"
# Go garbage collector malfunctions when running x86_64 binaries in QEMU on
# an aarch64 host. See: https://gitlab.com/qemu-project/qemu/-/issues/2560
case "$CARCH" in
x86_64)
make VERSION="$pkgver" DISABLE_GOGC=1 ;;
*)
make VERSION="$pkgver" ;;
esac
}
package() {
......@@ -61,4 +70,5 @@ check() {
sha512sums="
6f2e5c8281a8e6b340f2288b31fb102dcc98480e8bf905bf57a54a81d36a5615b194f0a56f5cd3be207784278257eb6ee3dfecaccb60c3332f4d0f45bafedaa3 postmarketos-mkinitfs-2.5.1.tar.gz
420e4bd8126f765c18b3ea48b2dc7356727958826dbe1086b753f5d46bc9b56d25ed668db8f9f4e8c9d5b1e943105850071c9c3ce442daf12eaa80516e973372 mkinitfs-vendor-2.5.1.tar.gz
2af899c69cbdc84ca85f2a5fe609974b2b9e4c0389d9487596d86d403e55b09fdc2e7daf4452bf33b8a27a2b37339d9311b8d1f903074a1410689665425b7d68 0001-add-compile-time-flag-to-disable-Go-GC-MR-56.patch
"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment