llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.41k stars 12.15k forks source link

mplayer doesn't compile, error during inline asm parsing #11065

Open alistra opened 13 years ago

alistra commented 13 years ago
Bugzilla Link 10693
Version 2.9
OS Linux
Attachments Compile log
CC @DimitryAndric,@echristo,@efriedma-quic

Extended Description

mplayer-1.0_rc4_p20110322 doesn't compile under clang. Generated log attached.

This was compiled on Gentoo Linux x86 by using:

CC=clang CXX=clang emerge mplayer

USE=3dnow 3dnowext X a52 alsa amr ass cdio dga dirac doc dts dv dvd dvdnav enca encode faac faad ftp gif iconv ipv6 jpeg jpeg2k kernel_linux live lzo mad mmx mmxext mp3 network openal opengl osdmenu oss png quicktime rar real rtc schroedinger sdl shm speex sse sse2 theora toolame tremor truetype twolame unicode vidix vorbis vpx win32codecs x264 xanim xinerama xscreensaver xv xvid xvmc -aalib -altivec -aqua -bidi -bindist -bl -bluray -bs2b -cddb -cdparanoia -cpudetection -custom-cpuopts -debug -directfb -dvb -dxr3 -esd -fbcon -ggi -gsm -jack -joystick -ladspa -libcaca -libmpeg2 -lirc -md5sum -mng -mpg123 -nas -nut -pnm -pulseaudio -pvr -radio -rtmp -samba -ssse3 -tga -v4l -v4l2 -vdpau -video_cards_mga -video_cards_s3virge -video_cards_tdfx -video_cards_vesa -zoran

llvmbot commented 12 years ago

As I recall it boils down to needing lookahead. "16 + (%eax)". Is the '(' the opening paren of a sub-expression or an indirection?

echristo commented 12 years ago

Yeah, I'd love for that to work, unfortunately the assembler thinks that 04 is octal and complains. (i.e. not safe if the stack offset for the variable changes).

Can you elaborate on the grammatical ambiguities? I'm running out of clever ideas for this sort of problem.

llvmbot commented 12 years ago

I vaguely recall this coming up before. IIRC, there's grammatical ambiguities that get pretty ugly in trying to accept this form of the expression. The proper syntax is to include the '0' in the source asm string. That is, "movl 8+0(%esp), %eax".

Usual caveat applies: I'm not an x86 expert.

DimitryAndric commented 12 years ago

In this case, the log happens to be enough: the issue is integrated-as rejecting the following:

movl 8+(%esp), %eax

Clang does seem to accept:

asm volatile("movl 8+4(%esp),%eax");

producing:

0: 8b 44 24 0c mov 0xc(%esp),%eax

GNU as obviously also accepts the '8+4(%esp)'. When leaving out the second operand of the +, you do get a warning from gas; e.g. clang -no-integrated-as of:

asm volatile("movl 8+(%esp),%eax");

will print:

/tmp/asmofs-xUVQvy.s: Assembler messages: /tmp/asmofs-xUVQvy.s:9: Warning: missing operand; zero assumed

So there you have it: if the operand is missing, assume zero. The question is whether clang should also warn...

echristo commented 13 years ago

FWIW a workaround for this is going to be using -no-integrated-as as one of the CFLAGS.

alistra commented 13 years ago

this is the compile line:

clang -MD -MP -D_ISOC99_SOURCE -D_BSD_SOURCE -O2 -march=i686 -pipe -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I. -Iffmpeg -D_REENTRANT -I/usr/include -I/usr/include/freetype2 -DFF_API_MAX_STREAMS=0 -I/usr/include/dirac
-I/usr/include/schroedinger-1.0 -I/usr/include/orc-0.4 -I/usr/include -I/usr/include/libdvdread -fomit-frame-pointer -c -o mp3lib/decode_i586.o mp3lib/decode_i586.c

We need the preprocessed file. This one doesn't compile for us:

decode_i586.c:32:10: fatal error: 'config.h' file not found

include "config.h"

     ^

1 error generated.

Please generate the file by using "-save-temps" on the command line and attaching the .i file that's generated.

sorry, attached the correct file

alistra commented 13 years ago

preprocessed file

llvmbot commented 13 years ago

this is the compile line:

clang -MD -MP -D_ISOC99_SOURCE -D_BSD_SOURCE -O2 -march=i686 -pipe -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I. -Iffmpeg -D_REENTRANT -I/usr/include -I/usr/include/freetype2 -DFF_API_MAX_STREAMS=0 -I/usr/include/dirac
-I/usr/include/schroedinger-1.0 -I/usr/include/orc-0.4 -I/usr/include -I/usr/include/libdvdread -fomit-frame-pointer -c -o mp3lib/decode_i586.o mp3lib/decode_i586.c

We need the preprocessed file. This one doesn't compile for us:

decode_i586.c:32:10: fatal error: 'config.h' file not found

include "config.h"

     ^

1 error generated.

Please generate the file by using "-save-temps" on the command line and attaching the .i file that's generated.

alistra commented 13 years ago

this is the compile line:

clang -MD -MP -D_ISOC99_SOURCE -D_BSD_SOURCE -O2 -march=i686 -pipe -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I. -Iffmpeg -D_REENTRANT -I/usr/include -I/usr/include/freetype2 -DFF_API_MAX_STREAMS=0 -I/usr/include/dirac -I/usr/include/schroedinger-1.0 -I/usr/include/orc-0.4 -I/usr/include -I/usr/include/libdvdread -fomit-frame-pointer -c -o mp3lib/decode_i586.o mp3lib/decode_i586.c

alistra commented 13 years ago

preprocessed file that is compiled

echristo commented 13 years ago

Aaah. I wasn't sure if it was rejecting that or some weirdness with not liking \t which might be a parse error from earlier.

And no, I don't know if we've discussed it or not.

efriedma-quic commented 13 years ago

In this case, the log happens to be enough: the issue is integrated-as rejecting the following:

movl 8+(%esp), %eax

I can't recall whether we've discussed this before.

echristo commented 13 years ago

Needs more information: preprocessed file that's failing and the command line that's causing the problem.