Opened 6 years ago

Last modified 7 months ago

#4542 closed defect

undefined reference to `__sync_sub_and_fetch_4'

Reported by: andrewziem Owned by: vaclavslavik
Priority: normal Milestone:
Component: build Version:
Keywords: Cc: andrewziem, vaclavslavik
Blocked By: Blocking:
Patch: no

Description

Building 2007-12-04 SVN on Fedora 7 i686 with GCC 4.1.2, I get a build error in the tests directory:

g++ -o test test_test.o test_archivetest.o test_ziptest.o test_tartest.o test_arrays.o test_base64.o test_fileconf.o test_datetimetest.o test_filekind.o test_filenametest.o test_filesystest.o test_fontmaptest.o test_formatconvertertest.o test_hashes.o test_intltest.o test_lists.o test_longlongtest.o test_convautotest.o test_mbconvtest.o test_regextest.o test_wxregextest.o test_scopeguardtest.o test_iostream.o test_strings.o test_stdstrings.o test_tokenizer.o test_unichar.o test_unicode.o test_vararg.o test_crt.o test_vsnprintf.o test_bstream.o test_datastreamtest.o test_ffilestream.o test_fileback.o test_filestream.o test_largefile.o test_memstream.o test_sstream.o test_tempfile.o test_textstreamtest.o test_zlibstream.o test_textfiletest.o test_atomic.o test_queue.o test_uris.o test_vectors.o -pthread -L/home/z/tmp/wxWidgets/lib -Wl,-rpath,/home/z/tmp/wxWidgets/lib -lcppunit -ldl -lz -ldl -lm -lwx_baseu_net-2.9 -lwx_baseu-2.9 -lwxregexu-2.9 -lwxexpat-2.9 -pthread -Wl,--version-script,/home/z/tmp/wxWidgets/version-script -lz -ldl -lm
test_atomic.o: In function `AtomicTestCase::MyThread::Entry()':
atomic.cpp:(.text+0x51): undefined reference to `sync_sub_and_fetch_4'
atomic.cpp:(.text+0x9f): undefined reference to `
sync_sub_and_fetch_4'
test_atomic.o: In function `AtomicTestCase::TestNoThread()':
atomic.cpp:(.text+0xad5): undefined reference to `sync_sub_and_fetch_4'
test_atomic.o: In function `AtomicTestCase::TestDecReturn()':
atomic.cpp:(.text+0x170e): undefined reference to `
sync_sub_and_fetch_4'
atomic.cpp:(.text+0x187d): undefined reference to `sync_sub_and_fetch_4'
collect2: ld returned 1 exit status

Attachments (1)

config.log download (144.7 KB) - added by andrewziem 6 years ago.
config.log latest svn 2007-12-04

Download all attachments as: .zip

Change History (5)

comment:1 Changed 6 years ago by vaclavslavik

Interesting... This is gcc's builtin function and 4.1.2 certainly does have it. Could it be a bug in GCC related to compiler flags (see http://www.usenetarticles.com/thread/953850.html)?

I changed configure test to try linking the app too, so it should correctly detect that the builtins don't work on your system, but that means that an inefficient version of this code will be used, it would be nice to understand what's wrong...

Changed 6 years ago by andrewziem

config.log latest svn 2007-12-04

comment:2 Changed 6 years ago by andrewziem

Sorry, I still get the same error. To be sure, I "rm -rf wxWidgets", retrieved code from SVN trunk, and "./configure --enable debug;make".

Please note I do have sync_sub_and_fetch but not sync_sub_and_fetch_4. I am not sure where _4 comes from. Is it the difference between int and wxUint32?

I will attach config.log if that helps.
File Added: config.log

comment:3 Changed 6 years ago by vaclavslavik

*Really* fixed now. Apparently, this is gcc's normal behavior if the required primitives aren't supported by the architecture (as is the case with i686, unlike x86_64):

Not all operations are supported by all target processors. If a

particular operation cannot be implemented on the target processor, a
warning will be generated and a call an external function will be
generated. The external function will carry the same name as the
builtin, with an additional suffix `_N' where N is the size of the data
type.

Our configure test didn't fail, because it didn't use sync_sub_and_fetch return value -- and because int32_t memory access is always atomic on i686, the compiler correctly determined this use is supported by target architecture -- but wx uses the return value and that's not supported.

comment:4 Changed 7 months ago by VZ

(In [74934]) Work around g++ atomic builtins detection in configure when -Os is used.

Assigning sync_sub_and_fetch() result to an unused variable can result in it
being optimized away and the function support is then not really tested for,
see #4542. So do make sure this variable is kept by making it volatile.

Closes #15555.

Note: See TracTickets for help on using tickets.