SDL 1.2.6 (and CVS) compile problems with GCC 3.3.1

Hi.

I am trying to compile SDL 1.2.6 (or SDL CVS) version with GCC 3.3.1 and
this does not work well. The following verion of GCC and NASM are present
on my system:

gcc version 3.3.1 20030814 (Red Hat Linux 3.3.1-2)
NASM version 0.98.35 compiled on Jul 29 2003

I did a ./configure --disable-debug --enable-nasm and the make on SDL 1.2.6
and GCC then produces this error:

gcc -DPACKAGE=“SDL” -DVERSION=“1.2.6” -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1
-I. -I. -march=c3 -mmmx -m3dnow -Os -falign-loops=0 -falign-functions=0
-falign-jumps=0 -fomit-frame-pointer -fexpensive-optimizations -march=pentium
-mcpu=pentiumpro -Wall -DENABLE_DUMMYVIDEO -DDISKAUD_SUPPORT -DUSE_DLOPEN
-DUSE_ASMBLIT -I./hermes -I…/…/src/hermes -DOSS_SUPPORT -DALSA_SUPPORT
-I/usr/X11R6/include -DENABLE_X11 -DXTHREADS -I./include -I./src/video
-DXFREE86_VM -DXFREE86_VMGAMMA -DXFREE86_DGAMOUSE -DDEFAULT_DGAMOUSE
-DXFREE86_XV -DHAVE_XINERAMA -Isrc/video -DENABLE_DGA -DENABLE_FBCON
-DHAVE_OPENGL -DUSE_INPUT_EVENTS -D_REENTRANT -DSDL_USE_PTHREADS
-DPTHREAD_NO_RECURSIVE_MUTEX -I…/…/include -I…/…/include/SDL -I…/…/src
-I…/…/src/linux -I…/…/src/main -I…/…/src/audio -I…/…/src/video
-I…/…/src/video/XFree86/extensions -I…/…/src/events -I…/…/src/joystick
-I…/…/src/cdrom -I…/…/src/thread -I…/…/src/timer -I…/…/src/endian
-I…/…/src/file -c SDL_RLEaccel.c -fPIC -DPIC -o .libs/SDL_RLEaccel.lo
SDL_RLEaccel.c: In function RLEClipBlit': SDL_RLEaccel.c:845: error: invalidasm’: invalid expression as operand
SDL_RLEaccel.c:845: error: invalid asm': invalid expression as operand SDL_RLEaccel.c:845: error: invalidasm’: invalid expression as operand

(There is also another unrelated “problem” here and that is that the configure
script totally ignores my CFLAGS and gladly adds -march=pentium
-mcpu=pentiumpro)

I have tracked this down to problems in the src/video/mmx.h file and the
constraints used when building the inline assembly. The file uses
"X" and “=X” for constraints but, according to the GCC manual this should
be one of the following when using MMX / SSE registers:
x xmm SSE register
y MMX register

See here
http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Machine-Constraints.html#Machine%20Constraints

and here for a bug-report on a similar issue:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7267

I am not that fluent in AT&T syntax and inline assembly GCC style to fix this.
I did try to replace a few of the =X with =y and it reduced the number of
errors down to one.

Is there any way I can force gcc to pinpoint exactly where on a line it goes
wrong? The problem is that the macros used expand to a single very long line
and gcc does not provide enough information for me to find which part of
the line that holds the error.

Thanks in advance.–
John Eckerdal

John Eckerdal wrote:

Hi.

Hi,

I am trying to compile SDL 1.2.6 (or SDL CVS) version with GCC 3.3.1 and
this does not work well. The following verion of GCC and NASM are present
on my system:

gcc version 3.3.1 20030814 (Red Hat Linux 3.3.1-2)
NASM version 0.98.35 compiled on Jul 29 2003

I did a ./configure --disable-debug --enable-nasm and the make on SDL 1.2.6
and GCC then produces this error:

