Generating a gcc on x86 to handle atomic gracefuly

SDL recently added atomic functions.

I’ve been building gcc’s for 20 years and suddenly I can’t
seemlessly handle this (though my ubuntu native compilers can)
without -march=native

I tried to configure my gcc as similar to the ubuntu gcc’s – but
The program looks like this:

I wasn’t able to find anything on the web to deal with this (except a hint
in libg++ to use -march=native

: leisner at gateway 03:09:59;nl foo.c
1 int i = 0;

 2  int SDL_AtomicIncrementThenFetch32(volatile int * ptr)
 3  {
 4     return __sync_add_and_fetch(ptr, 1);
 5  }
 6  main()
 7  {

 8          SDL_AtomicIncrementThenFetch32(&i);
 9          return i;
10  }

%gcc foo.c -o foo
/tmp/cc2mf0HU.o: In function SDL_AtomicIncrementThenFetch32': foo.c:(.text+0xf): undefined reference to__sync_add_and_fetch_4’
collect2: ld returned 1 exit status
%/usr/bin/gcc foo.c -o foo
%

I built gcc a number of times with different gyrations of configuration without
being able to do away with -march=native (I also upgrade my gcc, I was using
4.4.1, I went to 4.4.3)

Here’s my gcc -v:
%gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: /usr/local/src/gnu/gcc-4.4.3/configure --prefix=/usr/gnu/gcc-4.4.3 --enable-languages=c,c++ --enable-threads=posix --disable-nls --enable-mpfr --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (GCC)
%/usr/bin/gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: …/src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)

Try --target=i586-linux-gnu

Andrew.On 02/14/2010 08:27 PM, Marty Leisner wrote:

SDL recently added atomic functions.

I’ve been building gcc’s for 20 years and suddenly I can’t
seemlessly handle this (though my ubuntu native compilers can)
without -march=native