blob: b43207f2a70c4bdcd79e1ec9142cd9b8f9921ca1 [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 Williamsb58112e2024-03-07 11:16:36 -060013SRCREV = "25905f5d0a2a7883bd33491997556193582c6059"
14
15export GOPROXY = "https://proxy.golang.org,direct"
16# Workaround for network access issue during compile step.
17# This needs to be fixed in the recipes buildsystem so that
18# it can be accomplished during do_fetch task.
19do_compile[network] = "1"
Patrick Williams2390b1b2022-11-03 13:47:49 -050020
21COMPATIBLE_HOST = "(x86_64|i.86|arm|aarch64).*-linux"
22
23B = "${S}/src/${GO_IMPORT}/bin"
24
25GO_EXTRA_LDFLAGS += ' -X ${GO_IMPORT}/prog.GitRevision=${SRCREV}'
26
27export GOHOSTFLAGS="${GO_LINKSHARED} ${GOBUILDFLAGS}"
28export GOTARGETFLAGS="${GO_LINKSHARED} ${GOBUILDFLAGS}"
29export TARGETOS = '${GOOS}'
30export TARGETARCH = '${GOARCH}'
31export TARGETVMARCH = '${GOARCH}'
32
Patrick Williams520786c2023-06-25 16:20:36 -050033CGO_ENABLED = "1"
Patrick Williams2390b1b2022-11-03 13:47:49 -050034
Patrick Williamsb58112e2024-03-07 11:16:36 -060035LDFLAGS:append:class-target = "${@bb.utils.contains_any("TC_CXX_RUNTIME", "llvm android", " -lc++", " -lstdc++", d)}"
36
Patrick Williams2390b1b2022-11-03 13:47:49 -050037DEPENDS:class-native += "qemu-system-native"
38
39do_compile:class-native() {
40 export HOSTOS="${GOHOSTOS}"
41 export HOSTARCH="${GOHOSTARCH}"
42
43 oe_runmake HOSTGO="${GO}" host
44}
45
46do_compile:class-target() {
47 export HOSTOS="${GOOS}"
48 export HOSTARCH="${GOARCH}"
49 export SYZ_CC_${TARGETOS}_${TARGETARCH}="${CC}"
50
51 # Unset GOOS and GOARCH so that the correct syz-sysgen binary can be
52 # generated. Fixes:
53 # go install: cannot install cross-compiled binaries when GOBIN is set
54 unset GOOS
55 unset GOARCH
56
Patrick Williamsb58112e2024-03-07 11:16:36 -060057 oe_runmake GO="${GO}" CFLAGS="${CXXFLAGS} ${LDFLAGS}" REV=${SRCREV} target
Patrick Williams2390b1b2022-11-03 13:47:49 -050058}
59
60do_install:class-native() {
61 SYZ_BINS_NATIVE="syz-manager syz-runtest syz-repro syz-mutate syz-prog2c \
62 syz-db syz-upgrade"
63
64 install -d ${D}${bindir}
65
66 for i in ${SYZ_BINS_NATIVE}; do
67 install -m 0755 ${B}/${i} ${D}${bindir}
68 done
69}
70
71do_install:class-target() {
72 SYZ_TARGET_DIR="${TARGETOS}_${TARGETARCH}"
73 SYZ_BINS_TARGET="syz-fuzzer syz-execprog syz-stress syz-executor"
74
75 install -d ${D}${bindir}/${SYZ_TARGET_DIR}
76
77 for i in ${SYZ_BINS_TARGET}; do
78 install -m 0755 ${B}/${SYZ_TARGET_DIR}/${i} ${D}${bindir}/${SYZ_TARGET_DIR}
79 done
80}
81
82BBCLASSEXTEND += "native"