gcc -DPACKAGE=“SDL” -DVERSION=“1.2.6” -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1
-I. -I. -march=c3 -mmmx -m3dnow -Os -falign-loops=0 -falign-functions=0
-falign-jumps=0 -fomit-frame-pointer -fexpensive-optimizations -march=pentium
-mcpu=pentiumpro -Wall -DENABLE_DUMMYVIDEO -DDISKAUD_SUPPORT -DUSE_DLOPEN
-DUSE_ASMBLIT -I./hermes -I…/…/src/hermes -DOSS_SUPPORT -DALSA_SUPPORT
-I/usr/X11R6/include -DENABLE_X11 -DXTHREADS -I./include -I./src/video
-DXFREE86_VM -DXFREE86_VMGAMMA -DXFREE86_DGAMOUSE -DDEFAULT_DGAMOUSE
-DXFREE86_XV -DHAVE_XINERAMA -Isrc/video -DENABLE_DGA -DENABLE_FBCON
-DHAVE_OPENGL -DUSE_INPUT_EVENTS -D_REENTRANT -DSDL_USE_PTHREADS
-DPTHREAD_NO_RECURSIVE_MUTEX -I…/…/include -I…/…/include/SDL -I…/…/src
-I…/…/src/linux -I…/…/src/main -I…/…/src/audio -I…/…/src/video
-I…/…/src/video/XFree86/extensions -I…/…/src/events -I…/…/src/joystick
-I…/…/src/cdrom -I…/…/src/thread -I…/…/src/timer -I…/…/src/endian
-I…/…/src/file -c SDL_RLEaccel.c -fPIC -DPIC -o .libs/SDL_RLEaccel.lo
SDL_RLEaccel.c: In function RLEClipBlit': SDL_RLEaccel.c:845: error: invalidasm’: invalid expression as operand
SDL_RLEaccel.c:845: error: invalid asm': invalid expression as operand SDL_RLEaccel.c:845: error: invalidasm’: invalid expression as operand

I just installed gcc 3.3.1 to see, and I don’t have this problem.

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/specs
Configured with: …/configure --prefix=/usr --libdir=/usr/lib
–with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info
–enable-shared --enable-threads=posix --disable-checking
–enable-long-long --enable-__cxa_atexit
–enable-languages=c,c++,ada,f77,objc,java,pascal
–host=i586-mandrake-linux-gnu --with-system-zlib
Thread model: posix
gcc version 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk)

(There is also another unrelated “problem” here and that is that the configure
script totally ignores my CFLAGS and gladly adds -march=pentium
-mcpu=pentiumpro)

It works for me, I do the following :
$ CFLAGS=“some nice flags” ./configure
$ make
Not using --disable-debug enables debugging info, but it’s stripped at
install anyway.

I have tracked this down to problems in the src/video/mmx.h file and the
constraints used when building the inline assembly. The file uses
"X" and “=X” for constraints but, according to the GCC manual this should
be one of the following when using MMX / SSE registers:
x xmm SSE register
y MMX register

See here
http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Machine-Constraints.html#Machine%20Constraints

and here for a bug-report on a similar issue:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7267

I am not that fluent in AT&T syntax and inline assembly GCC style to fix this.
I did try to replace a few of the =X with =y and it reduced the number of
errors down to one.

Is there any way I can force gcc to pinpoint exactly where on a line it goes
wrong? The problem is that the macros used expand to a single very long line
and gcc does not provide enough information for me to find which part of
the line that holds the error.

I usually use gcc -E to get the preprocessor output, then I mess with it
to find the problem. If you want, you can send me the preprocessor
result and I’ll take a look at it.

Stephane

John Eckerdal wrote:

See here
http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Machine-Constraints.html#Machine%20Constraints

Btw, this is in contradiction with this page :
http://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html
where it is stated X means || “Any operand whatsoever is allowed.”

Stephane

John Eckerdal wrote:

