Browse Source

Merge pull request #2914 from acozzette/nacl

Added a workaround to allow building for NaCl
Adam Cozzette 8 years ago
parent
commit
585993201a
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/google/protobuf/stubs/port.h

+ 8 - 1
src/google/protobuf/stubs/port.h

@@ -44,6 +44,8 @@
 #include <stdint.h>
 #include <stdint.h>
 #endif
 #endif
 
 
+#include <google/protobuf/stubs/platform_macros.h>
+
 #undef PROTOBUF_LITTLE_ENDIAN
 #undef PROTOBUF_LITTLE_ENDIAN
 #ifdef _WIN32
 #ifdef _WIN32
   // Assuming windows is always little-endian.
   // Assuming windows is always little-endian.
@@ -359,7 +361,12 @@ class Bits {
   }
   }
 
 
   static uint32 Log2FloorNonZero64(uint64 n) {
   static uint32 Log2FloorNonZero64(uint64 n) {
-#if defined(__GNUC__)
+    // arm-nacl-clang runs into an instruction-selection failure when it
+    // encounters __builtin_clzll:
+    // https://bugs.chromium.org/p/nativeclient/issues/detail?id=4395
+    // To work around this, when we build for NaCl we use the portable
+    // implementation instead.
+#if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_OS_NACL)
   return 63 ^ __builtin_clzll(n);
   return 63 ^ __builtin_clzll(n);
 #else
 #else
   return Log2FloorNonZero64_Portable(n);
   return Log2FloorNonZero64_Portable(n);