Compiling SDL-1.2.12 with CFLAGS="-mcpu=G4" fails

i tried compiling sdl 1.2.12 with gcc version 4.0.1 (Apple Inc. build
5465)

CFLAGS="-mcpu=G4" ./configure && make

and it fails with this :----------------------
/bin/sh ./libtool --mode=compile gcc -mcpu=G4 -I./include -
D_GNU_SOURCE=1 -DTARGET_API_MAC_CARBON -DTARGET_API_MAC_OSX -
fvisibility=hidden -I/usr/X11R6/include -DXTHREADS -D_THREAD_SAFE -
maltivec -force_cpusubtype_ALL -fpascal-strings -c ./src/audio/macosx/
SDL_coreaudio.c -o build/SDL_coreaudio.lo
gcc -mcpu=G4 -I./include -D_GNU_SOURCE=1 -DTARGET_API_MAC_CARBON -
DTARGET_API_MAC_OSX -fvisibility=hidden -I/usr/X11R6/include -
DXTHREADS -D_THREAD_SAFE -maltivec -force_cpusubtype_ALL -fpascal-
strings -c ./src/audio/macosx/SDL_coreaudio.c -fno-common -DPIC -o
build/.libs/SDL_coreaudio.o
In file included from /System/Library/Frameworks/
CoreServices.framework/Frameworks/CarbonCore.framework/Headers/
DriverServices.h:32,
from /System/Library/Frameworks/
CoreServices.framework/Frameworks/CarbonCore.framework/Headers/
CarbonCore.h:125,
from /System/Library/Frameworks/
CoreServices.framework/Headers/CoreServices.h:21,
from /System/Library/Frameworks/AudioUnit.framework/
Headers/AUComponent.h:21,
from /System/Library/Frameworks/AudioUnit.framework/
Headers/AudioUnit.h:22,
from ./src/audio/macosx/SDL_coreaudio.c:24:
/System/Library/Frameworks/CoreServices.framework/Frameworks/
CarbonCore.framework/Headers/MachineExceptions.h:115: error: syntax
error before ‘vector’
/System/Library/Frameworks/CoreServices.framework/Frameworks/
CarbonCore.framework/Headers/MachineExceptions.h:120: error: syntax
error before ‘}’ token
/System/Library/Frameworks/CoreServices.framework/Frameworks/
CarbonCore.framework/Headers/MachineExceptions.h:123: error: array
type has incomplete element type
/System/Library/Frameworks/CoreServices.framework/Frameworks/
CarbonCore.framework/Headers/MachineExceptions.h:124: error: field
’VSCR’ has incomplete type
make: *** [build/SDL_coreaudio.lo] Error 1

i have tried without the cflags and with --enable-altivec and it
compiles.

then i tried on an older version of gcc, gcc version 4.0.1 (Apple
Computer, Inc. build 5370) and it compiled fine

could anyone offer a suggestion to what changed?

thanks

matt

CFLAGS="-mcpu=G4" ./configure && make

Can you try CFLAGS="-faltivec -mcpu=G4" ?

–ryan.

it compiles. i was asking a few other people and they said its a gcc
problem. do you know anything more on that ?

thanks

mattOn Nov 17, 2007, at 10:46 PM, Ryan C. Gordon wrote:

CFLAGS="-faltivec -mcpu=G4"

matt hull wrote:

it compiles. i was asking a few other people and they said its a gcc
problem. do you know anything more on that ?

It’s not a bug, really.

It’s trying to use an altivec extension in one of the headers. It sees
an #ifdef that suggests the target CPU definitely has Altivec support,
and then includes some Altivec functionality.

The problem is GCC doesn’t understand the Altivec extension keywords and
assumes it’s a syntax error, if you don’t use -faltivec. It can’t turn
this option on by default with -mcpu=G4, because words like "vector"
might be used in your legitimate C program that have nothing to do with
Altivec.

So in this case, if you use one flag, use the other, too.

–ryan.