-I…/…/src/file -c SDL_RLEaccel.c -fPIC -DPIC -o .libs/SDL_RLEaccel.lo
SDL_RLEaccel.c: In function RLEClipBlit': SDL_RLEaccel.c:845: error: invalidasm’: invalid expression as operand
SDL_RLEaccel.c:845: error: invalid asm': invalid expression as operand SDL_RLEaccel.c:845: error: invalidasm’: invalid expression as operand

I just installed gcc 3.3.1 to see, and I don’t have this problem.

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/specs
Configured with: …/configure --prefix=/usr --libdir=/usr/lib
–with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info
–enable-shared --enable-threads=posix --disable-checking
–enable-long-long --enable-__cxa_atexit
–enable-languages=c,c++,ada,f77,objc,java,pascal
–host=i586-mandrake-linux-gnu --with-system-zlib
Thread model: posix
gcc version 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk)

I did some investigating… I started with a “clean” SDL build, no CFLAGS
added at all. The I gradually added -mmmx -march=c3 (and removed the other
arch definitions) and -O2 / -Os

default:
options: -fexpensive-optimizations -march=pentium -mcpu=pentiumpro no errors

Notice that the configure script does not include -O2 or -Os here. This is
what CFLAGS= ./configure --disable-debug --enable-nasm generated.

variations:
options: -march=c3 -fexpensive-optimizations gives no errors
options: -march=c3 -mmmx -fexpensive-optimizations gives no errors
options: -march=c3 -mmmx -O2 -fexpensive-optimizations gives two errors.
options: -march=c3 -O2 -fexpensive-optimizations gives two errors.
options: -march=c3 -Os -fexpensive-optimizations gives three errors.
options: -Os -fexpensive-optimizations gives three errors.

The errors are the same on the same line as above.

(There is also another unrelated “problem” here and that is that the configure
script totally ignores my CFLAGS and gladly adds -march=pentium
-mcpu=pentiumpro)

It works for me, I do the following :
$ CFLAGS=“some nice flags” ./configure
$ make

Well, I checked the configure script and it identifies my VIA C3
(Ezra-T core) as a Pentium Pro class computer which is false since the
Ezra core does not implement conditional moves. The problem is that
if the architecture match it will allways add a -march -mcpu which does
not work for my CPU.On Mon, 1 Sep 2003, Stephane Marchesin wrote:


John Eckerdal the Assembly Gems page
http://www.df.lth.se/~john_e

John Eckerdal wrote:

I did some investigating… I started with a “clean” SDL build, no CFLAGS
added at all. The I gradually added -mmmx -march=c3 (and removed the other
arch definitions) and -O2 / -Os

default:
options: -fexpensive-optimizations -march=pentium -mcpu=pentiumpro no errors

Notice that the configure script does not include -O2 or -Os here. This is
what CFLAGS= ./configure --disable-debug --enable-nasm generated.

variations:
options: -march=c3 -fexpensive-optimizations gives no errors
options: -march=c3 -mmmx -fexpensive-optimizations gives no errors
options: -march=c3 -mmmx -O2 -fexpensive-optimizations gives two errors.
options: -march=c3 -O2 -fexpensive-optimizations gives two errors.
options: -march=c3 -Os -fexpensive-optimizations gives three errors.
options: -Os -fexpensive-optimizations gives three errors.

I tried them all, none of these options give me an error !
I have some warnings int SDL_blit_A.c, though. The attached patch
"longlongfix.patch" fixes those.

I’ve also taken a look at the mmx.h file. As I can’t reproduce the bug,
I can only guess, but my guess is the constraintfix.patch file.
Please, apply both and tell me if it works.

The errors are the same on the same line as above.

(There is also another unrelated “problem” here and that is that the configure
script totally ignores my CFLAGS and gladly adds -march=pentium
-mcpu=pentiumpro)

It works for me, I do the following :
$ CFLAGS=“some nice flags” ./configure
$ make

Well, I checked the configure script and it identifies my VIA C3
(Ezra-T core) as a Pentium Pro class computer which is false since the
Ezra core does not implement conditional moves. The problem is that
if the architecture match it will allways add a -march -mcpu which does
not work for my CPU.

Yes, but my point was that if you don’t use --disable-debug, neither
-march nor -mcpu will be set, so that you can set yours in the CFLAGS.
Of course, your library will contain debug symbols, but they are removed
at install (or using strip).

Stephane

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: longlongfix.patch
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030901/d4190c98/attachment.asc
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: constraintfix.patch
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030901/d4190c98/attachment.txt>On Mon, 1 Sep 2003, Stephane Marchesin wrote:

Hi,

SDL_RLEaccel.c:845: error: invalid `asm’: invalid expression as operand

I have also reproduced the same error. When I removed "-fomit-frame-pointer"
from CFLAGS it went well. As I experienced causes several problems around SDL.
For example, it causes crash while using YUV overlay (SDL-1.2.5 or former with
gcc-2.95).

Kentaro

I tried them all, none of these options give me an error !
I have some warnings int SDL_blit_A.c, though. The attached patch
"longlongfix.patch" fixes those.

I’ve also taken a look at the mmx.h file. As I can’t reproduce the bug,
I can only guess, but my guess is the constraintfix.patch file.
Please, apply both and tell me if it works.

Yep, that makes it compile.

Yes, but my point was that if you don’t use --disable-debug, neither
-march nor -mcpu will be set, so that you can set yours in the CFLAGS.
Of course, your library will contain debug symbols, but they are removed
at install (or using strip).

Is that the only thing that will happen?
Some configure scripts will also add a -DDEBUG flag so that a lot of debug
code is compiled in.On Tue, 2 Sep 2003, Stephane Marchesin wrote:


John Eckerdal the Assembly Gems page
http://www.df.lth.se/~john_e

Kentaro Fukuchi wrote:

Hi,

Hi,

SDL_RLEaccel.c:845: error: invalid `asm’: invalid expression as operand

I have also reproduced the same error.

Do the two patchs solve this problem for you ?

When I removed "-fomit-frame-pointer"
from CFLAGS it went well. As I experienced causes several problems around SDL.
For example, it causes crash while using YUV overlay (SDL-1.2.5 or former with
gcc-2.95).

According to configure.in, this is a known problem :
[configure.in, line 83]
# Ack! This breaks the MMX YV12 conversion on gcc 2.95.2
# CFLAGS="$CFLAGS -fomit-frame-pointer"

Stephane

John Eckerdal wrote:

I tried them all, none of these options give me an error !
I have some warnings int SDL_blit_A.c, though. The attached patch
"longlongfix.patch" fixes those.

I’ve also taken a look at the mmx.h file. As I can’t reproduce the bug,
I can only guess, but my guess is the constraintfix.patch file.
Please, apply both and tell me if it works.

Yep, that makes it compile.

Fine !

Is that the only thing that will happen?
Some configure scripts will also add a -DDEBUG flag so that a lot of debug
code is compiled in.

Not that I know of (at least, looking at the compilation output, there
doesn’t seem to be any debugging macro activated).

Stephane>On Tue, 2 Sep 2003, Stephane Marchesin wrote:

I have also reproduced the same error.

Do the two patchs solve this problem for you ?

Yessss!! Thank you very much!

When I removed "-fomit-frame-pointer"
from CFLAGS it went well. As I experienced causes several problems around SDL.
For example, it causes crash while using YUV overlay (SDL-1.2.5 or former with
gcc-2.95).

According to configure.in, this is a known problem :
[configure.in, line 83]
# Ack! This breaks the MMX YV12 conversion on gcc 2.95.2
# CFLAGS="$CFLAGS -fomit-frame-pointer"

This also disappeared already. Sorry for all.

KentaroFrom: stephane.marchesin@wanadoo.fr (Stephane Marchesin)
Subject: Re: [SDL] SDL 1.2.6 (and CVS) compile problems with GCC 3.3.1
Date: Tue, 02 Sep 2003 20:51:43 +0200