From 0fb86198533c24d40cbb1ae081d0ba3652cf10f6 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 23 Apr 2022 11:49:48 +0200 Subject: tools/syz-kconf: apply replacement vars to Compiler as well This allows to use compiler dependent on arch and/or from kernel build/source dir. --- tools/syz-kconf/kconf.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/syz-kconf/kconf.go b/tools/syz-kconf/kconf.go index 316ffd3a8..a32b0a61d 100644 --- a/tools/syz-kconf/kconf.go +++ b/tools/syz-kconf/kconf.go @@ -241,8 +241,7 @@ func (ctx *Context) executeShell() error { } args := strings.Split(shell.Cmd, " ") for i := 1; i < len(args); i++ { - args[i] = strings.ReplaceAll(args[i], "${BUILDDIR}", ctx.BuildDir) - args[i] = strings.ReplaceAll(args[i], "${ARCH}", ctx.Target.KernelArch) + args[i] = ctx.replaceVars(args[i]) } if args[0] == "make" { if err := ctx.Make(args[1:]...); err != nil { @@ -426,7 +425,7 @@ func (ctx *Context) Make(args ...string) error { args = append(args, "CROSS_COMPILE="+ctx.Target.Triple+"-") } if ctx.Inst.Compiler != "" { - args = append(args, "CC="+ctx.Inst.Compiler) + args = append(args, "CC="+ctx.replaceVars(ctx.Inst.Compiler)) } else if ctx.Target.KernelCompiler != "" { args = append(args, "CC="+ctx.Target.KernelCompiler) } @@ -434,6 +433,12 @@ func (ctx *Context) Make(args ...string) error { return err } +func (ctx *Context) replaceVars(str string) string { + str = strings.ReplaceAll(str, "${BUILDDIR}", ctx.BuildDir) + str = strings.ReplaceAll(str, "${ARCH}", ctx.Target.KernelArch) + return str +} + func releaseTag(dir string) (string, error) { data, err := ioutil.ReadFile(filepath.Join(dir, "Makefile")) if err != nil { -- cgit mrf-deployment