-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[CMake] Use llvm-config to locate Findzstd.cmake #16032
Conversation
LLVM17 now depends on `-lzstd` when the `--link-static` option is used. I.e: ``` $ llvm-config-16 --link-static --system-libs -lrt -ldl -lm -lz -ltinfo -lxml2 $ llvm-config-17 --link-static --system-libs -lrt -ldl -lm -lz -lzstd -ltinfo -lxml2 ``` The current cmake rules try to find a "Findzstd.cmake" file located within the project, although this doesn't seem to exist, resulting in a compilation error. This commit adds a fallback to search the system for libzstd.a incase a "Findzstd.cmake" is not found. The zstd library is already installed as part of: https://github.com/apache/tvm/pull/15799/files#diff-c2c0605a8fdd4f5600690a8c7b1ec769882426af1b0ed01e8aaa0814e3a8f5dbR48 Change-Id: I19ab168f92d23e98809851f948e2122345ed01f1
I was trying to fix the zstd dependency a while ago but it unfortunately didn't work out :( |
BTW, |
Ah I missed #15479 thanks :)
Thanks that makes more sense. I wonder if we can rely on |
tbh I'm not an expert and don't have much idea what the best approach is. happy to get this PR in if it works! |
Use llvm-config to find the location of the "Find*.cmake" files and add this location to the cmake `CMAKE_MODULE_PATH` variable. This allows the build to discover "Findzstd.cmake". Change-Id: I3d25074fad3b2b8fa4c3d47e0e4c0b27d8739c65
I feel like the new approach is more robust, but happy to revert @junrushao if you think otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
BTW could you confirm if it works with LLVM-17 on Windows? I was having some trouble previously |
I'm afraid I don't have a windows machine at hand to check |
I think we should get this commit in anyways. In the worst case, it does no harm |
Well, I got the error below on Windows:
|
It seems |
PR apache#16032 introduces a more stable way of zstd path finding by relying on LLVM's existing Findzstd module, but it turns out that the cmake dir from `llvm-config` is not very compatible with CMake's internal convention, and thus a conversion is required to get rid of the error message below: ``` -- Performing Test CMAKE_HAVE_LIBC_PTHREAD D:/a/package/package/tvm/build/CMakeFiles/CMakeScratch/TryCompile-tnlfb1/CMakeLists.txt:2 -- Configuring incomplete, errors occurred! when parsing string C:\Miniconda\envs\tlcpack-build\Library\lib\cmake\llvm Invalid character escape '\M'. ```
PR #16032 introduces a more stable way of zstd path finding by relying on LLVM's existing Findzstd module, but it turns out that the cmake dir from `llvm-config` is not very compatible with CMake's internal convention, and thus a conversion is required to get rid of the error message below: ``` -- Performing Test CMAKE_HAVE_LIBC_PTHREAD D:/a/package/package/tvm/build/CMakeFiles/CMakeScratch/TryCompile-tnlfb1/CMakeLists.txt:2 -- Configuring incomplete, errors occurred! when parsing string C:\Miniconda\envs\tlcpack-build\Library\lib\cmake\llvm Invalid character escape '\M'. ```
* [CMake] Fallback for finding static zstd library from the system LLVM17 now depends on `-lzstd` when the `--link-static` option is used. I.e: ``` $ llvm-config-16 --link-static --system-libs -lrt -ldl -lm -lz -ltinfo -lxml2 $ llvm-config-17 --link-static --system-libs -lrt -ldl -lm -lz -lzstd -ltinfo -lxml2 ``` The current cmake rules try to find a "Findzstd.cmake" file located within the project, although this doesn't seem to exist, resulting in a compilation error. This commit adds a fallback to search the system for libzstd.a incase a "Findzstd.cmake" is not found. The zstd library is already installed as part of: https://github.com/apache/tvm/pull/15799/files#diff-c2c0605a8fdd4f5600690a8c7b1ec769882426af1b0ed01e8aaa0814e3a8f5dbR48 Change-Id: I19ab168f92d23e98809851f948e2122345ed01f1 * Use llvm-config to locate Findzstd.cmake Use llvm-config to find the location of the "Find*.cmake" files and add this location to the cmake `CMAKE_MODULE_PATH` variable. This allows the build to discover "Findzstd.cmake". Change-Id: I3d25074fad3b2b8fa4c3d47e0e4c0b27d8739c65
PR apache#16032 introduces a more stable way of zstd path finding by relying on LLVM's existing Findzstd module, but it turns out that the cmake dir from `llvm-config` is not very compatible with CMake's internal convention, and thus a conversion is required to get rid of the error message below: ``` -- Performing Test CMAKE_HAVE_LIBC_PTHREAD D:/a/package/package/tvm/build/CMakeFiles/CMakeScratch/TryCompile-tnlfb1/CMakeLists.txt:2 -- Configuring incomplete, errors occurred! when parsing string C:\Miniconda\envs\tlcpack-build\Library\lib\cmake\llvm Invalid character escape '\M'. ```
LLVM17 now depends on
-lzstd
when the--link-static
option is used. I.e:The current cmake rules aren't able to find the "Findzstd.cmake", resulting in a cmake error. This commit uses
llvm-config --cmakedir
to locate "Findzstd.cmake" which defines a set of rules to find zstd in the system. The zstd library is already installed as part of: https://github.com/apache/tvm/pull/15799/files#diff-c2c0605a8fdd4f5600690a8c7b1ec769882426af1b0ed01e8aaa0814e3a8f5dbR48