aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2020-05-14 11:20:37 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-05-15 14:08:01 +0200
commite2993cfc1312e039f8e36a42d264f7a2053f1b7c (patch)
treebd9c4a60d4c42d30e301d66afa2f2eb73d8116b3 /sys
parent2d572622ca6fc1855a3fe275d5a8b992849b48f4 (diff)
targets: replace target.CCompilerPrefix with target.Triple
This field will soon be used in Clang builds. Also, we'd better encapsulate compiler name generation in targets.go Signed-off-by: Alexander Potapenko <glider@google.com>
Diffstat (limited to 'sys')
-rw-r--r--sys/syz-extract/linux.go6
-rw-r--r--sys/targets/targets.go21
2 files changed, 16 insertions, 11 deletions
diff --git a/sys/syz-extract/linux.go b/sys/syz-extract/linux.go
index a153d05f9..5eca07daf 100644
--- a/sys/syz-extract/linux.go
+++ b/sys/syz-extract/linux.go
@@ -89,11 +89,13 @@ func (*linux) prepareArch(arch *Arch) error {
buildDir := arch.buildDir
makeArgs := []string{
"ARCH=" + target.KernelArch,
- "CROSS_COMPILE=" + target.CCompilerPrefix,
"CFLAGS=" + strings.Join(cflags, " "),
"O=" + buildDir,
"-j", fmt.Sprint(runtime.NumCPU()),
}
+ if target.Triple != "" {
+ makeArgs = append(makeArgs, "CROSS_COMPILE="+target.Triple+"-")
+ }
out, err := osutil.RunCmd(time.Hour, kernelDir, "make", append(makeArgs, "defconfig")...)
if err != nil {
return fmt.Errorf("make defconfig failed: %v\n%s", err, out)
@@ -172,7 +174,7 @@ func (*linux) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint
AddSource: "#include <asm/unistd.h>",
ExtractFromELF: true,
}
- cc := arch.target.CCompilerPrefix + "gcc"
+ cc := arch.target.CCompiler
res, undeclared, err := extract(info, cc, args, params)
if err != nil {
return nil, nil, err
diff --git a/sys/targets/targets.go b/sys/targets/targets.go
index efa441e8d..548b114f0 100644
--- a/sys/targets/targets.go
+++ b/sys/targets/targets.go
@@ -24,7 +24,7 @@ type Target struct {
DataOffset uint64
Int64Alignment uint64
CFlags []string
- CCompilerPrefix string
+ Triple string
CCompiler string
KernelArch string
KernelHeaderArch string
@@ -138,7 +138,7 @@ var List = map[string]map[string]*Target{
PtrSize: 8,
PageSize: 4 << 10,
CFlags: []string{"-m64"},
- CCompilerPrefix: "x86_64-linux-gnu-",
+ Triple: "x86_64-linux-gnu",
KernelArch: "x86_64",
KernelHeaderArch: "x86",
NeedSyscallDefine: func(nr uint64) bool {
@@ -153,14 +153,14 @@ var List = map[string]map[string]*Target{
PageSize: 4 << 10,
Int64Alignment: 4,
CFlags: []string{"-m32"},
- CCompilerPrefix: "x86_64-linux-gnu-",
+ Triple: "x86_64-linux-gnu",
KernelArch: "i386",
KernelHeaderArch: "x86",
},
"arm64": {
PtrSize: 8,
PageSize: 4 << 10,
- CCompilerPrefix: "aarch64-linux-gnu-",
+ Triple: "aarch64-linux-gnu",
KernelArch: "arm64",
KernelHeaderArch: "arm64",
},
@@ -169,7 +169,7 @@ var List = map[string]map[string]*Target{
PtrSize: 4,
PageSize: 4 << 10,
CFlags: []string{"-D__LINUX_ARM_ARCH__=6", "-march=armv6"},
- CCompilerPrefix: "arm-linux-gnueabi-",
+ Triple: "arm-linux-gnueabi",
KernelArch: "arm",
KernelHeaderArch: "arm",
},
@@ -178,7 +178,7 @@ var List = map[string]map[string]*Target{
PtrSize: 8,
PageSize: 4 << 10,
CFlags: []string{"-march=mips64r2", "-mabi=64", "-EL"},
- CCompilerPrefix: "mips64el-linux-gnuabi64-",
+ Triple: "mips64el-linux-gnuabi64",
KernelArch: "mips",
KernelHeaderArch: "mips",
},
@@ -186,7 +186,7 @@ var List = map[string]map[string]*Target{
PtrSize: 8,
PageSize: 4 << 10,
CFlags: []string{"-D__powerpc64__"},
- CCompilerPrefix: "powerpc64le-linux-gnu-",
+ Triple: "powerpc64le-linux-gnu",
KernelArch: "powerpc",
KernelHeaderArch: "powerpc",
},
@@ -458,10 +458,13 @@ func initTarget(target *Target, OS, arch string) {
// https://github.com/google/syzkaller/pull/619
// https://github.com/google/syzkaller/issues/387
// https://github.com/google/syzkaller/commit/06db3cec94c54e1cf720cdd5db72761514569d56
- target.CCompilerPrefix = ""
+ target.Triple = ""
}
if target.CCompiler == "" {
- target.CCompiler = target.CCompilerPrefix + "gcc"
+ target.CCompiler = "gcc"
+ if target.Triple != "" {
+ target.CCompiler = target.Triple + "-" + target.CCompiler
+ }
}
if target.CPP == "" {
target.CPP = "cpp"