cmd/mbf: optional emulated target architecture
All checks were successful
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 2m48s
Test / ShareFS (push) Successful in 3m42s
Test / Hakurei (push) Successful in 3m50s
Test / Sandbox (race detector) (push) Successful in 5m19s
Test / Hakurei (race detector) (push) Successful in 6m24s
Test / Flake checks (push) Successful in 1m23s
All checks were successful
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 2m48s
Test / ShareFS (push) Successful in 3m42s
Test / Hakurei (push) Successful in 3m50s
Test / Sandbox (race detector) (push) Successful in 5m19s
Test / Hakurei (race detector) (push) Successful in 6m24s
Test / Flake checks (push) Successful in 1m23s
This enables transparent cross-compilation without breaking purity. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -4,10 +4,13 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"hakurei.app/check"
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/internal/pkg"
|
||||
"hakurei.app/internal/rosa"
|
||||
"hakurei.app/message"
|
||||
)
|
||||
|
||||
@@ -22,6 +25,7 @@ type cache struct {
|
||||
cures, jobs int
|
||||
hostAbstract, idle bool
|
||||
verboseInit bool
|
||||
arch string
|
||||
|
||||
base string
|
||||
}
|
||||
@@ -74,6 +78,50 @@ func (cache *cache) open() (err error) {
|
||||
cache.jobs,
|
||||
base,
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
done <- struct{}{}
|
||||
|
||||
if cache.arch != "" && cache.arch != runtime.GOARCH {
|
||||
var (
|
||||
name string
|
||||
offset byte
|
||||
magic string
|
||||
mask string
|
||||
)
|
||||
switch cache.arch {
|
||||
case "riscv64":
|
||||
name = "riscv64"
|
||||
offset = 0
|
||||
magic = "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00"
|
||||
mask = "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
|
||||
|
||||
default:
|
||||
cache.c.Close()
|
||||
err = pkg.UnsupportedArchError(cache.arch)
|
||||
return
|
||||
}
|
||||
|
||||
var pathname *check.Absolute
|
||||
pathname, _, err = cache.c.Cure(rosa.Std.Load(rosa.QEMU))
|
||||
if err != nil {
|
||||
cache.c.Close()
|
||||
return
|
||||
}
|
||||
|
||||
pkg.RegisterArch(cache.arch, container.BinfmtEntry{
|
||||
Offset: offset,
|
||||
Magic: magic,
|
||||
Mask: mask,
|
||||
Interpreter: pathname.Append(
|
||||
"system/bin",
|
||||
"qemu-"+name,
|
||||
),
|
||||
})
|
||||
rosa.DropCaches(cache.arch, rosa.Flags())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user