Bug#805072: protobuf: FTBFS on sparc64 - apparently tries to build x86 code
Source: protobuf
Followup-For: Bug #805072
Dear Maintainer,
The x86 sources are actually included on every platform. If you look at the
build logs for powerpc for example you can see them being included. The
contents are just preprocessed out everywhere except on intel.
The build is failing because the type 'Atomic64' is not defined. This is
supposed to be defined in src/google/protobuf/stubs/atomicops.h:
#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT
// We need to be able to go between Atomic64 and AtomicWord implicitly. This
// means Atomic64 and AtomicWord should be the same type on 64-bit.
#if defined(__ILP32__) || defined(GOOGLE_PROTOBUF_OS_NACL) || defined(GOOGLE_PROTOBUF_ARCH_SPARC)
// NaCl's intptr_t is not actually 64-bits on 64-bit!
// http://code.google.com/p/nativeclient/issues/detail?id=1162
// sparcv9's pointer type is 32bits
typedef int64 Atomic64;
#else
typedef intptr_t Atomic64;
#endif
#endif
But it is failing to be defined here because GOOGLE_PROTOBUF_ARCH_64_BIT
is not being defind on Debian/sparc64. GOOGLE_PROTOBUF_ARCH_64_BIT is
supposed to be defined in src/google/protobuf/stubs/platform_macros.h.
Here is the section about sparc:
#elif defined(sparc)
#define GOOGLE_PROTOBUF_ARCH_SPARC 1
#ifdef SOLARIS_64BIT_ENABLED
#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
#else
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#endif
So it's checking whether SOLARIS_64BIT_ENABLED is defined to determine
if it's on a 64bit arch. This is not defined on sparc64 linux so
but instead we can check for __LP64__, making that section into:
#elif defined(sparc)
#define GOOGLE_PROTOBUF_ARCH_SPARC 1
#if defined(SOLARIS_64BIT_ENABLED) || defined(__LP64__)
#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
#else
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#endif
So now it checks for either SOLARIS_64BIT_ENABLED or __LP64__ to
determine whether the sparc platform is 64bit. With this change the package
builds on my sparc64 system and it shouldn't affect any other archs.
I've attached a patch to implement this change.
Thanks!
David
-- System Information:
Debian Release: stretch/sid
APT prefers unreleased
APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: sparc64
Kernel: Linux 4.3.0-gentoo (SMP w/1 CPU core)
Locale: LANG=en_SG.UTF-8, LC_CTYPE=en_SG.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: unable to detect
--- a/src/google/protobuf/stubs/platform_macros.h
+++ b/src/google/protobuf/stubs/platform_macros.h
@@ -67,7 +67,7 @@
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#elif defined(sparc)
#define GOOGLE_PROTOBUF_ARCH_SPARC 1
-#ifdef SOLARIS_64BIT_ENABLED
+#if defined(SOLARIS_64BIT_ENABLED) || defined(__LP64__)
#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
#else
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
Reply to: