You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@etch.apache.org by "mscherer82@gmail.com" <ms...@gmail.com> on 2014/09/10 14:07:13 UTC

undefined reference to `__sync_fetch_and_add_4'

Hello,

I've build libcapu and libetch for QNX armv7 but when I tried to compile
the hello world cpp sample, I got a linker error:

libcapu.a(ThreadPool.o): In function
`capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()':
ThreadPool.cpp:(.text._ZN4capu12SmartPointerINS_10ThreadPool10PoolWorkerEE11decRefCountEv[capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()]+0x18):
undefined reference to `__sync_fetch_and_sub_4'

The compiler flags I used were: -march=armv7-a -mfpu=vfpv3-d16
-mfloat-abi=softfp

Any suggestions?

Thanks and Regards,
Marc

RE: undefined reference to `__sync_fetch_and_add_4'

Posted by Martin Veith <Ma...@bmw-carit.de>.
Hi Marc,

According to the gcc docs for version 4.4.2 these atomic operations should be supported:
https://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Atomic-Builtins.html

On the ARM documentation these functions are also supported:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491e/BABICCBA.html

As I don’t have the toolchain, I cannot really help here…

Martin

From: mscherer82@gmail.com [mailto:mscherer82@gmail.com]
Sent: Donnerstag, 11. September 2014 17:04
To: user@etch.apache.org
Subject: Re: undefined reference to `__sync_fetch_and_add_4'

Thank you very much for helping. In the stdatomic.c<http://svnweb.freebsd.org/base/head/sys/arm/arm/stdatomic.c?view=markup&pathrev=255092> there is a swtich which broad my compiler to this line:
/* These systems should be supported by the compiler. */
I also think the operations should be supported. My compiler version is:

Target: arm-unknown-nto-qnx6.5.0eabi
Configured with: ../configure --srcdir=.. --build=i686-pc-linux-gnu --enable-cheaders=c --with-as=ntoarm-as --with-ld=ntoarm-ld
--with-sysroot=/opt/qnx650/target/qnx6/
--disable-werror --libdir=/opt/qnx650/host/linux/x86/usr/lib
--libexecdir=/opt/qnx650/host/linux/x86/usr/lib
--target=arm-unknown-nto-qnx6.5.0eabi
--prefix=/opt/qnx650/host/linux/x86/usr
--exec-prefix=/opt/qnx650/host/linux/x86/usr
--with-local-prefix=/opt/qnx650/host/linux/x86/usr
--enable-languages=c++ --enable-threads=posix --disable-nls --disable-libssp --disable-tls --disable-libstdcxx-pch --enable-libmudflap --enable-__cxa_atexit
--with-gxx-include-dir=/opt/qnx650/target/qnx6/usr/include/c++/4.4.2 --enable-multilib --with-bugurl=http://www.qnx.com
--enable-shared CC=i686-unknown-linux-gnu-gcc LDFLAGS='-Wl,-s ' AUTOMAKE=: AUTOCONF=: AUTOHEADER=: AUTORECONF=: ACLOCAL=:
Thread model: posix
gcc version 4.4.2 (GCC)
Regards,
Marc

On Thu, Sep 11, 2014 at 3:31 PM, Robert Comer <we...@mac.com>> wrote:
this might help:

http://lists.freebsd.org/pipermail/svn-src-head/2013-August/051146.html

On Sep 11, 2014, at 8:27 AM, Robert Comer <we...@mac.com>> wrote:


i found this:

http://www.orocos.org/forum/orocos/orocos-users/cross-compiling-error-undefined-reference-syncfetchandsub4

check the first response. that call (__sync_fetch_and_sub_4) is generated when the compiler doesn't have it built in. so you must code that
one yourself and include it in your project somewhere. you can use the asm directives to reference the necessary instructions. you will have to
consult the processor reference to know what those are.

math lib won't help i wouldn't think. that's usually sin, cos, etc.

(btw, i think that is a 32 bit fetch and subtract operation, but i don't know the signature of the method to know what it takes for a signature
or offers as a api / contract. that would help a lot. anyone else know? a stab:

int32_t __sync_fetch_and_sub_4(int32_t * i, int32_t n) {
// done atomically:
return (*i -= n);
}

but it could be fetch, subtract, store and then return the original, or fetch, subtract, store and then return the result.
either way, the fetching and storing are done atomically, which means no intervening memory read or write (bus is locked).

scott out


On Sep 11, 2014, at 7:49 AM, Martin Veith <Ma...@bmw-carit.de>> wrote:


Hi Marc,

I assume you are using gcc as a compiler. Which version of gcc do you use?
Some older gcc version do not support the build in atomic operations…

Another shot in the dark: Maybe it helps to link against the Math library: -lm

Cheers,
Martin

From: mscherer82@gmail.com<ma...@gmail.com> [mailto:mscherer82@gmail.com]
Sent: Mittwoch, 10. September 2014 14:07
To: user@etch.apache.org<ma...@etch.apache.org>
Subject: undefined reference to `__sync_fetch_and_add_4'

Hello,
I've build libcapu and libetch for QNX armv7 but when I tried to compile the hello world cpp sample, I got a linker error:

libcapu.a(ThreadPool.o): In function `capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()':
ThreadPool.cpp:(.text._ZN4capu12SmartPointerINS_10ThreadPool10PoolWorkerEE11decRefCountEv[capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()]+0x18): undefined reference to `__sync_fetch_and_sub_4'
The compiler flags I used were: -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp
Any suggestions?
Thanks and Regards,
Marc




Re: undefined reference to `__sync_fetch_and_add_4'

Posted by "mscherer82@gmail.com" <ms...@gmail.com>.
Thank you very much for helping. In the stdatomic.c
<http://svnweb.freebsd.org/base/head/sys/arm/arm/stdatomic.c?view=markup&pathrev=255092>
there is a swtich which broad my compiler to this line:
/* These systems should be supported by the compiler. */

I also think the operations should be supported. My compiler version is:

Target: arm-unknown-nto-qnx6.5.0eabi
Configured with: ../configure --srcdir=.. --build=i686-pc-linux-gnu
--enable-cheaders=c --with-as=ntoarm-as --with-ld=ntoarm-ld
--with-sysroot=/opt/qnx650/target/qnx6/
--disable-werror --libdir=/opt/qnx650/host/linux/x86/usr/lib
--libexecdir=/opt/qnx650/host/linux/x86/usr/lib
--target=arm-unknown-nto-qnx6.5.0eabi
--prefix=/opt/qnx650/host/linux/x86/usr
--exec-prefix=/opt/qnx650/host/linux/x86/usr
--with-local-prefix=/opt/qnx650/host/linux/x86/usr
--enable-languages=c++ --enable-threads=posix --disable-nls
--disable-libssp --disable-tls --disable-libstdcxx-pch --enable-libmudflap
--enable-__cxa_atexit
--with-gxx-include-dir=/opt/qnx650/target/qnx6/usr/include/c++/4.4.2
--enable-multilib --with-bugurl=http://www.qnx.com
--enable-shared CC=i686-unknown-linux-gnu-gcc LDFLAGS='-Wl,-s ' AUTOMAKE=:
AUTOCONF=: AUTOHEADER=: AUTORECONF=: ACLOCAL=:
Thread model: posix
gcc version 4.4.2 (GCC)

Regards,
Marc

On Thu, Sep 11, 2014 at 3:31 PM, Robert Comer <we...@mac.com> wrote:

> this might help:
>
> http://lists.freebsd.org/pipermail/svn-src-head/2013-August/051146.html
>
> On Sep 11, 2014, at 8:27 AM, Robert Comer <we...@mac.com> wrote:
>
> i found this:
>
>
> http://www.orocos.org/forum/orocos/orocos-users/cross-compiling-error-undefined-reference-syncfetchandsub4
>
> check the first response. that call (__sync_fetch_and_sub_4) is generated
> when the compiler doesn't have it built in. so you must code that
> one yourself and include it in your project somewhere. you can use the asm
> directives to reference the necessary instructions. you will have to
> consult the processor reference to know what those are.
>
> math lib won't help i wouldn't think. that's usually sin, cos, etc.
>
> (btw, i think that is a 32 bit fetch and subtract operation, but i don't
> know the signature of the method to know what it takes for a signature
> or offers as a api / contract. that would help a lot. anyone else know? a
> stab:
>
> int32_t __sync_fetch_and_sub_4(int32_t * i, int32_t n) {
> // done atomically:
> return (*i -= n);
> }
>
> but it could be fetch, subtract, store and then return the original, or
> fetch, subtract, store and then return the result.
> either way, the fetching and storing are done atomically, which means
> no intervening memory read or write (bus is locked).
>
> scott out
>
>
> On Sep 11, 2014, at 7:49 AM, Martin Veith <Ma...@bmw-carit.de>
> wrote:
>
> Hi Marc,
>
> I assume you are using gcc as a compiler. Which version of gcc do you use?
> Some older gcc version do not support the build in atomic operations…
>
> Another shot in the dark: Maybe it helps to link against the Math library:
> -lm
>
> Cheers,
> Martin
>
> *From:* mscherer82@gmail.com [mailto:mscherer82@gmail.com
> <ms...@gmail.com>]
> *Sent:* Mittwoch, 10. September 2014 14:07
> *To:* user@etch.apache.org
> *Subject:* undefined reference to `__sync_fetch_and_add_4'
>
>
> Hello,
>
> I've build libcapu and libetch for QNX armv7 but when I tried to compile
> the hello world cpp sample, I got a linker error:
>
> libcapu.a(ThreadPool.o): In function
> `capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()':
> ThreadPool.cpp:(.text._ZN4capu12SmartPointerINS_10ThreadPool10PoolWorkerEE11decRefCountEv[capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()]+0x18):
> undefined reference to `__sync_fetch_and_sub_4'
>
> The compiler flags I used were: -march=armv7-a -mfpu=vfpv3-d16
> -mfloat-abi=softfp
>
> Any suggestions?
> Thanks and Regards,
> Marc
>
>
>
>

Re: undefined reference to `__sync_fetch_and_add_4'

Posted by Robert Comer <we...@mac.com>.
this might help:

http://lists.freebsd.org/pipermail/svn-src-head/2013-August/051146.html

On Sep 11, 2014, at 8:27 AM, Robert Comer <we...@mac.com> wrote:

> i found this:
> 
> http://www.orocos.org/forum/orocos/orocos-users/cross-compiling-error-undefined-reference-syncfetchandsub4
> 
> check the first response. that call (__sync_fetch_and_sub_4) is generated when the compiler doesn't have it built in. so you must code that
> one yourself and include it in your project somewhere. you can use the asm directives to reference the necessary instructions. you will have to
> consult the processor reference to know what those are.
> 
> math lib won't help i wouldn't think. that's usually sin, cos, etc.
> 
> (btw, i think that is a 32 bit fetch and subtract operation, but i don't know the signature of the method to know what it takes for a signature
> or offers as a api / contract. that would help a lot. anyone else know? a stab:
> 
> int32_t __sync_fetch_and_sub_4(int32_t * i, int32_t n) {
> 	// done atomically:
> 	return (*i -= n);
> }
> 
> but it could be fetch, subtract, store and then return the original, or fetch, subtract, store and then return the result.
> either way, the fetching and storing are done atomically, which means no intervening memory read or write (bus is locked).
> 
> scott out
> 
> 
> On Sep 11, 2014, at 7:49 AM, Martin Veith <Ma...@bmw-carit.de> wrote:
> 
>> Hi Marc,
>>  
>> I assume you are using gcc as a compiler. Which version of gcc do you use?
>> Some older gcc version do not support the build in atomic operations…
>>  
>> Another shot in the dark: Maybe it helps to link against the Math library: -lm
>>  
>> Cheers,
>> Martin
>>  
>> From: mscherer82@gmail.com [mailto:mscherer82@gmail.com] 
>> Sent: Mittwoch, 10. September 2014 14:07
>> To: user@etch.apache.org
>> Subject: undefined reference to `__sync_fetch_and_add_4'
>>  
>> Hello,
>> 
>> I've build libcapu and libetch for QNX armv7 but when I tried to compile the hello world cpp sample, I got a linker error:
>> 
>> libcapu.a(ThreadPool.o): In function `capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()':
>> ThreadPool.cpp:(.text._ZN4capu12SmartPointerINS_10ThreadPool10PoolWorkerEE11decRefCountEv[capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()]+0x18): undefined reference to `__sync_fetch_and_sub_4'
>> 
>> The compiler flags I used were: -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp
>> 
>> Any suggestions?
>> 
>> Thanks and Regards,
>> Marc
> 


