Skip to content
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

Merged
merged 2 commits into from
Nov 3, 2023

Conversation

lhutton1
Copy link
Contributor

@lhutton1 lhutton1 commented Nov 1, 2023

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 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

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
@junrushao
Copy link
Member

I was trying to fix the zstd dependency a while ago but it unfortunately didn't work out :(

@junrushao
Copy link
Member

BTW, Findzstd.cmake is supposed to provided by LLVM

@lhutton1
Copy link
Contributor Author

lhutton1 commented Nov 1, 2023

Ah I missed #15479 thanks :)

BTW, Findzstd.cmake is supposed to provided by LLVM

Thanks that makes more sense. I wonder if we can rely on llvm-config --cmakedir to give the location instead? I can take a closer look tomorrow

@junrushao
Copy link
Member

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
@lhutton1 lhutton1 changed the title [CMake] Fallback for finding static zstd library from the system [CMake] Use llvm-config to locate Findzstd.cmake Nov 2, 2023
@lhutton1
Copy link
Contributor Author

lhutton1 commented Nov 2, 2023

I feel like the new approach is more robust, but happy to revert @junrushao if you think otherwise

@lhutton1 lhutton1 marked this pull request as ready for review November 2, 2023 12:54
Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

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

LGTM!

@junrushao
Copy link
Member

junrushao commented Nov 2, 2023

BTW could you confirm if it works with LLVM-17 on Windows? I was having some trouble previously

@lhutton1
Copy link
Contributor Author

lhutton1 commented Nov 3, 2023

I'm afraid I don't have a windows machine at hand to check

@junrushao
Copy link
Member

I think we should get this commit in anyways. In the worst case, it does no harm

@junrushao junrushao merged commit 3b8d1a8 into apache:main Nov 3, 2023
8 of 9 checks passed
@lhutton1 lhutton1 deleted the fix-cmake-find-zstd branch November 3, 2023 20:11
@junrushao
Copy link
Member

Well, I got the error below on Windows:

D:\a\package\package>cd tvm 

D:\a\package\package\tvm>rd /s /q build 
The system cannot find the file specified.

D:\a\package\package\tvm>mkdir build 

D:\a\package\package\tvm>cd build 

D:\a\package\package\tvm\build>cmake -A x64 -Thost=x64       -G "Visual Studio 17 2022"       -DUSE_LLVM="llvm-config --link-static"       -DZLIB_USE_STATIC_LIBS=ON       -DUSE_RPC=ON       -DUSE_VULKAN=ON       .. 
-- The C compiler identification is MSVC 1[9](https://github.com/mlc-ai/package/actions/runs/6766922543/job/18407590080#step:8:10).37.32825.0
-- The CXX compiler identification is MSVC 19.37.32825.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build with RPC support...
-- Build with Graph Executor support...
-- Build with profiler...
-- Build with AOT Executor support...
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) 
-- Didn't find the path to CCACHE, disabling ccache
-- Performing Test SUPPORT_CXX17
-- Performing Test SUPPORT_CXX17 - Success
-- VTA build is skipped in Windows..
-- Vulkan_INCLUDE_DIRS=C:/Miniconda/envs/tlcpack-build/Library/includeC:/Miniconda/envs/tlcpack-build/Library/include/spirv-toolsC:/Miniconda/envs/tlcpack-build/Library/include/spirv/unified1C:/Miniconda/envs/tlcpack-build/Library/include/spirv/unified1
-- Vulkan_LIBRARY=C:/Miniconda/envs/tlcpack-build/Library/lib/vulkan-1.lib
-- Vulkan_SPIRV_TOOLS_LIBRARY=C:/Miniconda/envs/tlcpack-build/Library/lib/SPIRV-Tools.lib
-- Build with Vulkan support
-- Use llvm-config=llvm-config --link-static
-- LLVM libdir: C:\Miniconda\envs\tlcpack-build\Library\lib
-- LLVM cmakedir: C:\Miniconda\envs\tlcpack-build\Library\lib\cmake\llvm
-- LLVM linker flag: psapi.lib
-- LLVM linker flag: shell32.lib
-- LLVM linker flag: ole32.lib
-- LLVM linker flag: uuid.lib
-- LLVM linker flag: advapi32.lib
-- LLVM links against zlib
-- Found ZLIB: C:/Miniconda/envs/tlcpack-build/Library/lib/zlibstatic.lib (found version "1.2.13")  
CMake Error at C:/Miniconda/envs/tlcpack-build/Library/lib/cmake/llvm/Findzstd.cmake:39 (string):
  string sub-command REGEX, mode REPLACE: regex "$" matched an empty string.
Call Stack (most recent call first):
  cmake/utils/FindLLVM.cmake:177 (find_package)
  cmake/modules/LLVM.cmake:31 (find_llvm)
  CMakeLists.txt:544 (include)


-- Found zstd: C:/Miniconda/envs/tlcpack-build/Library/lib/zstd.lib  
-- LLVM links against static zstd
-- LLVM linker flag under LLVM libdir: C:\Miniconda\envs\tlcpack-build\Library\lib/xml2.lib
-- Found LLVM_INCLUDE_DIRS=C:\Miniconda\envs\tlcpack-build\Library\include
-- Found LLVM_DEFINITIONS=-D_CRT_SECURE_NO_DEPRECATE;-D_CRT_SECURE_NO_WARNINGS;-D_CRT_NONSTDC_NO_DEPRECATE;-D_CRT_NONSTDC_NO_WARNINGS;-D_SCL_SECURE_NO_DEPRECATE;-D_SCL_SECURE_NO_WARNINGS;-DUNICODE;-D_UNICODE;-D__STDC_CONSTANT_MACROS;-D__STDC_FORMAT_MACROS;-D__STDC_LIMIT_MACROS
-- Found LLVM_LIBS=C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMWindowsManifest.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMXRay.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLibDriver.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDlltoolDriver.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMCoverage.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLineEditor.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMXCoreDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMXCoreCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMXCoreDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMXCoreInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMX86TargetMCA.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMX86Disassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMX86AsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMX86CodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMX86Desc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMX86Info.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMWebAssemblyDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMWebAssemblyAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMWebAssemblyCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMWebAssemblyUtils.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMWebAssemblyDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMWebAssemblyInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMVEDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMVEAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMVECodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMVEDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMVEInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSystemZDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSystemZAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSystemZCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSystemZDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSystemZInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSparcDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSparcAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSparcCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSparcDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSparcInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMRISCVTargetMCA.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMRISCVDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMRISCVAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMRISCVCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMRISCVDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMRISCVInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMPowerPCDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMPowerPCAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMPowerPCCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMPowerPCDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMPowerPCInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMNVPTXCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMNVPTXDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMNVPTXInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMSP430Disassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMSP430AsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMSP430CodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMSP430Desc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMSP430Info.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMipsDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMipsAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMipsCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMipsDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMipsInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLoongArchDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLoongArchAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLoongArchCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLoongArchDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLoongArchInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLanaiDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLanaiCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLanaiAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLanaiDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLanaiInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMHexagonDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMHexagonCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMHexagonAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMHexagonDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMHexagonInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMBPFDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMBPFAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMBPFCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMBPFDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMBPFInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAVRDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAVRAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAVRCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAVRDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAVRInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMARMDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMARMAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMARMCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMARMDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMARMUtils.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMARMInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAMDGPUTargetMCA.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAMDGPUDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAMDGPUAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAMDGPUCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAMDGPUDesc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAMDGPUUtils.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAMDGPUInfo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAArch64Disassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAArch64AsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAArch64CodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAArch64Desc.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAArch64Utils.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAArch64Info.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMIntelJITEvents.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMOrcJIT.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMWindowsDriver.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMCJIT.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMJITLink.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMInterpreter.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMExecutionEngine.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMRuntimeDyld.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMOrcTargetProcess.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMOrcShared.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDWP.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDebugInfoLogicalView.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDebugInfoGSYM.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMOption.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMObjectYAML.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMObjCopy.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMCA.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMCDisassembler.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLTO.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMPasses.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMCFGuard.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMCoroutines.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMipo.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMVectorize.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMLinker.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMInstrumentation.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMFrontendOpenMP.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMFrontendOpenACC.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMFrontendHLSL.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMExtensions.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDWARFLinkerParallel.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDWARFLinker.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMGlobalISel.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMIRParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAsmPrinter.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSelectionDAG.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMCodeGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMTarget.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMObjCARCOpts.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMCodeGenTypes.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMIRPrinter.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMInterfaceStub.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMFileCheck.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMFuzzMutate.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMScalarOpts.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMInstCombine.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAggressiveInstCombine.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMTransformUtils.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMBitWriter.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAnalysis.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMProfileData.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSymbolize.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDebugInfoBTF.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDebugInfoPDB.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDebugInfoMSF.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDebugInfoDWARF.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMObject.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMTextAPI.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMCParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMIRReader.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMAsmParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMMC.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDebugInfoCodeView.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMBitReader.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMFuzzerCLI.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMCore.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMRemarks.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMBitstreamReader.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMBinaryFormat.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMTargetParser.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMTableGen.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMSupport.lib;C:\Miniconda\envs\tlcpack-build\Library\lib\LLVMDemangle.lib;psapi.lib;shell32.lib;ole32.lib;uuid.lib;advapi32.lib;ZLIB::ZLIB;zstd::libzstd_static;C:\Miniconda\envs\tlcpack-build\Library\lib/xml2.lib
-- Found TVM_LLVM_VERSION=170
-- Build with LLVM 
-- Set TVM_LLVM_VERSION=170
-- Build with contrib.random
-- Build with contrib.sort
-- Build with contrib.hybriddump
-- Git found: C:/Miniconda/envs/tlcpack-build/Library/bin/git.exe
-- Found TVM_GIT_COMMIT_HASH=2064d590300d1d593a4f705b7c51aec53d5ce3cb
-- Found TVM_GIT_COMMIT_TIME=2023-11-06 06:49:51 -0800
-- Could NOT find LIBBACKTRACE (missing: LIBBACKTRACE_STATIC_LIBRARY LIBBACKTRACE_INCLUDE_DIR) 
-- Building with TVM Map...
CMake Error at D:/a/package/package/tvm/build/CMakeFiles/CMakeScratch/TryCompile-tnlfb1/CMakeLists.txt:2 (set):
-- Build with thread support...
  Syntax error in cmake code at
-- 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'.

@lhutton1
Copy link
Contributor Author

lhutton1 commented Nov 6, 2023

It seems CMAKE_INSTALL_LIBDIR is undefined: https://github.com/llvm/llvm-project/blob/main/llvm/cmake/modules/Findzstd.cmake#L39C31-L39C51. I wonder if adding -DCMAKE_INSTALL_LIBDIR=lib to the cmake command could help?

junrushao added a commit to junrushao/tvm that referenced this pull request Nov 6, 2023
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'.
```
Hzfengsy pushed a commit that referenced this pull request Nov 7, 2023
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'.
```
binarybana pushed a commit to binarybana/tvm that referenced this pull request Nov 14, 2023
* [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
binarybana pushed a commit to binarybana/tvm that referenced this pull request Nov 14, 2023
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'.
```
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