Files
honggfuzz/honggfuzz.spec
2026-04-26 17:33:50 +08:00

117 lines
4.1 KiB
RPMSpec

# SPDX-FileCopyrightText: (C) 2026 Institute of Software, Chinese Academy of Sciences (ISCAS)
# SPDX-FileCopyrightText: (C) 2026 openRuyi Project Contributors
# SPDX-FileContributor: Jvle <keke.oerv@isrc.iscas.ac.cn>
#
# SPDX-License-Identifier: MulanPSL-2.0
%global srcname honggfuzz
Name: %{srcname}
Version: 2.5
Release: %autorelease
Summary: General-purpose, easy-to-use fuzzer
License: ASL 2.0
URL: https://honggfuzz.dev/
VCS: git:https://github.com/google/honggfuzz
#!RemoteAsset: sha256:cf622a22c38ac895017b2dd396df2a007a0d3cf9fbb574c014ee0ded813285f6
Source0: https://github.com/google/honggfuzz/archive/refs/tags/%{version}.tar.gz
# Used for sanity-check in %%check section.
Source1: hello.c
Patch0: 0001-linux-bfd-use-DIAGNOSTIC_ERROR_SWITCH-define-to-figu.patch
BuildRequires: gcc15
BuildRequires: gcc15-c++
BuildRequires: binutils-devel
BuildRequires: libunwind-devel
# This package currently links with lzma but does not require it.
# However we have to keep this BR at the moment until upstream remove
# the link (or edit Makefile). See also:
# https://github.com/google/honggfuzz/issues/332
BuildRequires: xz-devel
BuildRequires: make
BuildRequires: zlib-devel
Requires: gcc15
Requires: gcc15-c++
# Unfortunately it fails unless exactly the same version of clang &
# compiler-rt are installed, but that's a bug in clang not in this
# package.
Requires: clang
Requires: compiler-rt
%description
Honggfuzz is a general-purpose fuzzing tool. Given an input corpus
files, honggfuzz modifies input to a test program and utilize the
ptrace() API/POSIX signal interface to detect and log crashes. It
can also use software or hardware-based code coverage techniques
to produce more and more interesting inputs.
%package devel
Summary: Development files for %{srcname}
Requires: %{srcname}%{?_isa} = %{version}-%{release}
%description devel
Development files for %{srcname}.
%prep
# Disable LTO since it breaks linking.
%define _lto_cflags %{nil}
%autosetup -p1
# The source contains proprietary binary blobs. We remove the entire
# third_party/ subdirectory when repackaging this:
# reference: https://koji.fedoraproject.org/koji/buildinfo?buildID=2494915
rm -rf third_party
%build
# Upstream removes -D_FORTIFY_SOURCE claiming that "fortify-source
# intercepts some functions", so we also remove it here.
%undefine _fortify_level
%make_build
%install
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
mkdir -p $RPM_BUILD_ROOT/%{_includedir}
make install PREFIX=%{_prefix} DESTDIR=$RPM_BUILD_ROOT
# The rule above doesn't preserve links in the installed binaries.
# Recreate them here.
pushd $RPM_BUILD_ROOT%{_bindir}
for f in hfuzz-clang hfuzz-clang++ hfuzz-g++ hfuzz-gcc; do
rm $f
ln hfuzz-cc $f
done
popd
# Make sure the include files aren't chmod +x.
find $RPM_BUILD_ROOT%{_includedir} -type f -exec chmod -x {} \;
%check
# This checks that a simple program can be compiled using the GCC
# wrappers.
ln -s %{SOURCE1} hello.c
ln -s %{SOURCE1} hello.cpp
hfuzz_cc/hfuzz-gcc hello.c -o hello
./hello
hfuzz_cc/hfuzz-g++ hello.cpp -o hello
./hello
%files
%license COPYING
%{_bindir}/honggfuzz
%{_bindir}/hfuzz-cc
%{_bindir}/hfuzz-clang
%{_bindir}/hfuzz-clang++
%{_bindir}/hfuzz-g++
%{_bindir}/hfuzz-gcc
%files devel
%license COPYING
%doc CHANGELOG README.md CONTRIBUTING.md docs/
%{_includedir}/libhfcommon
%{_includedir}/libhfuzz
%{_includedir}/libhnetdriver
%changelog
%{?autochangelog}