From 734ec5c55984140031b06229190e9be5ef19f3c3 Mon Sep 17 00:00:00 2001
From: Junru Shao <junrushao1994@gmail.com>
Date: Wed, 4 Oct 2023 18:29:07 -0400
Subject: [PATCH] [Disco] Add -lrt to TVM runtime for NCCL

This commit adds `-lrt` to TVM runtime when linked against static NCCL.
The static NCCL depends on symbol `shm_unlink` which comes from librt.
---
 CMakeLists.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb622f3452a3..baa7a8dc1f83 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -895,8 +895,9 @@ if(USE_CUDA AND USE_NVTX)
 endif()
 
 if(USE_CUDA AND USE_NCCL)
-  target_link_libraries(tvm PRIVATE nccl)
-  target_link_libraries(tvm_runtime PRIVATE nccl)
+  find_library(LIBRT rt)
+  target_link_libraries(tvm PRIVATE nccl ${LIBRT})
+  target_link_libraries(tvm_runtime PRIVATE nccl ${LIBRT})
 endif()
 
 if(USE_ROCM AND USE_RCCL)