Bug 1186561 - add #include <vector> to a protobuf header to work around problems on Android; r=fitzgen
authorNathan Froyd <froydnj@mozilla.com>
Wed, 22 Jul 2015 15:10:03 -0400
changeset 254519 3caca87b85d7a74941ba7d93e3cd3a7611788c81
parent 254518 cc03e18f0438a92863e8871fdffe8efa52c9f4a6
child 254520 3588beda4844d1e8aeb428c0875bab016f81657b
push id62780
push usernfroyd@mozilla.com
push dateFri, 24 Jul 2015 17:17:17 +0000
treeherdermozilla-inbound@3caca87b85d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1186561
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1186561 - add #include <vector> to a protobuf header to work around problems on Android; r=fitzgen Compiling Gecko with libc++ and GCC 4.9 on Android runs into a problem. The protobuf #includes and libc++ result in preprocessed code that looks something like: /* via <iterator> */ namespace std { namespace __1 { } using namespace __1 __attribute__((__strong__)); } namespace std { namespace __1 { template <class _Iter> class __wrap_iter { ... template <class _Tp, class _Alloc> friend class vector; ... }; } // namespace __1 } // namespace std /* via <vector> */ namespace std { namespace __1 { template <class _Tp, class _Alloc> class _LIBCPP_TYPE_VIS_ONLY vector : ... { ... }; } // namespace __1 } // namespace std and the problem is that GCC doesn't understand that the forward declaration of vector inside __wrap_iter is forward-declaring the actual vector class; it thinks it's declaring something else. Hacking <iterator> to include _LIBCPP_TYPE_VIS_ONLY for the forward declaration doesn't help. What does help is including <vector> earlier than <iterator>, so the __wrap_iter forward declaration picks up the correct definition of std::vector, and makes everything happy. It's possible that there are other places that could get this same treatment, but this one place was the only one I needed to modify to make things go.
toolkit/components/protobuf/m-c-changes.patch
toolkit/components/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
--- a/toolkit/components/protobuf/m-c-changes.patch
+++ b/toolkit/components/protobuf/m-c-changes.patch
@@ -358,8 +358,28 @@
        if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
        values->AddAlreadyReserved(value);
      }
  #endif
    } else {
      // This is the slow-path case where "length" may be too large to
      // safely allocate.  We read as much as we can into *values
      // without pre-allocating "length" bytes.
+--- a/toolkit/components/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
++++ b/toolkit/components/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
+@@ -39,16 +39,17 @@
+ // streams.  Of course, many users will probably want to write their own
+ // implementations of these interfaces specific to the particular I/O
+ // abstractions they prefer to use, but these should cover the most common
+ // cases.
+ 
+ #ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
+ #define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
+ 
++#include <vector> /* See Bug 1186561 */
+ #include <string>
+ #include <iosfwd>
+ #include <google/protobuf/io/zero_copy_stream.h>
+ #include <google/protobuf/stubs/common.h>
+ #include <google/protobuf/stubs/stl_util.h>
+ 
+ 
+ namespace google {
--- a/toolkit/components/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
+++ b/toolkit/components/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
@@ -39,16 +39,17 @@
 // streams.  Of course, many users will probably want to write their own
 // implementations of these interfaces specific to the particular I/O
 // abstractions they prefer to use, but these should cover the most common
 // cases.
 
 #ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
 #define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
 
+#include <vector> /* See Bug 1186561 */
 #include <string>
 #include <iosfwd>
 #include <google/protobuf/io/zero_copy_stream.h>
 #include <google/protobuf/stubs/common.h>
 #include <google/protobuf/stubs/stl_util.h>
 
 
 namespace google {