onnxruntime: fix build with CMake 4 (#443820)

This commit is contained in:
K900
2025-09-18 05:41:23 +00:00
committed by GitHub
2 changed files with 12 additions and 39 deletions
+4 -14
View File
@@ -2,7 +2,6 @@
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
cmake,
gtest,
pkg-config,
@@ -10,13 +9,13 @@
stdenv.mkDerivation rec {
pname = "microsoft-gsl";
version = "4.0.0";
version = "4.2.0";
src = fetchFromGitHub {
owner = "Microsoft";
repo = "GSL";
rev = "v${version}";
hash = "sha256-cXDFqt2KgMFGfdh6NGE+JmP4R0Wm9LNHM0eIblYe6zU=";
hash = "sha256-NrnYfCCeQ50oHYFbn9vh5Z4mfyxc0kAM3qnzQdq9gyM=";
};
nativeBuildInputs = [
@@ -25,17 +24,8 @@ stdenv.mkDerivation rec {
];
buildInputs = [ gtest ];
# negate the `-Werror` flag as Microsoft doesn't build with clang
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error";
patches = [
# nvcc doesn't recognize the "gsl" attribute namespace (microsoft/onnxruntime#13573)
# only affects nvcc
(fetchpatch {
url = "https://raw.githubusercontent.com/microsoft/onnxruntime/4bfa69def85476b33ccfaf68cf070f3fb65d39f7/cmake/patches/gsl/1064.patch";
hash = "sha256-0jESA+VENWQms9HGE0jRiZZuWLJehBlbArxSaQbYOrM=";
})
];
# C++17 required by latest gtest
env.NIX_CFLAGS_COMPILE = "-std=c++17";
doCheck = true;
+8 -25
View File
@@ -8,7 +8,6 @@
cpuinfo,
eigen,
flatbuffers_23,
gbenchmark,
glibcLocales,
gtest,
howard-hinnant-date,
@@ -18,8 +17,9 @@
python3Packages,
re2,
zlib,
microsoft-gsl,
protobuf,
microsoft-gsl,
darwinMinVersionHook,
pythonSupport ? true,
cudaSupport ? config.cudaSupport,
ncclSupport ? config.cudaSupport,
@@ -56,25 +56,6 @@ let
hash = "sha256-pjwjrqq6dfiVsXIhbBtbolhiysiFlFTnx5XcX77f+C0=";
};
pytorch_clog = effectiveStdenv.mkDerivation {
pname = "clog";
version = "3c8b153";
src = "${cpuinfo.src}/deps/clog";
nativeBuildInputs = [
cmake
gbenchmark
gtest
];
cmakeFlags = [
(lib.cmakeBool "USE_SYSTEM_GOOGLEBENCHMARK" true)
(lib.cmakeBool "USE_SYSTEM_GOOGLETEST" true)
(lib.cmakeBool "USE_SYSTEM_LIBS" true)
# 'clog' tests set 'CXX_STANDARD 11'; this conflicts with our 'gtest'.
(lib.cmakeBool "CLOG_BUILD_TESTS" false)
];
};
onnx = fetchFromGitHub {
owner = "onnx";
repo = "onnx";
@@ -92,8 +73,8 @@ let
dlpack = fetchFromGitHub {
owner = "dmlc";
repo = "dlpack";
tag = "v0.6";
hash = "sha256-YJdZ0cMtUncH5Z6TtAWBH0xtAIu2UcbjnVcCM4tfg20=";
rev = "5c210da409e7f1e51ddf445134a4376fdbd70d7d";
hash = "sha256-YqgzCyNywixebpHGx16tUuczmFS5pjCz5WjR89mv9eI=";
};
isCudaJetson = cudaSupport && cudaPackages.flags.isJetsonBuild;
@@ -139,7 +120,6 @@ effectiveStdenv.mkDerivation rec {
libpng
nlohmann_json
microsoft-gsl
pytorch_clog
zlib
]
++ lib.optionals (lib.meta.availableOn effectiveStdenv.hostPlatform cpuinfo) [
@@ -170,7 +150,10 @@ effectiveStdenv.mkDerivation rec {
nccl
]
)
);
)
++ lib.optionals effectiveStdenv.hostPlatform.isDarwin [
(darwinMinVersionHook "13.3")
];
nativeCheckInputs = [
gtest