Name: p4lang-p4c Version: 1.2.5.5 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/protocolbuffers/protobuf/releases/download/v25.3/protobuf-25.3.tar.gz Source2: https://github.com/abseil/abseil-cpp/releases/download/20250127.1/abseil-cpp-20250127.1.tar.gz Source3: https://github.com/Z3Prover/z3/archive/z3-4.14.1.tar.gz Source4: https://github.com/p4lang/p4runtime/archive/ec4eb5ef70dbcbcbf2f8357a4b2b8c2f218845a5.tar.gz Source5: https://github.com/pantor/inja/archive/v3.4.0/inja-3.4.0.tar.gz Source6: https://github.com/libbpf/libbpf/archive/v1.5.0/libbpf-1.5.0.tar.gz Source7: https://github.com/gabime/spdlog/archive/v1.8.3/spdlog-1.8.3.tar.gz Patch0: p4c-1.2.5.5-tuple.patch 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 %description A reference compiler for the P4 programming language, supporting P4_14 and P4_16, with backends for BMv2, eBPF, DPDK, and more. %prep %autosetup -p1 -n p4c-%{version} mkdir -p %{_vpath_builddir}/_deps tar -xzf %{SOURCE1} -C %{_vpath_builddir}/_deps --transform='s/protobuf-25.3/protobuf-src/' tar -xzf %{SOURCE2} -C %{_vpath_builddir}/_deps --transform='s/abseil-cpp-20250127.1/abseil-src/' tar -xzf %{SOURCE3} -C %{_vpath_builddir}/_deps --transform='s/z3-z3-4.14.1/z3-src/' tar -xzf %{SOURCE4} -C %{_vpath_builddir}/_deps --transform='s/p4runtime-ec4eb5ef70dbcbcbf2f8357a4b2b8c2f218845a5/p4runtime-src/' tar -xzf %{SOURCE5} -C %{_vpath_builddir}/_deps --transform='s/inja-3.4.0/inja-src/' tar -xzf %{SOURCE6} -C backends/ebpf/runtime/contrib --transform='s/libbpf-1.5.0/libbpf/' mkdir -p backends/tofino/third_party tar -xzf %{SOURCE7} -C backends/tofino/third_party --transform='s/spdlog-1.8.3/spdlog/' sed -i '/PUBLIC "-mbmi"/d' cmake/Abseil.cmake sed -i 's/add_custom_target(uninstall/add_custom_target(z3_uninstall/' %{_vpath_builddir}/_deps/z3-src/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} \ -DBUILD_SHARED_LIBS=OFF \ -DENABLE_STATIC_LIBS=ON \ -DFETCHCONTENT_FULLY_DISCONNECTED=ON \ -DP4C_USE_PREINSTALLED_BDWGC=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