%define abseil_version 20250127.1 %define bdwgc_version 8.2.8 %define inja_version 3.4.0 %define libbpf_version 1.5.0 %define p4runtime_version ec4eb5ef70dbcbcbf2f8357a4b2b8c2f218845a5 %define protobuf_version 25.3 %define spdlog_version 1.8.3 %define z3_version 4.13.4 Name: p4lang-p4c Version: 1.2.5.6 Release: 1%{?dist} Summary: P4 language compiler License: ASL 2.0 URL: https://github.com/p4lang/p4c Source0: https://github.com/p4lang/p4c/archive/v%{version}/p4c-%{version}.tar.gz Source1: https://github.com/abseil/abseil-cpp/releases/download/%{abseil_version}/abseil-cpp-%{abseil_version}.tar.gz Source2: https://github.com/ivmai/bdwgc/archive/v%{bdwgc_version}/bdwgc-%{bdwgc_version}.tar.gz Source3: https://github.com/pantor/inja/archive/v%{inja_version}/inja-%{inja_version}.tar.gz Source4: https://github.com/libbpf/libbpf/archive/v%{libbpf_version}/libbpf-%{libbpf_version}.tar.gz Source5: https://github.com/p4lang/p4runtime/archive/%{p4runtime_version}.tar.gz Source6: https://github.com/protocolbuffers/protobuf/releases/download/v%{protobuf_version}/protobuf-%{protobuf_version}.tar.gz Source7: https://github.com/gabime/spdlog/archive/v%{spdlog_version}/spdlog-%{spdlog_version}.tar.gz Source8: https://github.com/Z3Prover/z3/archive/z3-%{z3_version}.tar.gz BuildRequires: cmake BuildRequires: bison BuildRequires: flex BuildRequires: gcc-c++ BuildRequires: boost-devel BuildRequires: gc-devel BuildRequires: gmp-devel BuildRequires: libbpf-devel BuildRequires: libstdc++-static BuildRequires: elfutils-libelf-devel BuildRequires: llvm-devel BuildRequires: rapidjson-devel BuildRequires: python3-devel BuildRequires: python3-grpcio BuildRequires: python3-jsl BuildRequires: python3-jsonschema BuildRequires: python3-pyroute2 BuildRequires: python3-ply BuildRequires: python3-ptf BuildRequires: python3-pyyaml BuildRequires: python3-scapy BuildRequires: python3-setuptools BuildRequires: python3-thrift BuildRequires: python3-googleapis-common-protos BuildRequires: p4lang-bmv2 Recommends: p4lang-bmv2 Recommends: python3-jsl Recommends: python3-jsonschema Recommends: cpp %description A reference compiler for the P4 programming language, supporting P4_14 and P4_16, with backends for BMv2, eBPF, DPDK, TOFINO and more. %prep %setup -q -n p4c-%{version} -a1 -a2 -a3 -a4 -a5 -a6 -a7 -a8 %autopatch -p1 patch -d z3-z3-%{z3_version} -p1 < cmake/z3.patch sed -i '/PUBLIC "-mbmi"/d' cmake/Abseil.cmake sed -i 's|${SPDLOG_SOURCE_DIR} ${CMAKE_BINARY_DIR}/spdlog|${spdlog_SOURCE_DIR} ${spdlog_BINARY_DIR}|' backends/tofino/cmake/spdlog.cmake sed -i 's|${BFN_P4C_SOURCE_DIR}/third_party/spdlog|${spdlog_SOURCE_DIR}|' backends/tofino/bf-p4c/CMakeLists.txt sed -i 's|${CMAKE_SOURCE_DIR}/third_party/spdlog|${spdlog_SOURCE_DIR}|' backends/tofino/bf-p4c/logging/CMakeLists.txt sed -i 's/\brsqrt\b/stateful_rsqrt/g' backends/tofino/bf-p4c/mau/stateful_alu.cpp sed -i '/add_dependencies(p4c_driver p4c-build-logs)/d' backends/tofino/bf-p4c/CMakeLists.txt sed -i '/install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}\/dist\/p4c-build-logs/{N;d;}' backends/tofino/bf-p4c/CMakeLists.txt sed -i 's|sys.path.insert(1, MYPATH)|sys.path.insert(1, "/usr/share/p4c")|' backends/tofino/compiler_interfaces/p4c-build-logs %build mkdir -p %{_builddir}/tmp export TMPDIR=%{_builddir}/tmp %cmake -B %{_vpath_builddir} \ -DFETCHCONTENT_FULLY_DISCONNECTED=ON \ -DFETCHCONTENT_SOURCE_DIR_ABSEIL=abseil-cpp-%{abseil_version} \ -DFETCHCONTENT_SOURCE_DIR_BDWGC=bdwgc-%{bdwgc_version} \ -DFETCHCONTENT_SOURCE_DIR_INJA=inja-%{inja_version} \ -DFETCHCONTENT_SOURCE_DIR_BPFREPO=libbpf-%{libbpf_version} \ -DFETCHCONTENT_SOURCE_DIR_P4RUNTIME=p4runtime-%{p4runtime_version} \ -DFETCHCONTENT_SOURCE_DIR_PROTOBUF=protobuf-%{protobuf_version} \ -DFETCHCONTENT_SOURCE_DIR_SPDLOG=spdlog-%{spdlog_version} \ -DFETCHCONTENT_SOURCE_DIR_Z3=z3-z3-%{z3_version} \ -DBUILD_SHARED_LIBS=OFF \ -DENABLE_STATIC_LIBS=ON \ -DENABLE_LTO=ON \ -DENABLE_BMV2=ON \ -DENABLE_EBPF=ON \ -DENABLE_UBPF=ON \ -DENABLE_DPDK=ON \ -DENABLE_TOFINO=ON \ -DENABLE_P4C_GRAPHS=ON \ -DENABLE_P4TEST=ON \ -DENABLE_DOCS=OFF \ -DENABLE_GC=ON \ -DENABLE_GTESTS=OFF \ -DENABLE_MULTITHREAD=OFF \ -DENABLE_TEST_TOOLS=ON %cmake_build %install %cmake_install mkdir -p %{buildroot}%{_datadir}/p4c/{schemas,tools} install -pm 0644 backends/tofino/compiler_interfaces/schemas/*.py %{buildroot}%{_datadir}/p4c/schemas/ install -pm 0644 backends/tofino/compiler_interfaces/tools/*.py %{buildroot}%{_datadir}/p4c/tools/ install -pm 0755 backends/tofino/compiler_interfaces/p4c-build-logs %{buildroot}%{_bindir}/p4c-build-logs %files %license LICENSE %doc README.md %{_bindir}/bfas %{_bindir}/bfrt_schema.py %{_bindir}/p4_14-to-p4_16 %{_bindir}/p4c %{_bindir}/p4c-barefoot %{_bindir}/p4c-bm2-pna %{_bindir}/p4c-bm2-psa %{_bindir}/p4c-bm2-ss %{_bindir}/p4c-build-logs %{_bindir}/p4c-dpdk %{_bindir}/p4c-ebpf %{_bindir}/p4c-gen-bfrt-conf %{_bindir}/p4c-gen-conf %{_bindir}/p4c-graphs %{_bindir}/p4c-manifest-config %{_bindir}/p4c-pna-p4tc %{_bindir}/p4c-ubpf %{_bindir}/p4smith %{_bindir}/p4test %{_bindir}/p4testgen %{_datadir}/p4c %changelog * Tue May 06 2025 - 1.2.5.6-1 - v1.2.5.6