Skip to content

sycl: zstd_STATIC_LIBRARY is NOTFOUND building on almalinux 8 #22310

@dvrogozh

Description

@dvrogozh

Describe the bug

We are working to support Pytorch CI with intel/llvm compiler, see intel/torch-xpu-ops#3934. Pytorch build is done on almalinux 8 (RHEL 8 derivative) and requires support for --offload-compress which depends on ZSTD library. The libzstd library on Fedora family is available only as a shared library. Building against system installed dependencies is a strong requirement within Linux ecosystem especially for Linux distro packaging of the components. The build of intel/llvm compiler is failing on such setup because SYCL library configuration mistakenly relies only on static ZSTD library:

target_link_libraries(${LIB_NAME} PRIVATE ${zstd_STATIC_LIBRARY})

Compare with how similar places implemented in other places in LLVM:

if(LLVM_ENABLE_ZSTD)
if(TARGET zstd::libzstd_shared AND NOT LLVM_USE_STATIC_ZSTD)
set(zstd_target zstd::libzstd_shared)
else()
set(zstd_target zstd::libzstd_static)
endif()
endif()
if(LLVM_ENABLE_ZSTD)
list(APPEND imported_libs ${zstd_target})
endif()

and:

if(LLVM_ENABLE_ZSTD)
if(TARGET zstd::libzstd_shared AND NOT LLVM_USE_STATIC_ZSTD)
set(zstd_target zstd::libzstd_shared)
else()
set(zstd_target zstd::libzstd_static)
endif()
endif()
if(LLVM_ENABLE_ZSTD)
list(APPEND imported_libs ${zstd_target})

To reproduce

$ docker pull pytorch/manylinux2_28-builder:xpu-main
$ docker run -it --rm -v $(pwd):/opt/_llvm pytorch/manylinux2_28-builder:xpu-main
# /opt/python/cp314-cp314/bin/python3 -m venv /opt/_build
# . /opt/_build/bin/activate
# pip install cmake ninja
# dnf install -y libtool libzstd-devel
# cmake -B build -S llvm -G Ninja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=$(pwd)/install \
    -DBUILD_SHARED_LIBS=ON \
    -DLLVM_BUILD_TOOLS=ON \
    -DLLVM_ENABLE_ASSERTIONS=ON \
    -DLLVM_ENABLE_DOXYGEN=OFF \
    -DLLVM_ENABLE_LLD=OFF \
    -DLLVM_ENABLE_PROJECTS='clang;sycl;llvm-spirv;opencl;xpti;xptifw;compiler-rt;libdevice;sycl-jit' \
    -DLLVM_ENABLE_RTTI=ON \
    -DLLVM_ENABLE_SPHINX=OFF \
    -DLLVM_ENABLE_ZSTD=ON \
    -DLLVM_EXTERNAL_PROJECTS='sycl;llvm-spirv;opencl;xpti;xptifw;compiler-rt;libdevice;sycl-jit' \
    -DLLVM_SPIRV_ENABLE_LIBSPIRV_DIS=OFF \
    -DLLVM_TARGETS_TO_BUILD='host;SPIRV' \
    -DSYCL_ENABLE_EXTENSION_JIT=ON \
    -DSYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB=OFF \
    -DSYCL_ENABLE_WERROR=OFF \
    -DSYCL_ENABLE_XPTI_TRACING=ON \
    -DLLVM_EXTERNAL_LIBDEVICE_SOURCE_DIR=$(pwd)/libdevice \
    -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$(pwd)/llvm-spirv \
    -DLLVM_EXTERNAL_SYCL_JIT_SOURCE_DIR=$(pwd)/sycl-jit \
    -DLLVM_EXTERNAL_SYCL_SOURCE_DIR=$(pwd)/sycl \
    -DLLVM_EXTERNAL_XPTI_SOURCE_DIR=$(pwd)/xpti \
    -DLLVM_EXTERNAL_XPTIFW_SOURCE_DIR=$(pwd)/xptifw \
    -DSYCL_INCLUDE_TESTS=OFF \
    -DXPTI_ENABLE_WERROR=OFF
<...>
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
zstd_STATIC_LIBRARY (ADVANCED)
    linked by target "sycl" in directory /opt/_llvm/sycl/source

-- Generating done (5.3s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

Environment

  • OS: Linux
  • DPC++ version: b09acde (latest main as of 6/12/2026)

Additional context

CC: @sarnex, @uditagarwal97

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions