dcgm: remove static library cruft

Static CUDA seems to be broken anyway, the upstream build system is
awkward and uncooperative, and it’s simpler to just patch it to
use dynamic libraries.
This commit is contained in:
Emily 2024-11-19 18:31:39 +00:00
parent e75510817a
commit decc7e8faf
2 changed files with 48 additions and 9 deletions

View File

@ -0,0 +1,40 @@
diff --git a/cmake/FindJsoncpp.cmake b/cmake/FindJsoncpp.cmake
index abedf7bb85..d7a52f5c7b 100644
--- a/cmake/FindJsoncpp.cmake
+++ b/cmake/FindJsoncpp.cmake
@@ -16,8 +16,8 @@
if (NOT TARGET JsonCpp::JsonCpp)
find_package(jsoncpp REQUIRED CONFIG)
- set(JSONCPP_STATIC_LIBS jsoncpp_static)
- set(JSONCPP_INCLUDE_PATH $<TARGET_PROPERTY:jsoncpp_static,INTERFACE_INCLUDE_DIRECTORIES>)
+ set(JSONCPP_STATIC_LIBS jsoncpp)
+ set(JSONCPP_INCLUDE_PATH $<TARGET_PROPERTY:jsoncpp,INTERFACE_INCLUDE_DIRECTORIES>)
endif()
# set(Jsoncpp_PATH_PREFIXES /usr/local "${Jsoncpp_ROOT}" "$ENV{HOME}")
# foreach(prefix ${Jsoncpp_PATH_PREFIXES})
diff --git a/cmake/FindLibevent.cmake b/cmake/FindLibevent.cmake
index 354d6f9b99..38aca9534e 100644
--- a/cmake/FindLibevent.cmake
+++ b/cmake/FindLibevent.cmake
@@ -26,16 +26,12 @@
endforeach()
find_path(LIBEVENT_INCLUDE_DIR evhttp.h event.h PATHS ${Libevent_INCLUDE_PATHS})
-find_library(LIBEVENT_STATIC_LIB NAMES libevent.a libevent_core.a libevent_extra.a PATHS ${Libevent_LIB_PATHS})
-find_library(LIBEVENT_PTHREAD_STATIC_LIB NAMES libevent_pthreads.a PATHS ${Libevent_LIB_PATHS})
+find_library(LIBEVENT_STATIC_LIB NAMES libevent.so libevent_core.so libevent_extra.so PATHS ${Libevent_LIB_PATHS})
+find_library(LIBEVENT_PTHREAD_STATIC_LIB NAMES libevent_pthreads.so PATHS ${Libevent_LIB_PATHS})
-if (LIBEVENT_INCLUDE_DIR AND LIBEVENT_STATIC_LIB AND LIBEVENT_PTHREAD_STATIC_LIB)
+if (LIBEVENT_INCLUDE_DIR AND LIBEVENT_STATIC_LIB)
set(Libevent_FOUND TRUE)
- add_library(libevent_event_static STATIC IMPORTED)
- set_target_properties(libevent_event_static PROPERTIES IMPORTED_LOCATION ${LIBEVENT_STATIC_LIB})
- add_library(libevent_event_pthread STATIC IMPORTED)
- set_target_properties(libevent_event_pthread PROPERTIES IMPORTED_LOCATION ${LIBEVENT_PTHREAD_STATIC_LIB})
- set(LIBEVENT_STATIC_LIBS libevent_event_static libevent_event_pthread)
+ set(LIBEVENT_STATIC_LIBS ${LIBEVENT_STATIC_LIB} ${LIBEVENT_PTHREAD_STATIC_LIB})
else ()
set(Libevent_FOUND FALSE)
endif ()

View File

@ -17,8 +17,6 @@
, symlinkJoin
, tclap_1_4
, yaml-cpp
, static ? gcc11Stdenv.hostPlatform.isStatic
}:
let
# DCGM depends on 2 different versions of CUDA at the same time.
@ -74,6 +72,10 @@ in gcc11Stdenv.mkDerivation rec {
hash = "sha256-PysxuN5WT7GB0oOvT5ezYeOau6AMVDDWE5HOAcmqw/Y=";
};
patches = [
./dynamic-libs.patch
];
hardeningDisable = [ "all" ];
strictDeps = true;
@ -97,13 +99,10 @@ in gcc11Stdenv.mkDerivation rec {
plog.dev
tclap_1_4
# Dependencies that can be either static or dynamic.
(fmt_9.override { enableShared = !static; }) # DCGM's build uses the static outputs regardless of enableShared
(yaml-cpp.override { inherit static; stdenv = gcc11Stdenv; })
# TODO: Dependencies that DCGM's CMake hard-codes to be static-only.
(jsoncpp.override { enableStatic = true; })
(libevent.override { sslSupport = false; static = true; })
fmt_9
(yaml-cpp.override { stdenv = gcc11Stdenv; })
jsoncpp
libevent
];
# Add our paths to the CMake flags so FindCuda.cmake can find them.