Linux build RHEL 5.3 link error

[atom@rhel-devel Linux]$ make
Linking The Jucer
build/intermediate/Debug/JuceLibraryCode1.o: In function `juce::Atomic::decrementAndReturn(int&)':
/home/atom/devel/juce/extras/Jucer (experimental)/Builds/Linux/../../JuceLibraryCode/../../../amalgamation/../src/core/juce_Atomic.h:109: undefined reference to `__sync_add_and_fetch_4'
build/intermediate/Debug/JuceLibraryCode1.o: In function `juce::Atomic::incrementAndReturn(int&)':
/home/atom/devel/juce/extras/Jucer (experimental)/Builds/Linux/../../JuceLibraryCode/../../../amalgamation/../src/core/juce_Atomic.h:107: undefined reference to `__sync_add_and_fetch_4'
build/intermediate/Debug/JuceLibraryCode1.o: In function `juce::Atomic::swapPointers(void* volatile*, void*)':
/home/atom/devel/juce/extras/Jucer (experimental)/Builds/Linux/../../JuceLibraryCode/../../../amalgamation/../src/core/juce_Atomic.h:116: undefined reference to `__sync_bool_compare_and_swap_4'
build/intermediate/Debug/JuceLibraryCode2.o: In function `juce::Atomic::compareAndExchange(int&, int, int)':
/home/atom/devel/juce/extras/Jucer (experimental)/Builds/Linux/../../JuceLibraryCode/../../../amalgamation/../src/containers/../core/juce_Atomic.h:111: undefined reference to `__sync_val_compare_and_swap_4'
collect2: ld returned 1 exit status
make: *** [build/Jucer] Error 1


[atom@rhel-devel Linux]$ gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj- --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)

Are the sync_add_etc functions only in gcc4.2…?

i had to add -march=i686 to build it (-march=native caused some other errors so i removed it, but a minimum of i486 has to be set cause that’s when those atomic calls appeared).

Well, I can’t really hard-code it for i686… What were the errors you got with arch=native?

[atom@rhel-devel Linux]$ make
../../Source/model/jucer_ComponentDocument.cpp:1: error: bad value (native) for -march= switch
../../Source/model/jucer_ComponentDocument.cpp:1: error: bad value (native) for -mtune= switch
make: *** [build/intermediate/Debug/jucer_ComponentDocument.o] Error 1

i486 is enough, and it would be safe to add i486 cause i can’t think of a cpu that runs linux/juce and is not i486 compatible.

I didn’t mean that i686 was too recent, I meant that people could be using ppc or other non-x86 architectures. I don’t understand why you’d get that error though… Any gcc experts know why it’d object to arch=native?

well gcc 4.1 does not have the “native” switch it appeared in 4.2

Ah, I see…

Well i think you solved this in some very bad way.

#error "Linux build requires gcc4.2 or later for atomic operations"

that’s not true, you can use any gcc4 but you need to pass a different switch to gcc cli, you just removed support for a lot of distros and versions on linux.

Really? I didn’t know that… What’s the switch?

well any switch that will work with -march option, native does not work in gcc < 4.2 but -march=i486 works and JUCE builds just fine (i’m building it). Maybe you could add a architecture combo for projects?

Ok, I guess I should remove that warning and make it try to use the intrinsics in GCC without checking the version.

It works fine if you just don't use any -march. GCC is version 4.1.2. I think it would be fine to use the GCC version and if less than 4.2, just set TARGET_ARCH="" in the Makefile.