Skip to content

Conversation

@uditagarwal97
Copy link
Contributor

@uditagarwal97 uditagarwal97 commented Oct 24, 2024

Problem:

When we use LLVM_ENABLE_ZSTD=ON along with LLVM_USE_STATIC_ZSTD=ON, LLVM config fails with the following error when libzstd.a is not found but libzstd.so is found:

CMake Error at lib/Support/CMakeLists.txt:327 (get_property):
  get_property could not find TARGET zstd::libzstd_static.  Perhaps it has
  not yet been created.


CMake Error at lib/Support/CMakeLists.txt:330 (get_property):
  get_property could not find TARGET zstd::libzstd_static.  Perhaps it has
  not yet been created.

The bug is in upstream and in the following lines: https://github.com/intel/llvm/blob/sycl/llvm/lib/Support/CMakeLists.txt#L32 - In the else(), the code just assumes that static libraries are available.

Solution:

When user specifies LLVM_USE_STATIC_ZSTD=ON, we should enable ZSTD only if static zstd library is present. Otherwise, the build should just proceed normally since zstd is optional, even in upstream.

@uditagarwal97 uditagarwal97 self-assigned this Oct 24, 2024
@uditagarwal97 uditagarwal97 marked this pull request as ready for review October 24, 2024 15:08
@uditagarwal97 uditagarwal97 requested review from a team as code owners October 24, 2024 15:08
endif()

# If LLVM_USE_STATIC_ZSTD is specified, make sure we enable zstd only if static
# libraries are found.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a bug report and PR to upstream this change, if approved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# If LLVM_USE_STATIC_ZSTD is specified, make sure we enable zstd only if static
# libraries are found.
if(LLVM_USE_STATIC_ZSTD AND NOT TARGET zstd::libzstd_static)
Copy link
Contributor

@sarnex sarnex Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry what is zstd::libzstd_static and who sets it? is it set by find_package if it finds the static lib? not a cmake expert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, zstd::libzstd_static is set during find_package if it finds static ZSTD libraries. https://github.com/intel/llvm/blob/sycl/llvm/cmake/modules/Findzstd.cmake#L60

Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me, but lets also submit to upstream like you said

@uditagarwal97
Copy link
Contributor Author

@intel/llvm-gatekeepers the PR is ready to be merged.

@sarnex sarnex merged commit 128b139 into intel:sycl Oct 24, 2024
13 checks passed
@uditagarwal97 uditagarwal97 deleted the fix_zstd_build branch November 5, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants