Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3988 from acozzette/down-integrate
Integrated internal changes from Google
- Loading branch information
Showing
142 changed files
with
4,456 additions
and
3,270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
// Protocol Buffers - Google's data interchange format | |||
// Copyright 2008 Google Inc. All rights reserved. | |||
// https://developers.google.com/protocol-buffers/ | |||
// | |||
// Redistribution and use in source and binary forms, with or without | |||
// modification, are permitted provided that the following conditions are | |||
// met: | |||
// | |||
// * Redistributions of source code must retain the above copyright | |||
// notice, this list of conditions and the following disclaimer. | |||
// * Redistributions in binary form must reproduce the above | |||
// copyright notice, this list of conditions and the following disclaimer | |||
// in the documentation and/or other materials provided with the | |||
// distribution. | |||
// * Neither the name of Google Inc. nor the names of its | |||
// contributors may be used to endorse or promote products derived from | |||
// this software without specific prior written permission. | |||
// | |||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
|
|||
package com.google.protobuf; | |||
|
|||
final class Android { | |||
|
|||
private static final Class<?> MEMORY_CLASS = getClassForName("libcore.io.Memory"); | |||
private static final boolean IS_ROBOLECTRIC = | |||
getClassForName("org.robolectric.Robolectric") != null; | |||
|
|||
/** Returns {@code true} if running on an Android device. */ | |||
static boolean isOnAndroidDevice() { | |||
return MEMORY_CLASS != null && !IS_ROBOLECTRIC; | |||
} | |||
|
|||
/** Returns the memory class or {@code null} if not on Android device. */ | |||
static Class<?> getMemoryClass() { | |||
return MEMORY_CLASS; | |||
} | |||
|
|||
@SuppressWarnings("unchecked") | |||
private static <T> Class<T> getClassForName(String name) { | |||
try { | |||
return (Class<T>) Class.forName(name); | |||
} catch (Throwable e) { | |||
return null; | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
9021f62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My protobuf bazel builds started failing with this CL. I run tests on both a debian8-clang and an ubuntu-gcc environments. Tests fail on both environments with a similar error message:
Message on debian8-clang (gcr.io/cloud-marketplace/google/clang-debian8)
ERROR: /protobuf/BUILD:473:1: Linking of rule '//:test_plugin' failed (Exit 1): clang failed: error executing command
(cd /root/.cache/bazel/_bazel_root/c10d995b71ee2cb34bd3247d67c66df9/execroot/com_google_protobuf &&
exec env -
PWD=/proc/self/cwd
/usr/local/bin/clang -o bazel-out/k8-fastbuild/bin/test_plugin -pthread '-fuse-ld=gold' -B/usr/local/bin -B/usr/bin -Wl,-S -Wl,@bazel-out/k8-fastbuild/bin/test_plugin-2.params)
Use --sandbox_debug to see verbose messages from the sandbox
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::RepeatedPtrFieldBase::AddWeak(google::protobuf::MessageLite const*): error: undefined reference to 'typeinfo for google::protobuf::internal::ImplicitWeakMessage'
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(google::protobuf::Arena*): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
Target //:protobuf_test failed to build
Message on ubuntu-trusty-gcc (stock ubuntu:trusty with gcc + bazel installed):
ERROR: /project_src/BUILD:473:1: Linking of rule '//:test_plugin' failed (Exit 1): gcc failed: error executing command
(cd /root/.cache/bazel/_bazel_root/7e958634aed2e0b9513fa7cce861a282/execroot/com_google_protobuf &&
exec env -
PWD=/proc/self/cwd
/usr/bin/gcc -o bazel-out/k8-fastbuild/bin/test_plugin -pthread '-fuse-ld=gold' -Wl,-no-as-needed -Wl,-z,relro,-z,now -B/usr/bin -B/usr/bin -pass-exit-codes -Wl,-S -Wl,@bazel-out/k8-fastbuild/bin/test_plugin-2.params)
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::RepeatedPtrFieldBase::AddWeak(google::protobuf::MessageLite const*): error: undefined reference to 'typeinfo for google::protobuf::internal::ImplicitWeakMessage'
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(google::protobuf::Arena*): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
collect2: error: ld returned 1 exit status
Target //:protobuf_test failed to build
9021f62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nlopezgi Sorry about that, I've just sent out pull request #4017 which should fix this.
9021f62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the quick response, our builds are now green