diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-10-22 13:13:53 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-10-22 13:31:24 +0900 |
| commit | fe1acbe8bc14d8d8ae19e94d2b80576f6d6b183e (patch) | |
| tree | fa95526febe2f625de1fddfe4fa593ea128bd044 /internal/rosa/rosa.go | |
| parent | 9dfbf95db02054204defbe422099c02b790a19fc (diff) | |
internal/rosa: optionally bypass cross-compilation
Cross-compilation is not applicable to everything, and it is quite
wasteful rebuilding the same thing for every architecture when it is
just using host tools to create arch-independent files.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/rosa.go')
| -rw-r--r-- | internal/rosa/rosa.go | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go index e83d7097..2241788f 100644 --- a/internal/rosa/rosa.go +++ b/internal/rosa/rosa.go @@ -267,8 +267,9 @@ function apply { } return t.New(name+"-src", Unversioned, nil, &PackageAttr{ - Paths: paths, - Tools: P{_patch}, + Paths: paths, + Tools: P{_patch}, + NoArch: true, }, &GenericHelper{ Build: buf.String(), }) @@ -302,7 +303,7 @@ type Helper interface { // PackageAttr holds build-system-agnostic attributes. type PackageAttr struct { - // Measure output if populated. Required by [THostNet]. + // Measure output if populated. Required by HostNet. KnownChecksum *pkg.Checksum // Mount the source tree writable. @@ -337,6 +338,8 @@ type PackageAttr struct { // Whether to create [pkg.KindExecNet] instead of [pkg.KindExec]. HostNet bool + // Whether the [Helper] behaves identically across all architectures. + NoArch bool // Inputs added only during cross-compilation. Cross P // Native utilities used by the build process. @@ -405,6 +408,10 @@ func (t Toolchain) New( attr = new(PackageAttr) } + if attr.NoArch { + t = t.native() + } + if attr.Std && !t.stage.isStd() { panic(BootstrapError(name)) } @@ -640,6 +647,17 @@ ln -s ../bin /usr/` ) } +// A CrossError refers to a package that does not support cross-compilation and +// is panicked by the helper implementation. +type CrossError string + +func (e CrossError) Error() string { + return "package " + strconv.Quote(string(e)) + + " does not support cross-compilation" +} + +var _ error = CrossError("") + // GenericHelper directly passes build script segments for invocations of // one-off build scripts too specific to fit into any other [Helper] // implementation, but can still benefit from [Toolchain.New]. @@ -677,14 +695,21 @@ func (attr *GenericHelper) wantsDir() (string, bool) { } // script concatenates specified segments. -func (attr *GenericHelper) script(t Toolchain, _ string) string { +func (attr *GenericHelper) script(t Toolchain, name string) string { if attr == nil { attr = new(GenericHelper) } script := attr.Build if t.cross() { - script = attr.Cross + script + if attr.Cross == "" { + panic(CrossError(name)) + } + cross := attr.Cross + if cross == "\x00" { + cross = "" + } + script = cross + script } if t.opts&OptSkipCheck == 0 { script += attr.Check |
