aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>2019-03-26 14:36:39 +1100
committerDmitry Vyukov <dvyukov@google.com>2019-05-03 10:00:16 +0200
commit90c8f82ae8f12735e0e06d422dfea80758aaf0a5 (patch)
treebf6d82e78966fb6d64ea7178d7ed8adfbfc92b2c /pkg
parent0642ca0c5c781f144cabb6e4b811a6714d5eed51 (diff)
pkg/build: Add ppc64le Linux as a supported configuration
Enable the Linux builder for ppc64le. For ppc64le, we use zImage rather than bzImage as our kernel target. Pass through the target architecture to buildKernel() so we can pick the right target based on arch. Closes: #1084 ("pkg/build: Support building Linux on ppc64le") Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/build/build.go1
-rw-r--r--pkg/build/linux.go29
2 files changed, 24 insertions, 6 deletions
diff --git a/pkg/build/build.go b/pkg/build/build.go
index 8ccbe9e3d..7e2a71ae4 100644
--- a/pkg/build/build.go
+++ b/pkg/build/build.go
@@ -72,6 +72,7 @@ func getBuilder(targetOS, targetArch, vmType string) (builder, error) {
}{
{"linux", "amd64", []string{"gvisor"}, gvisor{}},
{"linux", "amd64", []string{"gce", "qemu"}, linux{}},
+ {"linux", "ppc64le", []string{"qemu"}, linux{}},
{"fuchsia", "amd64", []string{"qemu"}, fuchsia{}},
{"fuchsia", "arm64", []string{"qemu"}, fuchsia{}},
{"akaros", "amd64", []string{"qemu"}, akaros{}},
diff --git a/pkg/build/linux.go b/pkg/build/linux.go
index e3c8a6d9f..c56595743 100644
--- a/pkg/build/linux.go
+++ b/pkg/build/linux.go
@@ -25,7 +25,7 @@ type linux struct{}
func (linux linux) build(targetArch, vmType, kernelDir, outputDir, compiler, userspaceDir,
cmdlineFile, sysctlFile string, config []byte) error {
- if err := linux.buildKernel(kernelDir, outputDir, compiler, config); err != nil {
+ if err := linux.buildKernel(targetArch, kernelDir, outputDir, compiler, config); err != nil {
return err
}
if err := linux.createImage(targetArch, vmType, kernelDir, outputDir, userspaceDir, cmdlineFile,
@@ -35,7 +35,7 @@ func (linux linux) build(targetArch, vmType, kernelDir, outputDir, compiler, use
return nil
}
-func (linux) buildKernel(kernelDir, outputDir, compiler string, config []byte) error {
+func (linux) buildKernel(targetArch, kernelDir, outputDir, compiler string, config []byte) error {
configFile := filepath.Join(kernelDir, ".config")
if err := osutil.WriteFile(configFile, config); err != nil {
return fmt.Errorf("failed to write config file: %v", err)
@@ -59,9 +59,18 @@ func (linux) buildKernel(kernelDir, outputDir, compiler string, config []byte) e
if err := osutil.CopyFile(configFile, outputConfig); err != nil {
return err
}
- // We build only bzImage as we currently don't use modules.
+ // We build only zImage/bzImage as we currently don't use modules.
cpu := strconv.Itoa(runtime.NumCPU())
- cmd = osutil.Command("make", "bzImage", "-j", cpu, "CC="+compiler)
+
+ var target string
+ switch targetArch {
+ case "386", "amd64":
+ target = "bzImage"
+ case "ppc64le":
+ target = "zImage"
+ }
+ cmd = osutil.Command("make", target, "-j", cpu, "CC="+compiler)
+
if err := osutil.Sandbox(cmd, true, true); err != nil {
return err
}
@@ -87,8 +96,16 @@ func (linux) createImage(targetArch, vmType, kernelDir, outputDir, userspaceDir,
if err := osutil.WriteExecFile(scriptFile, []byte(createImageScript)); err != nil {
return fmt.Errorf("failed to write script file: %v", err)
}
- bzImage := filepath.Join(kernelDir, filepath.FromSlash("arch/x86/boot/bzImage"))
- cmd := osutil.Command(scriptFile, userspaceDir, bzImage, targetArch)
+
+ var kernelImage string
+ switch targetArch {
+ case "386", "amd64":
+ kernelImage = "arch/x86/boot/bzImage"
+ case "ppc64le":
+ kernelImage = "arch/powerpc/boot/zImage.pseries"
+ }
+ kernelImagePath := filepath.Join(kernelDir, filepath.FromSlash(kernelImage))
+ cmd := osutil.Command(scriptFile, userspaceDir, kernelImagePath, targetArch)
cmd.Dir = tempDir
cmd.Env = append([]string{}, os.Environ()...)
cmd.Env = append(cmd.Env,