From d9a893a554d6077f5cab4aa8a81f24213443232e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 2 Aug 2018 19:07:22 +0200 Subject: Makefile: don't compile all targets into target binaries Currently target binaries contain support for all OS/arch combinations. However, obviously a fuchsia target binary won't test windows. For target binaries we need support only for a single target (with the exception of 386/arm target in amd64/arm64 binaries). So compile in only _the_ target into target binaries. This reduces akaros/amd64 fuzzer binary from 33 to 7 MB and execprog from 28 to 2 MB. --- sys/syz-sysgen/sysgen.go | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'sys/syz-sysgen') diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go index 65242910b..467987c45 100644 --- a/sys/syz-sysgen/sysgen.go +++ b/sys/syz-sysgen/sysgen.go @@ -114,6 +114,7 @@ func main() { job.OK = true }() } + writeEmpty(OS) wg.Wait() var syscallArchs []ArchData @@ -160,15 +161,23 @@ func main() { } func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint64, out io.Writer) { - fmt.Fprintf(out, "// AUTOGENERATED FILE\n\n") + tag := fmt.Sprintf("syz_target,syz_os_%v,syz_arch_%v", target.OS, target.Arch) + if target.VMArch != "" { + tag += fmt.Sprintf(" syz_target,syz_os_%v,syz_arch_%v", target.OS, target.VMArch) + } + fmt.Fprintf(out, "// AUTOGENERATED FILE\n") + fmt.Fprintf(out, "// +build !syz_target %v\n\n", tag) fmt.Fprintf(out, "package gen\n\n") - fmt.Fprintf(out, "import . \"github.com/google/syzkaller/prog\"\n\n") + fmt.Fprintf(out, "import . \"github.com/google/syzkaller/prog\"\n") + fmt.Fprintf(out, "import . \"github.com/google/syzkaller/sys/%v\"\n\n", target.OS) - fmt.Fprintf(out, "var Target_%v = &Target{"+ + fmt.Fprintf(out, "func init() {\n") + fmt.Fprintf(out, "\tRegisterTarget(&Target{"+ "OS: %q, Arch: %q, Revision: revision_%v, PtrSize: %v, "+ "PageSize: %v, NumPages: %v, DataOffset: %v, Syscalls: syscalls_%v, "+ - "Resources: resources_%v, Structs: structDescs_%v, Consts: consts_%v}\n\n", - target.Arch, target.OS, target.Arch, target.Arch, target.PtrSize, + "Resources: resources_%v, Structs: structDescs_%v, Consts: consts_%v}, "+ + "InitTarget)\n}\n\n", + target.OS, target.Arch, target.Arch, target.PtrSize, target.PageSize, target.NumPages, target.DataOffset, target.Arch, target.Arch, target.Arch, target.Arch) @@ -196,6 +205,14 @@ func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint fmt.Fprintf(out, "\n\n") } +func writeEmpty(OS string) { + const data = `// AUTOGENERATED FILE +// This file is needed if OS is completely excluded by build tags. +package gen +` + writeSource(filepath.Join("sys", OS, "gen", "empty.go"), []byte(data)) +} + func generateExecutorSyscalls(target *targets.Target, syscalls []*prog.Syscall, rev string) ArchData { data := ArchData{ Revision: rev, -- cgit mrf-deployment