Bug 34316 - undefined reference to `__sync_add_and_fetch_8'
Summary: undefined reference to `__sync_add_and_fetch_8'
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: Other ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-09-26 05:13 UTC by yugiohjcj
Modified: 2016-01-26 04:55 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description yugiohjcj 2015-09-26 05:13:59 UTC
Hello,

I would like to compile mono but it fails (tested with mono-4.2.1.36, mono-3.12.1 and mono-3.10.0).
Here is what happens with mono-4.2.1.36:
$ ./configure --prefix=/usr
[...]
        mcs source:    mcs

   Engine:
	Host:	       i686-pc-linux-gnu
	Target:	       i686-pc-linux-gnu
	GC:	       sgen and Included Boehm GC with typed GC and parallel mark
	TLS:           __thread
	SIGALTSTACK:   yes
	Engine:        Building and using the JIT
	oprofile:      no
	BigArrays:     no
	DTrace:        no
	LLVM Back End: no (dynamically loaded: no)

   Libraries:
	.NET 4.5:        yes
	MonoDroid:       no
	Xamarin.iOS:     no
	Xamarin.WatchOS: no
	Xamarin.Mac:     no
	JNI support:     IKVM Native
	libgdiplus:      assumed to be installed
	zlib:            system zlib
$ make
[...]
  CC     libmonoruntimesgen_static_la-sgen-mono.lo
sgen-mono.c: In function ‘get_array_fill_vtable’:
sgen-mono.c:64:32: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 #define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
                                ^
sgen-mono.c:365:38: note: in expansion of macro ‘ALIGN_TO’
   MonoVTable* vtable = (MonoVTable*) ALIGN_TO(_vtable, 8);
                                      ^
sgen-mono.c: In function ‘mono_gc_get_managed_allocator_by_type’:
sgen-mono.c:1299:30: warning: ‘max_size_branch’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   mono_mb_patch_short_branch (mb, max_size_branch);
                              ^
sgen-mono.c:1051:27: note: ‘max_size_branch’ was declared here
  guint32 slowpath_branch, max_size_branch;
                           ^
  CCLD   libmonoruntimesgen-static.la
  CC     pedump.o
  CCLD   pedump
./.libs/libmonoruntime.a(libmonoruntime_la-threads.o): In function `InterlockedIncrement64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:290: undefined reference to `__sync_add_and_fetch_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threads.o): In function `InterlockedDecrement64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:295: undefined reference to `__sync_sub_and_fetch_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threads.o): In function `InterlockedCompareExchange64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threads.o): In function `InterlockedAdd64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:285: undefined reference to `__sync_add_and_fetch_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threads.o): In function `InterlockedRead64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threads.o): In function `InterlockedCompareExchange64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedCompareExchange64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedRead64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedCompareExchange64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedRead64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedCompareExchange64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedRead64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedCompareExchange64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedRead64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedCompareExchange64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedRead64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedCompareExchange64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedRead64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedCompareExchange64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:280: undefined reference to `__sync_val_compare_and_swap_8'
./.libs/libmonoruntime.a(libmonoruntime_la-threadpool-ms.o): In function `InterlockedRead64':
/tmp/build/mono-mono-4.2.1.36/mono/metadata/../../mono/utils/atomic.h:306: undefined reference to `__sync_fetch_and_add_8'
collect2: error: ld returned 1 exit status
make[3]: *** [pedump] Error 1
make[3]: Leaving directory `/tmp/build/mono-mono-4.2.1.36/mono/metadata'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/tmp/build/mono-mono-4.2.1.36/mono'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/build/mono-mono-4.2.1.36'
make: *** [all] Error 2

I am using gcc-4.8.2 on Slackware 14.1.
Any idea how to solve this problem?

Thank you.
Best regards.
Comment 1 yugiohjcj 2016-01-26 04:55:03 UTC
OK I found two ways to solve this problem:

1) You can keep your gcc compiler and use the "-march=i686" option while building mono:
$ export CFLAGS="-march=i686"
$ ./configure --prefix=/usr
$ make

2) You can rebuild your gcc compiler for the i686 architecture (tested with gcc-4.9.1).

In fact, on Slackware 14.1, the provided gcc-4.8.2 compiler is compiled for i486 architecture instead of i686.
It seems to be the reason why we need to use one of the two solutions above.