// Toolchain attach / provisioner logic. // // In the Sovereign Coven the user maintains their own GCC/LLVM toolchains. // Instead of downloading pre-built binaries, the engine bind-mounts the // toolchain directory into the sandbox at /usr/cross and prepends it to // PATH so the spell's BUILD script invokes the right compiler. package sandbox import "fmt" // Toolchain represents one user-maintained compiler set. type Toolchain struct { Arch string // x86_64, aarch64 Path string // /opt/sorcery-go/toolchains/aarch64-linux-musl Sysroot string // target rootfs headers/libs } // AttachToolchain bind-mounts the toolchain into the sandbox read-only and // updates the environment so the compiler is picked up transparently. func (b *Box) AttachToolchain(tc Toolchain) error { if tc.Path == "" { return fmt.Errorf("sandbox: toolchain path empty") } b.Binds = append(b.Binds, tc.Path+":/usr/cross:ro") if old, ok := b.Env["PATH"]; ok { b.Env["PATH"] = "/usr/cross/bin:" + old } else { b.Env["PATH"] = "/usr/cross/bin" } b.Env["CROSS_COMPILE"] = tc.Arch + "-linux-musl-" if tc.Sysroot != "" { b.Env["SYSROOT"] = tc.Sysroot } return nil }