# DPC++ supports additional backends, but the default Fedora build remains # redistributable and usable without proprietary SDKs. %bcond hip 0 %bcond native_cpu 1 %bcond tests 0 %bcond assertions 0 %bcond jit 0 %bcond preview 1 # UMF is not currently available as a Fedora package. Keep the bundled copy # as an explicit, auditable source instead of allowing CMake to access the # network. Build with --with system_umf once umf-devel is available. %bcond system_umf 0 # GCC 16 LTO miscompiles the mixed RTTI/no-RTTI LLVM and Unified Runtime link, # leaving llvm::support::detail::format_adapter typeinfo undefined while # linking libur_loader.so. Keep all other Fedora optimization and hardening # flags; re-test this exception with each major GCC or DPC++ update. %global _lto_cflags %{nil} %global umf_version 1.1.0 %global level_zero_min 1.32.0 %global compute_runtime_version 26.18.38308.1 %global vc_intrinsics_commit 60cea7590bd022d95f5cf336ee765033bd114d69 %global spirv_headers_commit 9268f3057354a2cb65991ba5f38b16d81e803692 %global emhash_commit 5e131ba09a5290823fe71099d9c35eb5df5345b6 %global phmap_commit 8a889d3699b3c09ade435641fb034427f3fd12b6 %global dpcpp_root %{_libdir}/dpcpp %global dpcpp_builddir %{_builddir}/llvm-%{version}-build %if %{with tests} %global tests_cmake ON %else %global tests_cmake OFF %endif Name: dpcpp Version: 7.1.1 Release: %autorelease Summary: LLVM-based Intel DPC++ and SYCL compiler License: (Apache-2.0 WITH LLVM-exception) AND Apache-2.0 AND NCSA AND MIT URL: https://github.com/intel/llvm Source0: %{url}/archive/refs/tags/v%{version}/%{name}-%{version}.tar.gz %if %{without system_umf} Source1: https://github.com/oneapi-src/unified-memory-framework/archive/refs/tags/v%{umf_version}/unified-memory-framework-%{umf_version}.tar.gz %endif # Pinned upstream dependencies normally obtained with FetchContent. Declaring # them as RPM sources makes the build reproducible and network-independent. Source2: https://github.com/intel/vc-intrinsics/archive/%{vc_intrinsics_commit}/vc-intrinsics-%{vc_intrinsics_commit}.tar.gz Source3: https://github.com/KhronosGroup/SPIRV-Headers/archive/%{spirv_headers_commit}/SPIRV-Headers-%{spirv_headers_commit}.tar.gz Source4: https://github.com/ktprime/emhash/archive/%{emhash_commit}/emhash-%{emhash_commit}.tar.gz Source5: https://github.com/greg7mdp/parallel-hashmap/archive/%{phmap_commit}/parallel-hashmap-%{phmap_commit}.tar.gz # The Level Zero v2 adapter consumes experimental headers that are not shipped # by oneapi-level-zero-devel. Unified Runtime otherwise sparse-clones these # during configuration, which is forbidden in Fedora builds. Source6: https://github.com/intel/compute-runtime/archive/refs/tags/%{compute_runtime_version}/compute-runtime-%{compute_runtime_version}.tar.gz Source7: dpcpp.rpmlintrc Patch0: dpcpp-7.1.1-opencl-header-deps.patch # ROCm/HIP is currently available only on x86_64 in Fedora. The default # OpenCL, Level Zero, and native CPU build is also supported on aarch64. %if %{with hip} ExclusiveArch: x86_64 %else ExclusiveArch: x86_64 aarch64 %endif BuildRequires: binutils-devel BuildRequires: cmake >= 3.20 BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: git-core BuildRequires: ninja-build BuildRequires: pkgconf-pkg-config BuildRequires: pkgconfig(hwloc) >= 2.3 BuildRequires: pkgconfig(libedit) BuildRequires: pkgconfig(libffi) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(ncurses) # Both interfaces are supplied by oneapi-level-zero-devel. The Intel compute # runtime is a runtime recommendation, not a build-time header provider. BuildRequires: pkgconfig(level-zero) >= %{level_zero_min} BuildRequires: pkgconfig(libze_loader) >= %{level_zero_min} BuildRequires: pkgconfig(OpenCL) BuildRequires: pkgconfig(OpenCL-Headers) BuildRequires: python3-devel BuildRequires: python3-packaging BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(libzstd) >= 1.4.8 %if %{with hip} BuildRequires: cmake(hip) BuildRequires: cmake(hsa-runtime64) %endif %if %{with tests} BuildRequires: python3-lit %endif %if %{with system_umf} BuildRequires: cmake(umf) >= %{umf_version} %else Provides: bundled(umf) = %{umf_version} %endif Provides: bundled(vc-intrinsics) = 0^git20250529.%{vc_intrinsics_commit} Provides: bundled(spirv-headers) = 0^git.%{spirv_headers_commit} Provides: bundled(emhash) = 0^git.%{emhash_commit} Provides: bundled(parallel-hashmap) = 1.3.12 Provides: bundled(intel-compute-runtime) = %{compute_runtime_version} Requires: binutils Requires: gcc-c++ Recommends: intel-compute-runtime %description DPC++ is Intel's open source, LLVM-based compiler for C++ and SYCL. It provides the Clang driver, SYCL headers and runtime, LLVM-to-SPIR-V tools, Unified Runtime loader, and OpenCL and Level Zero adapters. The compiler suite is installed in a private library directory so that its modified Clang and LLVM components can coexist with Fedora's system LLVM. Use dpcpp-clang++ with its SYCL language option to compile SYCL applications. The default build supports OpenCL, both Level Zero adapters, and the native CPU backend. The AMD HIP backend can be enabled with --with hip. %package devel Summary: Development files for DPC++ and SYCL Requires: %{name}%{?_isa} = %{version}-%{release} %description devel The %{name}-devel package contains the public SYCL, Unified Runtime, and XPTI headers, CMake and pkg-config metadata, and link-time libraries for developing applications with DPC++. %prep %autosetup -n llvm-%{version} -p1 %if %{without system_umf} %{__tar} -xf %{SOURCE1} %endif %{__tar} -xf %{SOURCE2} %{__tar} -xf %{SOURCE3} %{__tar} -xf %{SOURCE4} %{__tar} -xf %{SOURCE5} %{__tar} -xf %{SOURCE6} # RPM installs all license files into one package license directory. Give # identically named upstream licenses unique names so none are overwritten. install -pm 0644 sycl/LICENSE.TXT LICENSE.sycl install -pm 0644 llvm-spirv/LICENSE.TXT LICENSE.llvm-spirv install -pm 0644 unified-runtime/LICENSE.TXT LICENSE.unified-runtime %if %{without system_umf} install -pm 0644 unified-memory-framework-%{umf_version}/LICENSE.TXT LICENSE.umf %endif install -pm 0644 vc-intrinsics-%{vc_intrinsics_commit}/LICENSE.md LICENSE.vc-intrinsics install -pm 0644 SPIRV-Headers-%{spirv_headers_commit}/LICENSE LICENSE.spirv-headers install -pm 0644 emhash-%{emhash_commit}/LICENSE LICENSE.emhash install -pm 0644 parallel-hashmap-%{phmap_commit}/LICENSE LICENSE.parallel-hashmap install -pm 0644 compute-runtime-%{compute_runtime_version}/LICENSE.md LICENSE.compute-runtime %if %{with tests} # glibc in Fedora 45+ exposes this startup object symbol even for the non-PIE # executable used solely to test abi_check.py. It is not part of libsycl's ABI. %if 0%{?fedora} >= 45 %ifarch x86_64 abi_fixture=sycl/test/tools/abi_check_positive_dump.txt grep -qxF '_dl_relocate_static_pie_ifunc' "$abi_fixture" || printf '%%s\n' '_dl_relocate_static_pie_ifunc' >> "$abi_fixture" # abi_check.py rejects a reference with the right symbol set in the wrong # order. Preserve its canonical bytewise ordering after adding the Fedora # glibc startup symbol; -u also keeps this adjustment idempotent. LC_ALL=C sort -u -o "$abi_fixture" "$abi_fixture" %endif %endif %endif # Never permit an accidental dependency download during a mock or Koji build. # DPC++ uses the source directory below through CMake's FetchContent override. %build %set_build_flags l0_include_dir="$(pkgconf --variable=includedir level-zero)/level_zero" l0_loader="$(pkgconf --variable=libdir libze_loader)/libze_loader.so" %if %{with tests} # FindOpenCL normally reports /usr/include. The SYCL lit configuration turns # that into an explicit, early "-isystem /usr/include", which breaks # libstdc++'s #include_next on Fedora. Use a private view of the # same system headers so the compiler's normal /usr/include ordering remains # intact. opencl_test_includedir="%{_builddir}/dpcpp-opencl-headers" install -d "$opencl_test_includedir" ln -s "%{_includedir}/CL" "$opencl_test_includedir/CL" %endif set -- \ -s "%{_builddir}/llvm-%{version}" \ -o "%{dpcpp_builddir}" \ -t Release \ --cmake-gen Ninja \ --use-zstd \ --level_zero_adapter_version ALL \ --l0-headers "$l0_include_dir" \ --l0-loader "$l0_loader" \ --cmake-opt=-DCMAKE_INSTALL_PREFIX:PATH=%{dpcpp_builddir}/install \ --cmake-opt=-DCMAKE_INSTALL_LIBDIR:PATH=lib \ --cmake-opt=-DCMAKE_SKIP_RPATH:BOOL=ON \ --cmake-opt=-DLLVM_USE_STATIC_ZSTD:BOOL=OFF \ --cmake-opt=-DLLVM_ENABLE_LIBEDIT:BOOL=ON \ --cmake-opt=-DLLVM_ENABLE_LIBXML2:BOOL=ON \ --cmake-opt=-DLLVM_ENABLE_TERMINFO:BOOL=ON \ --cmake-opt=-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \ --cmake-opt=-DCLANG_INCLUDE_TESTS:BOOL=%{tests_cmake} \ --cmake-opt=-DLLVM_INCLUDE_TESTS:BOOL=%{tests_cmake} \ --cmake-opt=-DLLVM_SPIRV_INCLUDE_TESTS:BOOL=%{tests_cmake} \ --cmake-opt=-DSYCL_INCLUDE_TESTS:BOOL=%{tests_cmake} \ --cmake-opt=-DUR_BUILD_TESTS:BOOL=OFF \ --cmake-opt=-DUR_BUILD_EXAMPLES:BOOL=OFF \ "--cmake-opt=-DFETCHCONTENT_SOURCE_DIR_EXP-HEADERS:PATH=%{_builddir}/llvm-%{version}/compute-runtime-%{compute_runtime_version}/level_zero/include" \ --cmake-opt=-DUMF_BUILD_TESTS:BOOL=OFF \ --cmake-opt=-DUMF_BUILD_EXAMPLES:BOOL=OFF \ "--cmake-opt=-DFETCHCONTENT_SOURCE_DIR_VC-INTRINSICS:PATH=%{_builddir}/llvm-%{version}/vc-intrinsics-%{vc_intrinsics_commit}" \ "--cmake-opt=-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR:PATH=%{_builddir}/llvm-%{version}/SPIRV-Headers-%{spirv_headers_commit}" \ "--cmake-opt=-DFETCHCONTENT_SOURCE_DIR_EMHASH:PATH=%{_builddir}/llvm-%{version}/emhash-%{emhash_commit}" \ "--cmake-opt=-DFETCHCONTENT_SOURCE_DIR_PARALLEL-HASHMAP:PATH=%{_builddir}/llvm-%{version}/parallel-hashmap-%{phmap_commit}" %if %{with tests} set -- "$@" \ "--cmake-opt=-DOpenCL_INCLUDE_DIR:PATH=$opencl_test_includedir" %endif %if %{without assertions} set -- "$@" --no-assertions %endif %if %{with native_cpu} set -- "$@" --native_cpu %endif %if %{with hip} set -- "$@" \ --hip \ --hip-platform AMD \ --cmake-opt=-DUR_HIP_ROCM_DIR:PATH=%{_prefix} %endif %if %{without jit} set -- "$@" --disable-jit %endif %if %{without preview} set -- "$@" --disable-preview-lib %endif %if %{with system_umf} set -- "$@" \ --cmake-opt=-DUR_USE_EXTERNAL_UMF:BOOL=ON %else set -- "$@" \ --cmake-opt=-DUR_USE_EXTERNAL_UMF:BOOL=OFF \ "--cmake-opt=-DFETCHCONTENT_SOURCE_DIR_UNIFIED-MEMORY-FRAMEWORK:PATH=%{_builddir}/llvm-%{version}/unified-memory-framework-%{umf_version}" %endif CC=gcc CXX=g++ %{python3} buildbot/configure.py "$@" # Building the target separately keeps deployment out of %%build. Upstream's # deploy target does not honor DESTDIR, so it installs into the private staging # prefix configured above and %%install copies that tree into the buildroot. %ninja_build -C "%{dpcpp_builddir}" sycl-toolchain %install %ninja_build -C "%{dpcpp_builddir}" deploy-sycl-toolchain install -d "%{buildroot}%{dpcpp_root}" cp -a "%{dpcpp_builddir}/install/." "%{buildroot}%{dpcpp_root}/" # Provide collision-free driver names. Keeping the real binaries in the # private prefix avoids conflicts with Fedora's clang and llvm packages. install -d "%{buildroot}%{_bindir}" ln -s "../%{_lib}/dpcpp/bin/clang" \ "%{buildroot}%{_bindir}/dpcpp-clang" ln -s "../%{_lib}/dpcpp/bin/clang++" \ "%{buildroot}%{_bindir}/dpcpp-clang++" ln -s "../%{_lib}/dpcpp/bin/sycl-ls" \ "%{buildroot}%{_bindir}/dpcpp-sycl-ls" # DPC++ applications need the private SYCL and Unified Runtime libraries at # execution time. A dedicated loader path avoids copying potentially # conflicting libraries into Fedora's global LLVM namespace. install -d "%{buildroot}%{_sysconfdir}/ld.so.conf.d" printf '%%s\n' '%{dpcpp_root}/lib' > \ "%{buildroot}%{_sysconfdir}/ld.so.conf.d/dpcpp-%{_arch}.conf" # Remove static archives that are implementation details of the compiler. # Keep device bitcode and any archives explicitly consumed by the driver. find "%{buildroot}%{dpcpp_root}/lib" -maxdepth 1 -type f -name 'libLLVM*.a' -delete find "%{buildroot}%{dpcpp_root}/lib" -maxdepth 1 -type f -name 'libclang*.a' -delete %check "%{dpcpp_builddir}/bin/clang++" --version "%{dpcpp_builddir}/bin/clang++" -fsycl -### -x c++ /dev/null 2>&1 | \ grep -F -- '-lsycl' %if %{with tests} %ninja_build -C "%{dpcpp_builddir}" check-llvm-spirv check-sycl %endif %files %license LICENSE.TXT %license LICENSE.sycl %license LICENSE.llvm-spirv %license LICENSE.unified-runtime %if %{without system_umf} %license LICENSE.umf %endif %license LICENSE.vc-intrinsics %license LICENSE.spirv-headers %license LICENSE.emhash %license LICENSE.parallel-hashmap %license LICENSE.compute-runtime %doc README.md %{_bindir}/dpcpp-clang %{_bindir}/dpcpp-clang++ %{_bindir}/dpcpp-sycl-ls %config(noreplace) %{_sysconfdir}/ld.so.conf.d/dpcpp-%{_arch}.conf %{dpcpp_root}/ %exclude %{dpcpp_root}/include/ %exclude %{dpcpp_root}/lib/cmake/ %exclude %{dpcpp_root}/lib/pkgconfig/ %exclude %{dpcpp_root}/lib/libxpti.a %if %{with preview} %exclude %{dpcpp_root}/lib/libsycl-preview.so %endif %exclude %{dpcpp_root}/lib/libsycl.so %exclude %{dpcpp_root}/lib/libumf.so %exclude %{dpcpp_root}/lib/libur_adapter_level_zero.so %exclude %{dpcpp_root}/lib/libur_adapter_level_zero_v2.so %if %{with native_cpu} %exclude %{dpcpp_root}/lib/libur_adapter_native_cpu.so %endif %exclude %{dpcpp_root}/lib/libur_adapter_opencl.so %exclude %{dpcpp_root}/lib/libur_loader.so %exclude %{dpcpp_root}/lib/libxptifw.so %files devel %{dpcpp_root}/include/ %{dpcpp_root}/lib/cmake/ %{dpcpp_root}/lib/pkgconfig/ %{dpcpp_root}/lib/libxpti.a %if %{with preview} %{dpcpp_root}/lib/libsycl-preview.so %endif %{dpcpp_root}/lib/libsycl.so %{dpcpp_root}/lib/libumf.so %{dpcpp_root}/lib/libur_adapter_level_zero.so %{dpcpp_root}/lib/libur_adapter_level_zero_v2.so %if %{with native_cpu} %{dpcpp_root}/lib/libur_adapter_native_cpu.so %endif %{dpcpp_root}/lib/libur_adapter_opencl.so %{dpcpp_root}/lib/libur_loader.so %{dpcpp_root}/lib/libxptifw.so %changelog %autochangelog