yelite commented on a change in pull request #10683:
URL: https://github.com/apache/tvm/pull/10683#discussion_r830431018
##########
File path: CMakeLists.txt
##########
@@ -736,6 +738,37 @@ if(BUILD_FOR_HEXAGON)
endif()
endif()
+
+if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID
STREQUAL "GNU"))
+ if(USE_LLD)
+ find_program(LLD_PATH "lld")
+ if(LLD_PATH)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=${LLD_PATH}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=${LLD_PATH}")
+ else()
+ if(USE_LLD STREQUAL "AUTO")
+ message(STATUS "Not using lld linker, executable was not found")
+ elseif(USE_LLD MATCHES ${IS_TRUE_PATTERN})
+ message(FATAL_ERROR "Could not find 'lld' executable but USE_LLD was
set to ON")
+ endif()
+ endif()
+ endif()
+
+ if(USE_MOLD)
+ find_program(MOLD_PATH "mold")
+ if(MOLD_PATH)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=${MOLD_PATH}")
Review comment:
Using mold in gcc is more complicated than this. gcc only supports
`-fuse-ld=mold` after 12.1 (which hasn't been released yet). Also I don't think
gcc can take a path in `-fuse-ld=xxx`.
https://github.com/rui314/mold#how-to-use has the correct way to use mold in
gcc prior to 12.1.
I have pushed the cmake file I used before at
https://github.com/yelite/tvm/commit/0a8c70a39f3585f811fc8bf90426ff1226ace8eb.
Hope that's helpful
##########
File path: CMakeLists.txt
##########
@@ -736,6 +738,37 @@ if(BUILD_FOR_HEXAGON)
endif()
endif()
+
+if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID
STREQUAL "GNU"))
+ if(USE_LLD)
+ find_program(LLD_PATH "lld")
+ if(LLD_PATH)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=${LLD_PATH}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=${LLD_PATH}")
+ else()
+ if(USE_LLD STREQUAL "AUTO")
+ message(STATUS "Not using lld linker, executable was not found")
+ elseif(USE_LLD MATCHES ${IS_TRUE_PATTERN})
+ message(FATAL_ERROR "Could not find 'lld' executable but USE_LLD was
set to ON")
+ endif()
+ endif()
+ endif()
+
+ if(USE_MOLD)
+ find_program(MOLD_PATH "mold")
+ if(MOLD_PATH)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=${MOLD_PATH}")
Review comment:
I would suggest using `CMAKE_SHARED_LINKER_FLAGS` (and other variants)
rather than `CMAKE_CXX_FLAGS`. The former will only be applied when linking the
library, while the latter will be apply to all compiler invocations (you will
probably get an unused flag warning).
--
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]