diff options
| -rw-r--r-- | pkg/bisect/bisect.go | 3 | ||||
| -rw-r--r-- | pkg/bisect/bisect_test.go | 2 | ||||
| -rw-r--r-- | pkg/build/build.go | 1 | ||||
| -rw-r--r-- | pkg/build/linux.go | 19 | ||||
| -rw-r--r-- | pkg/instance/instance.go | 5 | ||||
| -rw-r--r-- | pkg/vcs/linux.go | 1 | ||||
| -rw-r--r-- | syz-ci/jobs.go | 5 | ||||
| -rw-r--r-- | syz-ci/manager.go | 1 | ||||
| -rw-r--r-- | syz-ci/syz-ci.go | 2 | ||||
| -rw-r--r-- | tools/syz-bisect/bisect.go | 2 | ||||
| -rw-r--r-- | tools/syz-testbuild/testbuild.go | 2 |
11 files changed, 35 insertions, 8 deletions
diff --git a/pkg/bisect/bisect.go b/pkg/bisect/bisect.go index cf6bae5bc..75b6450d8 100644 --- a/pkg/bisect/bisect.go +++ b/pkg/bisect/bisect.go @@ -22,6 +22,7 @@ type Config struct { Trace io.Writer Fix bool BinDir string + Ccache string DebugDir string Timeout time.Duration Kernel KernelConfig @@ -448,7 +449,7 @@ func (env *env) build() (*vcs.Commit, string, error) { return nil, "", fmt.Errorf("kernel clean failed: %v", err) } kern := &env.cfg.Kernel - _, kernelSign, err := env.inst.BuildKernel(bisectEnv.Compiler, kern.Userspace, + _, kernelSign, err := env.inst.BuildKernel(bisectEnv.Compiler, env.cfg.Ccache, kern.Userspace, kern.Cmdline, kern.Sysctl, bisectEnv.KernelConfig) if kernelSign != "" { env.log("kernel signature: %v", kernelSign) diff --git a/pkg/bisect/bisect_test.go b/pkg/bisect/bisect_test.go index e60da3aed..ee730b724 100644 --- a/pkg/bisect/bisect_test.go +++ b/pkg/bisect/bisect_test.go @@ -32,7 +32,7 @@ func (env *testEnv) BuildSyzkaller(repo, commit string) error { return nil } -func (env *testEnv) BuildKernel(compilerBin, userspaceDir, cmdlineFile, sysctlFile string, +func (env *testEnv) BuildKernel(compilerBin, cCache, userspaceDir, cmdlineFile, sysctlFile string, kernelConfig []byte) (string, string, error) { commit := env.headCommit() configHash := hash.String(kernelConfig) diff --git a/pkg/build/build.go b/pkg/build/build.go index af2aa91a5..348a18555 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -26,6 +26,7 @@ type Params struct { KernelDir string OutputDir string Compiler string + Ccache string UserspaceDir string CmdlineFile string SysctlFile string diff --git a/pkg/build/linux.go b/pkg/build/linux.go index 34a980b20..6acf6f347 100644 --- a/pkg/build/linux.go +++ b/pkg/build/linux.go @@ -65,7 +65,24 @@ func (linux) buildKernel(params *Params) error { case "ppc64le": target = "zImage" } - if err := runMake(params.KernelDir, target, "CC="+params.Compiler); err != nil { + + ccParam := params.Compiler + if params.Ccache != "" { + ccParam = params.Ccache + " " + ccParam + // Ensure CONFIG_GCC_PLUGIN_RANDSTRUCT doesn't prevent ccache usage. + // See /Documentation/kbuild/reproducible-builds.rst. + gccPluginsDir := filepath.Join(params.KernelDir, "scripts", "gcc-plugins") + if osutil.IsExist(gccPluginsDir) { + err := osutil.WriteFile(filepath.Join(gccPluginsDir, + "randomize_layout_seed.h"), + []byte("const char *randstruct_seed = "+ + "\"e9db0ca5181da2eedb76eba144df7aba4b7f9359040ee58409765f2bdc4cb3b8\";")) + if err != nil { + return err + } + } + } + if err := runMake(params.KernelDir, target, "CC="+ccParam); err != nil { return err } vmlinux := filepath.Join(params.KernelDir, "vmlinux") diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index 201c07cf8..b5cbd3bd2 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -29,7 +29,7 @@ import ( type Env interface { BuildSyzkaller(string, string) error - BuildKernel(string, string, string, string, []byte) (string, string, error) + BuildKernel(string, string, string, string, string, []byte) (string, string, error) Test(numVMs int, reproSyz, reproOpts, reproC []byte) ([]error, error) } @@ -94,7 +94,7 @@ func (env *env) BuildSyzkaller(repo, commit string) error { return nil } -func (env *env) BuildKernel(compilerBin, userspaceDir, cmdlineFile, sysctlFile string, kernelConfig []byte) ( +func (env *env) BuildKernel(compilerBin, ccacheBin, userspaceDir, cmdlineFile, sysctlFile string, kernelConfig []byte) ( string, string, error) { imageDir := filepath.Join(env.cfg.Workdir, "image") params := &build.Params{ @@ -104,6 +104,7 @@ func (env *env) BuildKernel(compilerBin, userspaceDir, cmdlineFile, sysctlFile s KernelDir: env.cfg.KernelSrc, OutputDir: imageDir, Compiler: compilerBin, + Ccache: ccacheBin, UserspaceDir: userspaceDir, CmdlineFile: cmdlineFile, SysctlFile: sysctlFile, diff --git a/pkg/vcs/linux.go b/pkg/vcs/linux.go index 069493411..423919ad6 100644 --- a/pkg/vcs/linux.go +++ b/pkg/vcs/linux.go @@ -124,6 +124,7 @@ func (ctx *linux) EnvForCommit(binDir, commit string, kernelConfig []byte) (*Bis return nil, err } } + return env, nil } diff --git a/syz-ci/jobs.go b/syz-ci/jobs.go index faa35c439..3322609dd 100644 --- a/syz-ci/jobs.go +++ b/syz-ci/jobs.go @@ -405,6 +405,7 @@ func (jp *JobProcessor) bisect(job *Job, mgrcfg *mgrconfig.Config) error { Timeout: 8 * time.Hour, Fix: req.Type == dashapi.JobBisectFix, BinDir: jp.cfg.BisectBinDir, + Ccache: jp.cfg.Ccache, Kernel: bisect.KernelConfig{ Repo: mgr.mgrcfg.Repo, Branch: mgr.mgrcfg.Branch, @@ -527,8 +528,8 @@ func (jp *JobProcessor) testPatch(job *Job, mgrcfg *mgrconfig.Config) error { } log.Logf(0, "job: building kernel...") - kernelConfig, _, err := env.BuildKernel(mgr.mgrcfg.Compiler, mgr.mgrcfg.Userspace, mgr.mgrcfg.KernelCmdline, - mgr.mgrcfg.KernelSysctl, req.KernelConfig) + kernelConfig, _, err := env.BuildKernel(mgr.mgrcfg.Compiler, mgr.mgrcfg.Ccache, mgr.mgrcfg.Userspace, + mgr.mgrcfg.KernelCmdline, mgr.mgrcfg.KernelSysctl, req.KernelConfig) if err != nil { return err } diff --git a/syz-ci/manager.go b/syz-ci/manager.go index 99a2ec44a..ce9b04518 100644 --- a/syz-ci/manager.go +++ b/syz-ci/manager.go @@ -301,6 +301,7 @@ func (mgr *Manager) build(kernelCommit *vcs.Commit) error { KernelDir: mgr.kernelDir, OutputDir: tmpDir, Compiler: mgr.mgrcfg.Compiler, + Ccache: mgr.mgrcfg.Ccache, UserspaceDir: mgr.mgrcfg.Userspace, CmdlineFile: mgr.mgrcfg.KernelCmdline, SysctlFile: mgr.mgrcfg.KernelSysctl, diff --git a/syz-ci/syz-ci.go b/syz-ci/syz-ci.go index faa51f4fc..b696fc8e0 100644 --- a/syz-ci/syz-ci.go +++ b/syz-ci/syz-ci.go @@ -93,6 +93,7 @@ type Config struct { // GCS path to upload coverage reports from managers (optional). CoverUploadPath string `json:"cover_upload_path"` BisectBinDir string `json:"bisect_bin_dir"` + Ccache string `json:"ccache"` Managers []*ManagerConfig `json:"managers"` } @@ -106,6 +107,7 @@ type ManagerConfig struct { RepoAlias string `json:"repo_alias"` Branch string `json:"branch"` // Defaults to "master". Compiler string `json:"compiler"` + Ccache string `json:"ccache"` Userspace string `json:"userspace"` KernelConfig string `json:"kernel_config"` // Baseline config for bisection, see pkg/bisect.KernelConfig.BaselineConfig. diff --git a/tools/syz-bisect/bisect.go b/tools/syz-bisect/bisect.go index c09d000a0..f50b29095 100644 --- a/tools/syz-bisect/bisect.go +++ b/tools/syz-bisect/bisect.go @@ -46,6 +46,7 @@ type Config struct { // gcc versions. A working archive can be downloaded from: // https://storage.googleapis.com/syzkaller/bisect_bin.tar.gz BinDir string `json:"bin_dir"` + Ccache string `json:"ccache"` KernelRepo string `json:"kernel_repo"` KernelBranch string `json:"kernel_branch"` SyzkallerRepo string `json:"syzkaller_repo"` @@ -86,6 +87,7 @@ func main() { Trace: os.Stdout, Fix: *flagFix, BinDir: mycfg.BinDir, + Ccache: mycfg.Ccache, DebugDir: *flagCrash, Kernel: bisect.KernelConfig{ Repo: mycfg.KernelRepo, diff --git a/tools/syz-testbuild/testbuild.go b/tools/syz-testbuild/testbuild.go index fd5a0fea3..f4c108a52 100644 --- a/tools/syz-testbuild/testbuild.go +++ b/tools/syz-testbuild/testbuild.go @@ -128,7 +128,7 @@ func test(repo vcs.Repo, bisecter vcs.Bisecter, kernelConfig []byte, env instanc if err := build.Clean(*flagOS, *flagArch, vmType, *flagKernelSrc); err != nil { fail(err) } - _, _, err = env.BuildKernel(bisectEnv.Compiler, *flagUserspace, + _, _, err = env.BuildKernel(bisectEnv.Compiler, "", *flagUserspace, *flagKernelCmdline, *flagKernelSysctl, bisectEnv.KernelConfig) if err != nil { if verr, ok := err.(*osutil.VerboseError); ok { |
