Package: mongo-cxx-driver-legacy
Version: 1.1.2-3
Severity: important
Tags: sid + patch
Justification: FTBFS
User: debian-m...@lists.debian.org
Usertags: mips-patch


Package mongo-cxx-driver-legacy_1.1.2-3 FTBFS on mips and mipsel with following 
error:

> build/linux2/c++11_on/ssl/mongo/client/dbclient.os: In function 
> `std::__atomic_base<long long>::fetch_add(long long, std::memory_order)':
> /usr/include/c++/6/bits/atomic_base.h:514: undefined reference to 
> `__atomic_fetch_add_8'
> /usr/include/c++/6/bits/atomic_base.h:514: undefined reference to 
> `__atomic_fetch_add_8'
> collect2: error: ld returned 1 exit status
> scons: *** [build/linux2/c++11_on/ssl/libmongoclient.so.0.0.0] Error 1
> scons: building terminated because of errors.

Full build log:
https://buildd.debian.org/status/fetch.php?pkg=mongo-cxx-driver-legacy&arch=mips&ver=1.1.2-3&stamp=1479670183

The problem occurs because for 64-bits atomic operations on mips/mipsel it is 
needed to use libatomic library.
Configure tests CheckCXX11Atomics, CheckGCCAtomicBuiltins and 
CheckGCCSyncBuiltins does not cover this specific case.
Tests detect that mips has atomic operations (32-bits) but build fails during 
compilation because 64-bits atomic are needed.


I have created and attached a patch that corrects these tests and adds latomic 
into LIBS for mips/mipsel.
With this patch package builds successfully on mips, mipsel, mips64el and i386 
architectures.

Regards,
Radovan
--- mongo-cxx-driver-legacy-1.1.2.orig/SConstruct
+++ mongo-cxx-driver-legacy-1.1.2/SConstruct
@@ -686,7 +686,10 @@ if darwin:
 elif linux:
 
     env.Append( LIBS=['m'] )
-
+    
+    if 'mips' in os.uname()[4] and '32bit' in py_platform.architecture():
+        env.Append( LIBS=['atomic'] )
+	
     if os.uname()[4] == "x86_64" and not force32:
         linux64 = True
         nixLibPrefix = "lib64"
@@ -1597,7 +1600,7 @@ def doConfigure(myenv):
         test_body = """
         #include <atomic>
         int main(int argc, char **argv) {
-            std::atomic<int> a(0);
+            std::atomic<long long> a(0);
             return a.fetch_add(1);
         }
         """
@@ -1609,9 +1612,9 @@ def doConfigure(myenv):
     def CheckGCCAtomicBuiltins(context):
         test_body = """
         int main(int argc, char **argv) {
-            int a = 0;
-            int b = 0;
-            int c = 0;
+            long long a = 0;
+            long long b = 0;
+            long long c = 0;
 
             __atomic_compare_exchange(&a, &b, &c, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
             return 0;
@@ -1625,7 +1628,7 @@ def doConfigure(myenv):
     def CheckGCCSyncBuiltins(context):
         test_body = """
         int main(int argc, char **argv) {
-            int a = 0;
+            long long a = 0;
             return __sync_fetch_and_add(&a, 1);
         }
 

Reply via email to