Re: undefined reference to `__sync_fetch_and_add_4'

Posted by Robert Comer <we...@mac.com>.
i found this:

http://www.orocos.org/forum/orocos/orocos-users/cross-compiling-error-undefined-reference-syncfetchandsub4

check the first response. that call (__sync_fetch_and_sub_4) is generated when the compiler doesn't have it built in. so you must code that
one yourself and include it in your project somewhere. you can use the asm directives to reference the necessary instructions. you will have to
consult the processor reference to know what those are.

math lib won't help i wouldn't think. that's usually sin, cos, etc.

(btw, i think that is a 32 bit fetch and subtract operation, but i don't know the signature of the method to know what it takes for a signature
or offers as a api / contract. that would help a lot. anyone else know? a stab:

int32_t __sync_fetch_and_sub_4(int32_t * i, int32_t n) {
	// done atomically:
	return (*i -= n);
}

but it could be fetch, subtract, store and then return the original, or fetch, subtract, store and then return the result.
either way, the fetching and storing are done atomically, which means no intervening memory read or write (bus is locked).

scott out


On Sep 11, 2014, at 7:49 AM, Martin Veith <Ma...@bmw-carit.de> wrote:

> Hi Marc,
>  
> I assume you are using gcc as a compiler. Which version of gcc do you use?
> Some older gcc version do not support the build in atomic operations…
>  
> Another shot in the dark: Maybe it helps to link against the Math library: -lm
>  
> Cheers,
> Martin
>  
> From: mscherer82@gmail.com [mailto:mscherer82@gmail.com] 
> Sent: Mittwoch, 10. September 2014 14:07
> To: user@etch.apache.org
> Subject: undefined reference to `__sync_fetch_and_add_4'
>  
> Hello,
> 
> I've build libcapu and libetch for QNX armv7 but when I tried to compile the hello world cpp sample, I got a linker error:
> 
> libcapu.a(ThreadPool.o): In function `capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()':
> ThreadPool.cpp:(.text._ZN4capu12SmartPointerINS_10ThreadPool10PoolWorkerEE11decRefCountEv[capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()]+0x18): undefined reference to `__sync_fetch_and_sub_4'
> 
> The compiler flags I used were: -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp
> 
> Any suggestions?
> 
> Thanks and Regards,
> Marc


RE: undefined reference to `__sync_fetch_and_add_4'

Posted by Martin Veith <Ma...@bmw-carit.de>.
Hi Marc,

I assume you are using gcc as a compiler. Which version of gcc do you use?
Some older gcc version do not support the build in atomic operations…

Another shot in the dark: Maybe it helps to link against the Math library: -lm

Cheers,
Martin

From: mscherer82@gmail.com [mailto:mscherer82@gmail.com]
Sent: Mittwoch, 10. September 2014 14:07
To: user@etch.apache.org
Subject: undefined reference to `__sync_fetch_and_add_4'

Hello,
I've build libcapu and libetch for QNX armv7 but when I tried to compile the hello world cpp sample, I got a linker error:

libcapu.a(ThreadPool.o): In function `capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()':
ThreadPool.cpp:(.text._ZN4capu12SmartPointerINS_10ThreadPool10PoolWorkerEE11decRefCountEv[capu::SmartPointer<capu::ThreadPool::PoolWorker>::decRefCount()]+0x18): undefined reference to `__sync_fetch_and_sub_4'
The compiler flags I used were: -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp
Any suggestions?
Thanks and Regards,
Marc