From d86fc14f8bb7ab11985d43c0129169c4129f56ba Mon Sep 17 00:00:00 2001 From: Elliot Cameron Date: Fri, 15 Mar 2024 15:02:37 -0400 Subject: [PATCH] dcgm: add static build option Currently only one dependency (yaml-cpp) actually supports being either static or dynamic because DCGM's build system hard-codes the use of static artifacts for other dependencies. We note that in the comments as future work. --- pkgs/os-specific/linux/dcgm/default.nix | 31 +++++++++++-------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/pkgs/os-specific/linux/dcgm/default.nix b/pkgs/os-specific/linux/dcgm/default.nix index 7017c34a7ddd..351c0909de3b 100644 --- a/pkgs/os-specific/linux/dcgm/default.nix +++ b/pkgs/os-specific/linux/dcgm/default.nix @@ -15,19 +15,10 @@ , symlinkJoin , tclap_1_4 , yaml-cpp + +, static ? gcc11Stdenv.hostPlatform.isStatic }: let - # Flags copied from DCGM's libevent build script - libevent-nossl = libevent.override { sslSupport = false; }; - libevent-nossl-static = libevent-nossl.overrideAttrs (super: { - CFLAGS = "-Wno-cast-function-type -Wno-implicit-fallthrough -fPIC"; - CXXFLAGS = "-Wno-cast-function-type -Wno-implicit-fallthrough -fPIC"; - configureFlags = super.configureFlags ++ [ "--disable-shared" "--with-pic" ]; - }); - - jsoncpp-static = jsoncpp.override { enableStatic = true; }; - yaml-cpp-static = yaml-cpp.override { static = true; }; - # DCGM depends on 3 different versions of CUDA at the same time. # The runtime closure, thankfully, is quite small because most things # are statically linked. @@ -117,14 +108,18 @@ in gcc11Stdenv.mkDerivation rec { ]; buildInputs = [ - plog.dev # header-only - tclap_1_4 # header-only - + # Header-only catch2 - fmt_9 - jsoncpp-static - libevent-nossl-static - yaml-cpp-static + 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; }) ]; disallowedReferences = lib.concatMap (x: x.pkgSet) cudaPackageSetByVersion;