Using crosstool (http://kegel.com/crosstool/) scripts i've built under
Cygwin(http://www.cygwin.com/) the following compilers gcc-4.1.1 and
4.2.0 20061024 (prerelease) for Sparc V8 architecture:
1 | $ ./sparc-unknown-linux-gnu-gcc -v
|
2 | Using built-in specs.
|
3 | Target: sparc-unknown-linux-gnu
|
4 | Configured with: /crosstool-0.43/build/sparc-unknown-linux-gnu/gcc-4.1.1-glibc-2.3.6/gcc-4.1.1/configure --target=sparc-unknown-linux-gnu --host=i686-host_pc-cygwin --prefix=/opt/crosstool/gcc-4.1.1-glibc-2.3.6/sparc-unknown-linux-gnu --with-headers=/opt/crosstool/gcc-4.1.1-glibc-2.3.6/sparc-unknown-linux-gnu/sparc-unknown-linux-gnu/include --with-local-prefix=/opt/crosstool/gcc-4.1.1-glibc-2.3.6/sparc-unknown-linux-gnu/sparc-unknown-linux-gnu --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
|
5 | Thread model: posix
|
6 | gcc version 4.1.1
|
and
1 | $ ./sparc-unknown-linux-gnu-gcc -v
|
2 | Using built-in specs.
|
3 | Target: sparc-unknown-linux-gnu
|
4 | Configured with: /crosstool-0.43/build/sparc-unknown-linux-gnu/gcc-4.2-20061024- glibc-2.3.6/gcc-4.2-20061024/configure --target=sparc-unknown-linux-gnu --host=i 686-host_pc-cygwin --prefix=/opt/crosstool/gcc-4.2-20061024-glibc-2.3.6/sparc-un known-linux-gnu --with-headers=/opt/crosstool/gcc-4.2-20061024-glibc-2.3.6/sparc -unknown-linux-gnu/sparc-unknown-linux-gnu/include --with-local-prefix=/opt/cros stool/gcc-4.2-20061024-glibc-2.3.6/sparc-unknown-linux-gnu/sparc-unknown-linux-g nu --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atex it --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
|
5 | Thread model: posix
|
6 | gcc version 4.2.0 20061024 (prerelease)
|
7 | It is necessary for me that i can use in my programs __sync_val_compare_and_swap function related to the Atomic-Builtins, which supports whith 4.1.* version of gcc.
|
1 | I try to compile simple C code:
|
2 |
|
3 | long cmpxchg( long* value, long comp_val, long new_val )
|
4 | {
|
5 | return __sync_val_compare_and_swap( value, comp_val, new_val );
|
6 | }
|
7 |
|
8 | int main()
|
9 | {
|
10 | return 0;
|
11 | }
|
But i have the following error: (on both compilers):
1 | $ ./sparc-unknown-linux-gnu-gcc test_cas.c -o test_cas
|
2 | /tmp/ccREXHsP.o: In function `cmpxchg':
|
3 | test_cas.c:(.text+0x24): undefined reference to `__sync_val_compare_and_swap_4'
|
4 | collect2: ld returned 1 exit status
|
I try to find __sync_val_compare_and_swap_4: $ nm -A *.so | grep
1 | __sync_val_compare_and_swap_4
|
2 | nm: libc.so: File format not recognized
|
3 | nm: libpthread.so: File format not recognized
|
I try to copile using __sync_val_compare_and_swap_4... But the same
error :(
What's the problem? May be i wrong built compilers? May be Sparc
architecture (SPARC v8) doesn't support this feature? I tried to compile
my another programs - all good (compiled and executed).