blob: 2adc06a2bc5fbf042d46fe3e8358a9f0c4c26930 [file] [log] [blame]
Patrick Williams2390b1b2022-11-03 13:47:49 -05001DESCRIPTION = "syzkaller is an unsupervised coverage-guided kernel fuzzer"
2LICENSE = "Apache-2.0"
3LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=5335066555b14d832335aa4660d6c376"
4
5inherit go-mod
6
7GO_IMPORT = "github.com/google/syzkaller"
8
9SRC_URI = "git://${GO_IMPORT};protocol=https;destsuffix=${BPN}-${PV}/src/${GO_IMPORT};branch=master \
10 file://0001-sys-targets-targets.go-allow-users-to-override-hardc.patch;patchdir=src/${GO_IMPORT} \
Patrick Williams520786c2023-06-25 16:20:36 -050011 file://0001-executor-Include-missing-linux-falloc.h.patch;patchdir=src/${GO_IMPORT} \
Patrick Williams2390b1b2022-11-03 13:47:49 -050012 "
Patrick Williams520786c2023-06-25 16:20:36 -050013SRCREV = "6d01f20890edf11b99bb54573025b11c1acd2d52"
Patrick Williams2390b1b2022-11-03 13:47:49 -050014
15COMPATIBLE_HOST = "(x86_64|i.86|arm|aarch64).*-linux"
16
17B = "${S}/src/${GO_IMPORT}/bin"
18
19GO_EXTRA_LDFLAGS += ' -X ${GO_IMPORT}/prog.GitRevision=${SRCREV}'
20
21export GOHOSTFLAGS="${GO_LINKSHARED} ${GOBUILDFLAGS}"
22export GOTARGETFLAGS="${GO_LINKSHARED} ${GOBUILDFLAGS}"
23export TARGETOS = '${GOOS}'
24export TARGETARCH = '${GOARCH}'
25export TARGETVMARCH = '${GOARCH}'
26
Patrick Williams520786c2023-06-25 16:20:36 -050027CGO_ENABLED = "1"
Patrick Williams2390b1b2022-11-03 13:47:49 -050028
29DEPENDS:class-native += "qemu-system-native"
30
31do_compile:class-native() {
32 export HOSTOS="${GOHOSTOS}"
33 export HOSTARCH="${GOHOSTARCH}"
34
35 oe_runmake HOSTGO="${GO}" host
36}
37
38do_compile:class-target() {
39 export HOSTOS="${GOOS}"
40 export HOSTARCH="${GOARCH}"
41 export SYZ_CC_${TARGETOS}_${TARGETARCH}="${CC}"
42
43 # Unset GOOS and GOARCH so that the correct syz-sysgen binary can be
44 # generated. Fixes:
45 # go install: cannot install cross-compiled binaries when GOBIN is set
46 unset GOOS
47 unset GOARCH
48
49 oe_runmake GO="${GO}" CC="${CXX}" CFLAGS="${CXXFLAGS} ${LDFLAGS}" REV=${SRCREV} target
50}
51
52do_install:class-native() {
53 SYZ_BINS_NATIVE="syz-manager syz-runtest syz-repro syz-mutate syz-prog2c \
54 syz-db syz-upgrade"
55
56 install -d ${D}${bindir}
57
58 for i in ${SYZ_BINS_NATIVE}; do
59 install -m 0755 ${B}/${i} ${D}${bindir}
60 done
61}
62
63do_install:class-target() {
64 SYZ_TARGET_DIR="${TARGETOS}_${TARGETARCH}"
65 SYZ_BINS_TARGET="syz-fuzzer syz-execprog syz-stress syz-executor"
66
67 install -d ${D}${bindir}/${SYZ_TARGET_DIR}
68
69 for i in ${SYZ_BINS_TARGET}; do
70 install -m 0755 ${B}/${SYZ_TARGET_DIR}/${i} ${D}${bindir}/${SYZ_TARGET_DIR}
71 done
72}
73
74BBCLASSEXTEND += "native"