fix compilation on gcc7

+52 -2
+6 -2
pkgs/development/libraries/science/math/caffe2/default.nix
··· 1 - { stdenv, lib, config, fetchFromGitHub 1 + { stdenv, lib, config, fetchFromGitHub, fetchpatch 2 2 , cmake 3 3 , glog, google-gflags, gtest 4 4 , protobuf, snappy ··· 56 56 }; 57 57 dst = "pybind11"; 58 58 }; 59 + 60 + ccVersion = (builtins.parseDrvName stdenv.cc.name).version; 59 61 in 60 62 61 63 stdenv.mkDerivation rec { ··· 84 86 ; 85 87 propagatedBuildInputs = [ numpy future six python-protobuf pydot ]; 86 88 87 - patches = lib.optional stdenv.cc.isClang [ ./update_clang_cvtsh_bugfix.patch ]; 89 + patches = lib.optional (stdenv.cc.isGNU && lib.versionAtLeast ccVersion "7.0.0") [ 90 + ./fix_compilation_on_gcc7.patch 91 + ] ++ lib.optional stdenv.cc.isClang [ ./update_clang_cvtsh_bugfix.patch ]; 88 92 89 93 cmakeFlags = [ ''-DBUILD_TEST=OFF'' 90 94 ''-DBUILD_PYTHON=ON''
+46
pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch
··· 1 + diff --git a/caffe2/operators/recurrent_network_op.cc b/caffe2/operators/recurrent_network_op.cc 2 + index dd4fded..5995e8a 100644 3 + --- a/caffe2/operators/recurrent_network_op.cc 4 + +++ b/caffe2/operators/recurrent_network_op.cc 5 + @@ -1,4 +1,4 @@ 6 + -#include "recurrent_network_op.h" 7 + +#include "caffe2/operators/recurrent_network_op.h" 8 + #include "caffe2/core/workspace.h" 9 + 10 + namespace caffe2 { 11 + diff --git a/caffe2/operators/recurrent_network_op.h b/caffe2/operators/recurrent_network_op.h 12 + index 55328e5..ea898bc 100644 13 + --- a/caffe2/operators/recurrent_network_op.h 14 + +++ b/caffe2/operators/recurrent_network_op.h 15 + @@ -762,8 +762,8 @@ class AccumulateInputGradientOp : public Operator<Context> { 16 + USE_OPERATOR_CONTEXT_FUNCTIONS; 17 + 18 + bool RunOnDevice() override { 19 + - const auto t = 20 + - OperatorBase::Input<Tensor<CPUContext>>(0).template data<int32_t>()[0]; 21 + + const auto& t0 = OperatorBase::Input<Tensor<CPUContext>>(0); 22 + + const auto t = t0.template data<int32_t>()[0]; 23 + auto& og = Input(1); 24 + auto* g = Output(0); 25 + 26 + diff --git a/caffe2/queue/queue_ops.h b/caffe2/queue/queue_ops.h 27 + index f2c0a33..642343f 100644 28 + --- a/caffe2/queue/queue_ops.h 29 + +++ b/caffe2/queue/queue_ops.h 30 + @@ -17,13 +17,10 @@ class CreateBlobsQueueOp final : public Operator<Context> { 31 + name(operator_def.output().Get(0)) {} 32 + 33 + bool RunOnDevice() override { 34 + - const auto capacity = 35 + - OperatorBase::template GetSingleArgument<int>("capacity", 1); 36 + - const auto numBlobs = 37 + - OperatorBase::template GetSingleArgument<int>("num_blobs", 1); 38 + + const auto capacity = GetSingleArgument("capacity", 1); 39 + + const auto numBlobs = GetSingleArgument("num_blobs", 1); 40 + const auto enforceUniqueName = 41 + - OperatorBase::template GetSingleArgument<int>( 42 + - "enforce_unique_name", false); 43 + + GetSingleArgument("enforce_unique_name", false); 44 + const auto fieldNames = 45 + OperatorBase::template GetRepeatedArgument<std::string>("field_names"); 46 + CAFFE_ENFORCE_EQ(this->OutputSize(), 1);