Skip to content

Fix the issue of linking a wrong import library of zstd #134812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jiangjianshan
Copy link

Hello,
I use the scripts from https://github.com/jiangjianshan/msvc-pkg to build many libraries if they are list in packages folder on that github repository. One time I have found in current or previous version of llvm-project, after you run llvm-config --system-libs, you will find 'zstd.dll.lib' but not 'zstd.lib' in the output. But 'zstd.dll.lib' is not exist when using MSVC compiler. This pull request will fix the issue and make llvm-project link to the correct import library of zstd when using MSVC compiler.

Copy link

github-actions bot commented Apr 8, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Apr 8, 2025

@llvm/pr-subscribers-llvm-support

Author: Jianshan Jiang (jiangjianshan)

Changes

Hello,
I use the scripts from https://github.com/jiangjianshan/msvc-pkg to build many libraries if they are list in packages folder on that github repository. One time I have found in current or previous version of llvm-project, after you run llvm-config --system-libs, you will find 'zstd.dll.lib' but not 'zstd.lib' in the output. But 'zstd.dll.lib' is not exist when using MSVC compiler. This pull request will fix the issue and make llvm-project link to the correct import library of zstd when using MSVC compiler.


Full diff: https://github.com/llvm/llvm-project/pull/134812.diff

1 Files Affected:

  • (modified) llvm/lib/Support/CMakeLists.txt (+10-2)
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 98ffd829d80b8..19f97444a6e37 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -336,10 +336,18 @@ if(LLVM_ENABLE_ZSTD)
   # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
   if(CMAKE_BUILD_TYPE)
     string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
-    get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION_${build_type})
+    if(MSVC)
+      get_property(zstd_library TARGET ${zstd_target} PROPERTY IMPORTED_IMPLIB_${build_type})
+    else()
+      get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION_${build_type})
+    endif()
   endif()
   if(NOT zstd_library)
-    get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION)
+    if(MSVC)
+      get_property(zstd_library TARGET ${zstd_target} PROPERTY IMPORTED_IMPLIB)
+    else()
+      get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION)
+    endif()
   endif()
   if (zstd_target STREQUAL zstd::libzstd_shared)
     get_library_name(${zstd_library} zstd_library)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants