[CDRIVER-616] __sync_add_and_fetch_4 missing on i386 Created: 13/Apr/15  Updated: 07/Oct/15  Resolved: 07/May/15

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1.5

Type: Bug Priority: Major - P3
Reporter: Jonathan Reams Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to CDRIVER-365 don't use __sync_fetch_and_add for 64... Closed

 Description   

When on GCC 4.1 compiling for i386, we don't use the intrinsic version of __sync_add_and_fetch for 64-bit values, but do use the intrinsic of __sync_add_and_fetch for 32-bit values, which leads to a compile failure. I believe this is an extension of CDRIVER-365.

A workaround for this is to compile with "-march=i686", which turns on the compiler intrinsic.



 Comments   
Comment by Githook User [ 07/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: Merge branch 'master' into 1.2.0-dev

  1. By A. Jesse Jiryu Davis (13) and others
  • master:
    post-release bump
    1.1.6 Release
    Post release bump
    1.1.5 Release
    CDRIVER-616 don't export bson_atomic_int_add / bson_atomic_int64_add on windows
    CDRIVER-616 export bson_atomic_int_add / bson_atomic_int64_add on i386
    thank chergert for code reviews and guidance
    update NEWS for 1.1.5
    begin NEWS for 1.1.5 release
    start .mci.yml
    separate checks for 32- and 64-bit atomics
    ensure bool value is 0 or 1 on old compilers
    avoid "logical-op" warning
    CDRIVER-616 missing "__sync_add_and_fetch_4" on i386
    Clear "Implicit conversion loses integer precision" warnings

Conflicts:
CMakeLists.txt
NEWS
build/autotools/Versions.m4
build/rpm/libbson.spec
doc/version.page
Branch: master
https://github.com/mongodb/libbson/commit/4d167597229b0de4dbdc12ed98472ddbcbb3d412

Comment by Githook User [ 07/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: Merge branch 'master' into 1.2.0-dev

  1. By A. Jesse Jiryu Davis (13) and others
  • master:
    post-release bump
    1.1.6 Release
    Post release bump
    1.1.5 Release
    CDRIVER-616 don't export bson_atomic_int_add / bson_atomic_int64_add on windows
    CDRIVER-616 export bson_atomic_int_add / bson_atomic_int64_add on i386
    thank chergert for code reviews and guidance
    update NEWS for 1.1.5
    begin NEWS for 1.1.5 release
    start .mci.yml
    separate checks for 32- and 64-bit atomics
    ensure bool value is 0 or 1 on old compilers
    avoid "logical-op" warning
    CDRIVER-616 missing "__sync_add_and_fetch_4" on i386
    Clear "Implicit conversion loses integer precision" warnings

Conflicts:
CMakeLists.txt
NEWS
build/autotools/Versions.m4
build/rpm/libbson.spec
doc/version.page
Branch: master
https://github.com/mongodb/libbson/commit/4d167597229b0de4dbdc12ed98472ddbcbb3d412

Comment by Githook User [ 07/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: Merge branch 'master' into 1.2.0-dev

  1. By A. Jesse Jiryu Davis (13) and others
  • master:
    post-release bump
    1.1.6 Release
    Post release bump
    1.1.5 Release
    CDRIVER-616 don't export bson_atomic_int_add / bson_atomic_int64_add on windows
    CDRIVER-616 export bson_atomic_int_add / bson_atomic_int64_add on i386
    thank chergert for code reviews and guidance
    update NEWS for 1.1.5
    begin NEWS for 1.1.5 release
    start .mci.yml
    separate checks for 32- and 64-bit atomics
    ensure bool value is 0 or 1 on old compilers
    avoid "logical-op" warning
    CDRIVER-616 missing "__sync_add_and_fetch_4" on i386
    Clear "Implicit conversion loses integer precision" warnings

Conflicts:
CMakeLists.txt
NEWS
build/autotools/Versions.m4
build/rpm/libbson.spec
doc/version.page
Branch: master
https://github.com/mongodb/libbson/commit/4d167597229b0de4dbdc12ed98472ddbcbb3d412

Comment by A. Jesse Jiryu Davis [ 22/Apr/15 ]

The hand-built logic to determine whether __sync_add_and_fetch is available, in bson-atomic.h, should be replaced with a configure-time check.

Comment by Jonathan Reams [ 13/Apr/15 ]

Actually, this is reproducible in the latest version of GCC.

 $ gcc --version                                                                                                                                      [14:42:51]
gcc (GCC) 4.9.2 20150304 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 $ CFLAGS="-m32 -march=i386" ./configure
...
libbson was configured with the following options:
 
Build configuration:
  Enable debugging (slow)                          : no
  Compile with debug symbols (slow)                : no
  Enable GCC build optimization                    : yes
  Enable automatic binary hardening                : yes
  Code coverage support                            : no
  Cross Compiling                                  : no
  Big endian                                       : no
  Link Time Optimization (experimental)            : no
 
Documentation:
  man                                              : no
  HTML                                             : no
 $ make -j17
...
./.libs/libbson-1.0.so: undefined reference to `__sync_add_and_fetch_4'
collect2: error: ld returned 1 exit status
Makefile:1057: recipe for target 'bcon-speed' failed
make: *** [bcon-speed] Error 1
make: *** Waiting for unfinished jobs....
./.libs/libbson-1.0.so: undefined reference to `__sync_add_and_fetch_4'
collect2: error: ld returned 1 exit status
Makefile:1069: recipe for target 'bson-to-json' failed
make: *** [bson-to-json] Error 1
./.libs/libbson-1.0.so: undefined reference to `__sync_add_and_fetch_4'
collect2: error: ld returned 1 exit status
Makefile:1075: recipe for target 'bson-validate' failed
make: *** [bson-validate] Error 1
./.libs/libbson-1.0.so: undefined reference to `__sync_add_and_fetch_4'
collect2: error: ld returned 1 exit status
./.libs/libbson-1.0.so: undefined reference to `__sync_add_and_fetch_4'
collect2: error: ld returned 1 exit status
./.libs/libbson-1.0.so: undefined reference to `__sync_add_and_fetch_4'
collect2: error: ld returned 1 exit status
Makefile:1051: recipe for target 'bcon-col-view' failed
make: *** [bcon-col-view] Error 1
Makefile:1081: recipe for target 'json-to-bson' failed
make: *** [json-to-bson] Error 1
Makefile:1063: recipe for target 'bson-metrics' failed
make: *** [bson-metrics] Error 1
tests/test_libbson-TestSuite.o: In function `TestSuite_ParallelWorker':
TestSuite.c:(.text+0x517): undefined reference to `__sync_add_and_fetch_4'
collect2: error: ld returned 1 exit status
Makefile:1127: recipe for target 'test-libbson' failed
make: *** [test-libbson] Error 1

Generated at Wed Feb 07 21:10:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.