summary refs log tree commit diff
path: root/pkgs/development/libraries/science
diff options
context:
space:
mode:
authorYuri Aisaka <yuri.aisaka@gmail.com>2018-03-09 22:32:42 +0900
committerYuri Aisaka <yuri.aisaka@gmail.com>2018-03-09 22:34:25 +0900
commite559fa19f319c0208fc27261faa479a8abec2d00 (patch)
treeae366a4fed1851a7120ce78ed71e42a2283682b6 /pkgs/development/libraries/science
parent8dcd7f0d85072dfbee958a31556383fc40854ea3 (diff)
downloadnixlib-e559fa19f319c0208fc27261faa479a8abec2d00.tar
nixlib-e559fa19f319c0208fc27261faa479a8abec2d00.tar.gz
nixlib-e559fa19f319c0208fc27261faa479a8abec2d00.tar.bz2
nixlib-e559fa19f319c0208fc27261faa479a8abec2d00.tar.lz
nixlib-e559fa19f319c0208fc27261faa479a8abec2d00.tar.xz
nixlib-e559fa19f319c0208fc27261faa479a8abec2d00.tar.zst
nixlib-e559fa19f319c0208fc27261faa479a8abec2d00.zip
fix compilation on gcc7
Diffstat (limited to 'pkgs/development/libraries/science')
-rw-r--r--pkgs/development/libraries/science/math/caffe2/default.nix8
-rw-r--r--pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch46
2 files changed, 52 insertions, 2 deletions
diff --git a/pkgs/development/libraries/science/math/caffe2/default.nix b/pkgs/development/libraries/science/math/caffe2/default.nix
index b055acba9f15..af7078599db5 100644
--- a/pkgs/development/libraries/science/math/caffe2/default.nix
+++ b/pkgs/development/libraries/science/math/caffe2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, config, fetchFromGitHub
+{ stdenv, lib, config, fetchFromGitHub, fetchpatch
 , cmake
 , glog, google-gflags, gtest
 , protobuf, snappy
@@ -56,6 +56,8 @@ let
     };
     dst = "pybind11";
   };
+
+  ccVersion = (builtins.parseDrvName stdenv.cc.name).version;
 in
 
 stdenv.mkDerivation rec {
@@ -84,7 +86,9 @@ stdenv.mkDerivation rec {
   ;
   propagatedBuildInputs = [ numpy future six python-protobuf pydot ];
 
-  patches = lib.optional stdenv.cc.isClang [ ./update_clang_cvtsh_bugfix.patch ];
+  patches = lib.optional (stdenv.cc.isGNU && lib.versionAtLeast ccVersion "7.0.0") [
+    ./fix_compilation_on_gcc7.patch
+  ] ++ lib.optional stdenv.cc.isClang [ ./update_clang_cvtsh_bugfix.patch ];
 
   cmakeFlags = [ ''-DBUILD_TEST=OFF''
                  ''-DBUILD_PYTHON=ON''
diff --git a/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch b/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch
new file mode 100644
index 000000000000..f319f20233a2
--- /dev/null
+++ b/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch
@@ -0,0 +1,46 @@
+diff --git a/caffe2/operators/recurrent_network_op.cc b/caffe2/operators/recurrent_network_op.cc
+index dd4fded..5995e8a 100644
+--- a/caffe2/operators/recurrent_network_op.cc
++++ b/caffe2/operators/recurrent_network_op.cc
+@@ -1,4 +1,4 @@
+-#include "recurrent_network_op.h"
++#include "caffe2/operators/recurrent_network_op.h"
+ #include "caffe2/core/workspace.h"
+ 
+ namespace caffe2 {
+diff --git a/caffe2/operators/recurrent_network_op.h b/caffe2/operators/recurrent_network_op.h
+index 55328e5..ea898bc 100644
+--- a/caffe2/operators/recurrent_network_op.h
++++ b/caffe2/operators/recurrent_network_op.h
+@@ -762,8 +762,8 @@ class AccumulateInputGradientOp : public Operator<Context> {
+   USE_OPERATOR_CONTEXT_FUNCTIONS;
+ 
+   bool RunOnDevice() override {
+-    const auto t =
+-        OperatorBase::Input<Tensor<CPUContext>>(0).template data<int32_t>()[0];
++    const auto& t0 = OperatorBase::Input<Tensor<CPUContext>>(0);
++    const auto t = t0.template data<int32_t>()[0];
+     auto& og = Input(1);
+     auto* g = Output(0);
+ 
+diff --git a/caffe2/queue/queue_ops.h b/caffe2/queue/queue_ops.h
+index f2c0a33..642343f 100644
+--- a/caffe2/queue/queue_ops.h
++++ b/caffe2/queue/queue_ops.h
+@@ -17,13 +17,10 @@ class CreateBlobsQueueOp final : public Operator<Context> {
+         name(operator_def.output().Get(0)) {}
+ 
+   bool RunOnDevice() override {
+-    const auto capacity =
+-        OperatorBase::template GetSingleArgument<int>("capacity", 1);
+-    const auto numBlobs =
+-        OperatorBase::template GetSingleArgument<int>("num_blobs", 1);
++    const auto capacity = GetSingleArgument("capacity", 1);
++    const auto numBlobs = GetSingleArgument("num_blobs", 1);
+     const auto enforceUniqueName =
+-        OperatorBase::template GetSingleArgument<int>(
+-            "enforce_unique_name", false);
++        GetSingleArgument("enforce_unique_name", false);
+     const auto fieldNames =
+         OperatorBase::template GetRepeatedArgument<std::string>("field_names");
+     CAFFE_ENFORCE_EQ(this->OutputSize(), 1);