Blame perf.spec

Michel Lind cdfa3f
# TODO: reenable once we get a basic build working
Michel Lind cdfa3f
# https://fedoraproject.org/wiki/Changes/SetBuildFlagsBuildCheck
Michel Lind cdfa3f
# see build and install -- CXXFLAGS and LDFLAGS are enough
Michel Lind cdfa3f
# still need to debug
Michel Lind cdfa3f
#undefine _auto_set_build_flags
Michel Lind cdfa3f
Michel Lind cdfa3f
%bcond_without manpages
Michel Lind cdfa3f
Michel Lind 53db11
# requires missing header to be patched in
Michel Lind 53db11
%bcond_without libbpf
Michel Lind 53db11
Michel Lind cdfa3f
%if 0%{?facebook}
Michel Lind cdfa3f
%bcond_with perl
Michel Lind cdfa3f
%else
Michel Lind cdfa3f
%bcond_without perl
Michel Lind cdfa3f
%endif
Michel Lind cdfa3f
Michel Lind 19b6ef
%global tag_version 6.12
Michel Lind cdfa3f
Name:           perf
Michel Lind 19b6ef
Version:        %{tag_version}.0
Michel Lind cdfa3f
Release:        %autorelease
Michel Lind cdfa3f
Summary:        Performance monitoring for the Linux kernel
Michel Lind cdfa3f
Michel Lind cdfa3f
License:        GPL-2.0-only
Michel Lind cdfa3f
URL:            https://perf.wiki.kernel.org/
Michel Lind cdfa3f
Source:         https://mirrors.edge.kernel.org/pub/linux/kernel/tools/perf/v%{version}/perf-%{version}.tar.xz 
Michel Lind 19b6ef
Source1:        https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/arch/arm64/include/uapi/asm/bpf_perf_event.h?h=v%{tag_version}#/bpf_perf_event_arm64.h
Michel Lind 19b6ef
Source2:        https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/arch/s390/include/uapi/asm/bpf_perf_event.h?h=v%{tag_version}#/bpf_perf_event_s390.h
Michel Lind 19b6ef
Michel Lind 19b6ef
# No java-devel
Michel Lind 19b6ef
# No point having a 32-bit perf anyway as even in Fedora the kernel is 64-bit
Michel Lind 19b6ef
ExcludeArch:    %{ix86}
Michel Lind cdfa3f
Michel Lind cdfa3f
BuildRequires:  make
Michel Lind cdfa3f
BuildRequires:  bison
Michel Lind cdfa3f
BuildRequires:  flex
Michel Lind d2c27b
%if 0%{?facebook}
Michel Lind d2c27b
%if 0%{?el9}
Michel Lind d2c27b
# Temporarily pin to building against the older clang
Michel Lind d2c27b
# so this works against an older Stream snapshot
Michel Lind d2c27b
BuildRequires:  clang = 18.1.8-3.el9
Michel Lind d2c27b
BuildRequires:  llvm-devel = 18.1.8-3.el9
Michel Lind d2c27b
%endif
Michel Lind d2c27b
%else
Michel Lind cdfa3f
BuildRequires:  clang
Michel Lind cdfa3f
BuildRequires:  llvm-devel
Michel Lind d2c27b
%endif
Michel Lind d2c27b
BuildRequires:  gcc
Michel Lind cdfa3f
BuildRequires:  binutils-devel
Michel Lind cdfa3f
BuildRequires:  capstone-devel
Michel Lind cdfa3f
BuildRequires:  elfutils-devel
Michel Lind cdfa3f
BuildRequires:  elfutils-libelf-devel
Michel Lind cdfa3f
BuildRequires:  java-devel
Michel Lind cdfa3f
BuildRequires:  libbabeltrace-devel
Michel Lind cdfa3f
BuildRequires:  libcap-devel
Michel Lind cdfa3f
BuildRequires:  libtraceevent-devel
Michel Lind cdfa3f
BuildRequires:  libunwind-devel
Michel Lind cdfa3f
BuildRequires:  libbabeltrace-devel
Michel Lind cdfa3f
BuildRequires:  libpfm-devel
Michel Lind cdfa3f
BuildRequires:  libstdc++-devel
Michel Lind cdfa3f
BuildRequires:  libunwind-devel
Michel Lind cdfa3f
BuildRequires:  numactl-devel
Michel Lind cdfa3f
BuildRequires:  python-devel
Michel Lind cdfa3f
BuildRequires:  python3dist(setuptools)
Michel Lind cdfa3f
BuildRequires:  openssl-devel
Michel Lind cdfa3f
%if %{with perl}
Michel Lind cdfa3f
BuildRequires:  perl-devel
Michel Lind cdfa3f
BuildRequires:  perl-interpreter
Michel Lind cdfa3f
BuildRequires:  perl-ExtUtils-Embed
Michel Lind cdfa3f
%endif
Michel Lind cdfa3f
BuildRequires:  systemtap-sdt-devel
Michel Lind cdfa3f
BuildRequires:  slang-devel
Michel Lind cdfa3f
BuildRequires:  zlib-devel
Michel Lind cdfa3f
%if %{with manpages}
Michel Lind cdfa3f
BuildRequires:  asciidoc
Michel Lind cdfa3f
BuildRequires:  xmlto
Michel Lind cdfa3f
%endif
Michel Lind cdfa3f
Michel Lind cdfa3f
%description
Michel Lind cdfa3f
This package contains the perf tool, which enables performance monitoring
Michel Lind cdfa3f
of the Linux kernel.
Michel Lind cdfa3f
Michel Lind cdfa3f
Michel Lind cdfa3f
%package -n libperf
Michel Lind cdfa3f
Summary:        The perf library from kernel source
Michel Lind cdfa3f
Michel Lind cdfa3f
%description -n libperf
Michel Lind cdfa3f
This package contains the kernel source perf library.
Michel Lind cdfa3f
Michel Lind cdfa3f
Michel Lind cdfa3f
%package -n libperf-devel
Michel Lind cdfa3f
Summary:        Development files for the perf library from kernel source
Michel Lind cdfa3f
Requires:       libperf%{?_isa} = %{version}-%{release}
Michel Lind cdfa3f
Michel Lind cdfa3f
%description -n libperf-devel
Michel Lind cdfa3f
This package includes libraries and header files needed for development
Michel Lind cdfa3f
of applications which use perf library from kernel source.
Michel Lind cdfa3f
Michel Lind cdfa3f
Michel Lind cdfa3f
%package -n python3-perf
Michel Lind cdfa3f
Summary:        Python bindings for apps which will manipulate perf events
Michel Lind cdfa3f
Michel Lind cdfa3f
%description -n python3-perf
Michel Lind cdfa3f
The python3-perf package contains a module that permits applications
Michel Lind cdfa3f
written in the Python programming language to use the interface
Michel Lind cdfa3f
to manipulate perf events.
Michel Lind cdfa3f
Michel Lind 53db11
# technically Makefile.config checks for lib64 but it seems to not work
Michel Lind 53db11
# ifeq ($(SRCARCH)$(IS_64_BIT), x861)
Michel Lind 53db11
%global perf_flags VF=1 prefix=%{_prefix} lib=%{_lib}
Michel Lind 53db11
%if %{without libbpf}
Michel Lind 53db11
%global perf_flags %perf_flags NO_LIBBPF=1
Michel Lind 53db11
%endif
Michel Lind 53db11
%global perf_make %make_build %{perf_flags}
Michel Lind 53db11
%global perf_make_install %make_install %{perf_flags}
Michel Lind 53db11
Michel Lind cdfa3f
Michel Lind cdfa3f
%prep
Michel Lind 53db11
%autosetup -p1
Michel Lind 53db11
%if %{with libbpf}
Michel Lind 53db11
# copy in missing files
Michel Lind 53db11
UAPI_ASM_ARM_DIR=arch/arm64/include/uapi/asm
Michel Lind 19b6ef
UAPI_ASM_S390_DIR=arch/s390/include/uapi/asm
Michel Lind 53db11
mkdir -p $UAPI_ASM_ARM_DIR
Michel Lind 19b6ef
mkdir -p $UAPI_ASM_S390_DIR
Michel Lind 53db11
cp -p %{SOURCE1} $UAPI_ASM_ARM_DIR/bpf_perf_event.h
Michel Lind 19b6ef
cp -p %{SOURCE2} $UAPI_ASM_S390_DIR/bpf_perf_event.h
Michel Lind 53db11
%endif
Michel Lind cdfa3f
Michel Lind cdfa3f
Michel Lind cdfa3f
%build
Michel Lind cdfa3f
unset CXXFLAGS
Michel Lind cdfa3f
unset LDFLAGS
Michel Lind cdfa3f
Michel Lind cdfa3f
# /usr/bin/ld: perf-in.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
Michel Lind cdfa3f
#global optflags %{optflags} -fPIE
Michel Lind cdfa3f
Michel Lind 53db11
%perf_make -C tools/perf
Michel Lind 53db11
Michel Lind 53db11
%perf_make -C tools/lib/perf
Michel Lind cdfa3f
Michel Lind cdfa3f
Michel Lind cdfa3f
%install
Michel Lind cdfa3f
unset CXXFLAGS
Michel Lind cdfa3f
unset LDFLAGS
Michel Lind cdfa3f
Michel Lind 53db11
%perf_make_install -C tools/perf
Michel Lind 53db11
%perf_make_install -C tools/lib/perf
Michel Lind cdfa3f
Michel Lind cdfa3f
# python-perf extension
Michel Lind 53db11
%perf_make_install install-python_ext -C tools/perf
Michel Lind cdfa3f
Michel Lind cdfa3f
# remove the 'trace' symlink.
Michel Lind cdfa3f
rm %{buildroot}%{_bindir}/trace
Michel Lind cdfa3f
Michel Lind cdfa3f
rm -f %{buildroot}%{_libdir}/libperf.a
Michel Lind cdfa3f
Michel Lind cdfa3f
%if %{without perl}
Michel Lind cdfa3f
rm %{buildroot}%{_libexecdir}/perf-core/tests/shell/common/*.pl
Michel Lind cdfa3f
%endif
Michel Lind cdfa3f
Michel Lind cdfa3f
# TODO - make this customizable upstream
Michel Lind cdfa3f
mkdir -p %{buildroot}%{bash_completions_dir}
Michel Lind cdfa3f
mv %{buildroot}%{_sysconfdir}/bash_completion.d/perf %{buildroot}%{bash_completions_dir}/
Michel Lind cdfa3f
rmdir %{buildroot}%{_sysconfdir}/bash_completion.d
Michel Lind cdfa3f
rmdir %{buildroot}%{_sysconfdir}/
Michel Lind cdfa3f
Michel Lind cdfa3f
Michel Lind cdfa3f
%files
Michel Lind cdfa3f
# license add-license-file-here
Michel Lind cdfa3f
%doc tools/perf/CREDITS
Michel Lind cdfa3f
%{_bindir}/perf
Michel Lind cdfa3f
%{_datadir}/perf-core
Michel Lind cdfa3f
# tips.txt is both human readable and used by perf
Michel Lind cdfa3f
# and really hard to override
Michel Lind cdfa3f
%{_docdir}/perf-tip
Michel Lind cdfa3f
%dir %{_includedir}/perf
Michel Lind cdfa3f
%{_includedir}/perf/perf_dlfilter.h
Michel Lind cdfa3f
%{_libdir}/libperf-jvmti.so
Michel Lind cdfa3f
%{_libexecdir}/perf-core
Michel Lind cdfa3f
%{bash_completions_dir}/perf
Michel Lind cdfa3f
%if %{with manpages}
Michel Lind cdfa3f
%{_mandir}/man1/perf*.1*
Michel Lind cdfa3f
%endif
Michel Lind cdfa3f
Michel Lind cdfa3f
%files -n libperf
Michel Lind cdfa3f
%{_libdir}/libperf.so.0
Michel Lind cdfa3f
%{_libdir}/libperf.so.0.0.1
Michel Lind cdfa3f
Michel Lind cdfa3f
%files -n libperf-devel
Michel Lind cdfa3f
%{_libdir}/libperf.so
Michel Lind cdfa3f
%{_libdir}/pkgconfig/libperf.pc
Michel Lind cdfa3f
%{_includedir}/internal/*.h
Michel Lind cdfa3f
%{_includedir}/perf/bpf_perf.h
Michel Lind cdfa3f
%{_includedir}/perf/core.h
Michel Lind cdfa3f
%{_includedir}/perf/cpumap.h
Michel Lind cdfa3f
%{_includedir}/perf/event.h
Michel Lind cdfa3f
%{_includedir}/perf/evlist.h
Michel Lind cdfa3f
%{_includedir}/perf/evsel.h
Michel Lind cdfa3f
%{_includedir}/perf/mmap.h
Michel Lind cdfa3f
%{_includedir}/perf/threadmap.h
Michel Lind cdfa3f
%{_mandir}/man3/libperf.3.gz
Michel Lind cdfa3f
%{_mandir}/man7/libperf-counting.7.gz
Michel Lind cdfa3f
%{_mandir}/man7/libperf-sampling.7.gz
Michel Lind cdfa3f
%{_docdir}/libperf/examples/sampling.c
Michel Lind cdfa3f
%{_docdir}/libperf/examples/counting.c
Michel Lind cdfa3f
%{_docdir}/libperf/html/libperf.html
Michel Lind cdfa3f
%{_docdir}/libperf/html/libperf-counting.html
Michel Lind cdfa3f
%{_docdir}/libperf/html/libperf-sampling.html
Michel Lind cdfa3f
Michel Lind cdfa3f
%files -n python3-perf
Michel Lind cdfa3f
%{python3_sitearch}/*
Michel Lind cdfa3f
Michel Lind cdfa3f
Michel Lind cdfa3f
%changelog
Michel Lind cdfa3f
%autochangelog
Michel Lind cdfa3f
-