Skip to content

Commit

Permalink
onnx: update to support abseil CXX language standard requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor Baker committed Aug 22, 2023
1 parent 1097f47 commit 062a9c4
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions pkgs/development/libraries/science/math/onnx/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
fetchFromGitHub,
fetchpatch,
lib,
stdenv,
# nativeBuildInputs
Expand All @@ -21,6 +22,7 @@
buildSharedLibs ? true,
}: let
gtestStatic = gtest.override {static = true;};
# protobuf-17 = protobuf.override {};
setBuildSharedLibrary = bool:
if bool
then "shared"
Expand All @@ -29,15 +31,27 @@ in
stdenv.mkDerivation (finalAttrs: {
strictDeps = true;
pname = "onnx";
version = "1.14.0";
# TODO(@connorbaker): Can't use our current version of onnx due to this issue: https://github.com/onnx/onnx/issues/5430; requires us to use a version of onnx that is not yet released because the patchset isn't clean.
version = "8a980683df9acbcb82dc3385fc7eb8cce4ed840f";

src = fetchFromGitHub {
owner = finalAttrs.pname;
repo = finalAttrs.pname;
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-f+s25Y/jGosaSdoZY6PE3j6pENkfDcD+IQndrbtuzWg=";
rev = "8a980683df9acbcb82dc3385fc7eb8cce4ed840f";
hash = "sha256-i60ypUNofpqOtnmrpkNA3j7iDEYQMtDSuSzTw4V/X3s=";
};

# patches = [
# (fetchpatch {
# url = "https://github.com/onnx/onnx/pull/5119.patch";
# hash = "sha256-FGLq1sLO7U+pCCPXGGLN+UcH6NjarxoSBl8UDtb5UBs=";
# })
# (fetchpatch {
# url = "https://github.com/onnx/onnx/pull/5196.patch";
# hash = "sha256-VDmhB3nNP1mPNNuBszvVTTq3appM7msA+K6WRK1Tf6Y=";
# })
# ];

doCheck = true;

nativeBuildInputs = [
Expand All @@ -49,6 +63,13 @@ in
# pybind11
];

# Though abseil-cpp is a propagatedBuildInput of protobuf, Nix doesn't see it here.
# Moving protobuf to buildInputs fixes this, but then we have protobuf in the runtime
# environment, which we don't want (it is a build-time dependency only).
buildInputs = [
protobuf.abseil-cpp
];

# propagatedBuildInputs = [
# protobuf
# numpy
Expand All @@ -62,6 +83,17 @@ in
# tabulate
# ];

# patches = [
# (fetchpatch {
# url = "https://github.com/onnx/onnx/pull/5196.patch";
# hash = "sha256-VDmhB3nNP1mPNNuBszvVTTq3appM7msA+K6WRK1Tf6Y=";
# })
# (fetchpatch {
# url = "https://github.com/onnx/onnx/pull/5355.patch";
# hash = "sha256-WFcqodTydsllL4hJvKQ95D2xHNmWw7Jjwgg67a/UbZc=";
# })
# ];

postPatch = ''
chmod +x tools/protoc-gen-mypy.sh.in
patchShebangs tools/protoc-gen-mypy.sh.in
Expand All @@ -79,6 +111,7 @@ in
cmakeFlags = [
"-DBUILD_SHARED_LIBS=${setBuildSharedLibrary buildSharedLibs}"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_CXX_STANDARD=17" # required by abseil-cpp; bump when abseil-cpp does
"-DONNX_USE_PROTOBUF_SHARED_LIBS=ON"
"-DONNX_BUILD_TESTS=ON"
"-Dgoogletest_STATIC_LIBRARIES=${gtestStatic}/lib/libgtest.a"
Expand Down

0 comments on commit 062a9c4

Please sign in to comment.