Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 1 | DESCRIPTION = "syzkaller is an unsupervised coverage-guided kernel fuzzer" |
| 2 | LICENSE = "Apache-2.0" |
| 3 | LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=5335066555b14d832335aa4660d6c376" |
| 4 | |
| 5 | inherit go-mod |
| 6 | |
| 7 | GO_IMPORT = "github.com/google/syzkaller" |
| 8 | |
| 9 | SRC_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 Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 11 | file://0001-executor-Include-missing-linux-falloc.h.patch;patchdir=src/${GO_IMPORT} \ |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 12 | " |
Patrick Williams | b58112e | 2024-03-07 11:16:36 -0600 | [diff] [blame] | 13 | SRCREV = "25905f5d0a2a7883bd33491997556193582c6059" |
| 14 | |
| 15 | export 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. |
| 19 | do_compile[network] = "1" |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 20 | |
| 21 | COMPATIBLE_HOST = "(x86_64|i.86|arm|aarch64).*-linux" |
| 22 | |
| 23 | B = "${S}/src/${GO_IMPORT}/bin" |
| 24 | |
| 25 | GO_EXTRA_LDFLAGS += ' -X ${GO_IMPORT}/prog.GitRevision=${SRCREV}' |
| 26 | |
| 27 | export GOHOSTFLAGS="${GO_LINKSHARED} ${GOBUILDFLAGS}" |
| 28 | export GOTARGETFLAGS="${GO_LINKSHARED} ${GOBUILDFLAGS}" |
| 29 | export TARGETOS = '${GOOS}' |
| 30 | export TARGETARCH = '${GOARCH}' |
| 31 | export TARGETVMARCH = '${GOARCH}' |
| 32 | |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 33 | CGO_ENABLED = "1" |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 34 | |
Patrick Williams | b58112e | 2024-03-07 11:16:36 -0600 | [diff] [blame] | 35 | LDFLAGS:append:class-target = "${@bb.utils.contains_any("TC_CXX_RUNTIME", "llvm android", " -lc++", " -lstdc++", d)}" |
| 36 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 37 | DEPENDS:class-native += "qemu-system-native" |
| 38 | |
| 39 | do_compile:class-native() { |
| 40 | export HOSTOS="${GOHOSTOS}" |
| 41 | export HOSTARCH="${GOHOSTARCH}" |
| 42 | |
| 43 | oe_runmake HOSTGO="${GO}" host |
| 44 | } |
| 45 | |
| 46 | do_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 Williams | b58112e | 2024-03-07 11:16:36 -0600 | [diff] [blame] | 57 | oe_runmake GO="${GO}" CFLAGS="${CXXFLAGS} ${LDFLAGS}" REV=${SRCREV} target |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | do_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 | |
| 71 | do_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 | |
| 82 | BBCLASSEXTEND += "native" |