Skip to content

## [Bug] Build fails due to missing source files and linking errors with custom ops in ZenDNN v5.0.2 / main #14

@kksspoi

Description

@kksspoi

Environment
I attempted to build ZenDNN on the following environment:
CPU: AMD Ryzen 9 7950X (Zen 4, AVX512 supported)
OS: Ubuntu 24.04.2 LTS (fully updated)
Linux Kernel: 6.14.0 (manually built with NVIDIA support)
CMake: 3.28.3 (but CMakeLists.txt required cmake_minimum_required(VERSION 3.14) which I manually patched)
Compiler: GCC 14.2.0 (built from source)
Build flags:
-march=znver4 -O3 -ffast-math -mavx512f -mavx512dq -mavx512vnni -mavx512bf16 -mavx512vl -mavx512bw -mavx2 -mfma -pthread -fopenmp -funroll-loops

Problem Summary
While building ZenDNN (both v5.0.2 and the main branch), I encountered consistent failures during the final linking stage of several test executables. These failures were caused by missing source files and unresolved symbols related to custom operations such as zendnn_sdpa_attention and zendnn_reorder.

Manual Fixes Required
To resolve the build failures and complete the build, I had to manually patch parts of the CMake logic in the following files:
・src/common/CMakeLists.txt
・tests/api_tests/CMakeLists.txt
1.I added explicit existence checks before referencing the missing files to avoid build-time errors. For example:
set(ZENDNN_CUSTOM_OP_SRC_DIR "${PROJECT_SOURCE_DIR}/src/common")

if(EXISTS "${ZENDNN_CUSTOM_OP_SRC_DIR}/zendnn_sdpa_attention.cpp")
list(APPEND sources "${ZENDNN_CUSTOM_OP_SRC_DIR}/zendnn_sdpa_attention.cpp")
endif()

if(EXISTS "${ZENDNN_CUSTOM_OP_SRC_DIR}/zendnn_reorder_custom_op.cpp")
list(APPEND sources "${ZENDNN_CUSTOM_OP_SRC_DIR}/zendnn_reorder_custom_op.cpp")
endif()

2.I manually linked these custom op sources to the affected test targets to resolve undefined references like:
・zendnn::zendnn_custom_op::zendnn_sdpa_attention(...)
・zendnn::zendnn_custom_op::zendnn_reorder(...)

To fix this, I inserted the following into the test CMake configuration:
foreach(target_name zendnn-sdpa-test-cpp zendnn-matmul-inplace-custom-op-test-cpp)
if (TARGET ${target_name})
target_link_libraries(${target_name} amdZenDNN_common amdZenDNN_cpu amdZenDNN_cpu_x64)
endif()
endforeach()

Result
After applying these patches, the build completed successfully and the cmake --install . step correctly installed the library and headers. However, these workarounds were not documented in the official build guide, and required manually analyzing the build system.

Question for Developers

To ensure I am following the correct build procedure for ZenDNN on a Zen 4 CPU with AVX512 support, could you confirm if the following steps are officially supported and appropriate?

I performed:

Required environment setup

export ZENDNN_BLIS_PATH=/home/s/local/amd-blis
export LANG=C
export LC_ALL=C
export OMP_PROC_BIND=CLOSE
export OMP_PLACES=CORES
source scripts/zendnn_gcc_env_setup.sh

Configure and build

mkdir -p build && cd build

cmake ..
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX="/home/s/local/zendnn"
-DCMAKE_CCXX_FLAGS="-march=znver4 -O3 -ffast-math -mavx512f -mavx512dq -mavx512vnni -mavx512bf16 -mavx512vl -mavx512bw -mavx2 -mfma -pthread -fopenmp -funroll-loops -Wno-error"
-DCMAKE_C_FLAGS="-march=znver4 -O3 -ffast-math -mavx512f -mavx512dq -mavx512vnni -mavx512bf16 -mavx512vl -mavx512bw -mavx2 -mfma -pthread -fopenmp -funroll-loops -Wno-error"
-DCMAKE_CXX_FLAGS="-march=znver4 -O3 -ffast-math -mavx512f -mavx512dq -mavx512vnni -mavx512bf16 -mavx512vl -mavx512bw -mavx2 -mfma -pthread -fopenmp -funroll-loops -Wno-error"

cmake --build .

If there is a better or more standardized way to build ZenDNN under these conditions (Zen 4 CPU + GCC 14 + AVX512 + Ubuntu 24.04), please kindly advise.

Thank you very much for your excellent work on ZenDNN.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions