gemini-code-assist[bot] commented on code in PR #19815:
URL: https://github.com/apache/tvm/pull/19815#discussion_r3427951590


##########
cmake/utils/FindLLVM.cmake:
##########
@@ -208,7 +208,12 @@ macro(find_llvm use_llvm)
         endif()
       elseif("${__flag}" STREQUAL "-lxml2")
         message(STATUS "LLVM links against xml2")
-        list(APPEND LLVM_LIBS "-lxml2")
+        if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+          find_library(__llvm_xml2_library NAMES xml2 HINTS "${__llvm_libdir}" 
REQUIRED)
+          list(APPEND LLVM_LIBS "${__llvm_xml2_library}")

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `find_library` caches its result in the CMake cache, if a developer 
re-runs CMake with a different LLVM path (which changes `${__llvm_libdir}`), 
the cached value of `__llvm_xml2_library` will persist and point to the old 
path. To ensure the library is correctly re-resolved when the LLVM path 
changes, we should unset `__llvm_xml2_library` from the cache before calling 
`find_library`.
   
   ```
           if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
             unset(__llvm_xml2_library CACHE)
             find_library(__llvm_xml2_library NAMES xml2 HINTS 
"${__llvm_libdir}" REQUIRED)
             list(APPEND LLVM_LIBS "${__llvm_xml2_library}")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to